blob: 9ac41d7f3d06e983d13b521b647f036b11652d04 [file] [log] [blame]
Bram Moolenaardfccaf02004-12-31 20:56:11 +00001/* vi:set ts=8 sts=4 sw=4:
2 *
3 * VIM - Vi IMproved by Bram Moolenaar
Bram Moolenaardfccaf02004-12-31 20:56:11 +00004 *
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 * See README.txt for an overview of the Vim source code.
8 */
9
10/*
Bram Moolenaarb78b0b02005-01-02 11:32:29 +000011 * (C) 2001,2005 by Marcin Dalecki <martin@dalecki.de>
Bram Moolenaardfccaf02004-12-31 20:56:11 +000012 *
13 * Implementation of dialogue functions for the Motif GUI variant.
Bram Moolenaarb78b0b02005-01-02 11:32:29 +000014 *
Bram Moolenaar2c7a7632007-05-10 18:19:11 +000015 * Note about Lesstif: Apparently lesstif doesn't get the widget layout right,
Bram Moolenaarb78b0b02005-01-02 11:32:29 +000016 * when using a dynamic scrollbar policy.
Bram Moolenaardfccaf02004-12-31 20:56:11 +000017 */
18
19#include <Xm/Form.h>
20#include <Xm/PushBG.h>
21#include <Xm/Text.h>
22#include <Xm/TextF.h>
23#include <Xm/Label.h>
24#include <Xm/Frame.h>
25#include <Xm/LabelG.h>
26#include <Xm/ToggleBG.h>
27#include <Xm/SeparatoG.h>
28#include <Xm/DialogS.h>
29#include <Xm/List.h>
30#include <Xm/RowColumn.h>
31#include <Xm/AtomMgr.h>
32#include <Xm/Protocols.h>
33
34#include <X11/keysym.h>
35#include <X11/Xatom.h>
36#include <X11/StringDefs.h>
37#include <X11/Intrinsic.h>
38
39#include "vim.h"
40
41extern Widget vimShell;
42
43#ifdef FEAT_MENU
44# define apply_fontlist(w) gui_motif_menu_fontlist(w)
45#else
46# define apply_fontlist(w)
47#endif
48
49/****************************************************************************
50 * Font selection dialogue implementation.
51 */
52
53static char wild[3] = "*";
54
55/*
56 * FIXME: This is a generic function, which should be used throughout the whole
57 * application.
58 *
59 * Add close_callback, which will be called when the user selects close from
60 * the window menu. The close menu item usually activates f.kill which sends a
61 * WM_DELETE_WINDOW protocol request for the window.
62 */
63
64 static void
65add_cancel_action(Widget shell, XtCallbackProc close_callback, void *arg)
66{
67 static Atom wmp_atom = 0;
68 static Atom dw_atom = 0;
69 Display *display = XtDisplay(shell);
70
71 /* deactivate the built-in delete response of killing the application */
Bram Moolenaar446cb832008-06-24 21:56:24 +000072 XtVaSetValues(shell, XmNdeleteResponse, XmDO_NOTHING, NULL);
Bram Moolenaardfccaf02004-12-31 20:56:11 +000073
74 /* add a delete window protocol callback instead */
75 if (!dw_atom)
76 {
77 wmp_atom = XmInternAtom(display, "WM_PROTOCOLS", True);
78 dw_atom = XmInternAtom(display, "WM_DELETE_WINDOW", True);
79 }
80 XmAddProtocolCallback(shell, wmp_atom, dw_atom, close_callback, arg);
81}
82
83#define MAX_FONTS 65535
84#define MAX_FONT_NAME_LEN 256
85#define MAX_ENTRIES_IN_LIST 5000
86#define MAX_DISPLAY_SIZE 150
87#define TEMP_BUF_SIZE 256
88
89enum ListSpecifier
90{
91 ENCODING,
92 NAME,
93 STYLE,
94 SIZE,
95 NONE
96};
97
98typedef struct _SharedFontSelData
99{
100 Widget dialog;
101 Widget ok;
102 Widget cancel;
103 Widget encoding_pulldown;
104 Widget encoding_menu;
105 Widget list[NONE];
106 Widget name;
107 Widget sample;
108 char **names; /* font name array of arrays */
109 int num; /* number of font names */
110 String sel[NONE]; /* selection category */
111 Boolean in_pixels; /* toggle state - size in pixels */
112 char *font_name; /* current font name */
113 XFontStruct *old; /* font data structure for sample display */
114 XmFontList old_list; /* font data structure for sample display */
115 Boolean exit; /* used for program exit control */
116} SharedFontSelData;
117
118/*
119 * Checking access to the font name array for validity.
120 */
121 static char *
122fn(SharedFontSelData *data, int i)
123{
124 /* Assertion checks: */
125 if (data->num < 0)
126 abort();
127 if (i >= data->num)
128 i = data->num - 1;
129 if (i < 0)
130 i = 0;
131
132 return data->names[i];
133}
134
135/*
136 * Get a specific substring from a font name.
137 */
138 static void
139get_part(char *in, int pos, char *out)
140{
141 int i;
142 int j;
143
144 *out = '\0';
145
146 for (i = 0; (pos > 0) && (in[i] != '\0'); ++i)
147 if (in[i] == '-')
148 pos--;
149
150 if (in[i] == '\0')
151 return;
152
153 for (j = 0; (in[i] != '-') && (in[i] != '\0'); ++i, ++j)
154 out[j] = in[i];
155 out[j] = '\0';
156}
157
158/*
159 * Given a font name this function returns the part used in the first
160 * scroll list.
161 */
162 static void
163name_part(char *font, char *buf)
164{
165 char buf2[TEMP_BUF_SIZE];
166 char buf3[TEMP_BUF_SIZE];
167
168 get_part(font, 2, buf2);
169 get_part(font, 1, buf3);
170
171 if (strlen(buf3))
Bram Moolenaar051b7822005-05-19 21:00:46 +0000172 vim_snprintf(buf, TEMP_BUF_SIZE, "%s (%s)", buf2, buf3);
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000173 else
Bram Moolenaar051b7822005-05-19 21:00:46 +0000174 vim_snprintf(buf, TEMP_BUF_SIZE, "%s", buf2);
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000175}
176
177/*
178 * Given a font name this function returns the part used in the second scroll list.
179 */
180 static void
181style_part(char *font, char *buf)
182{
183 char buf2[TEMP_BUF_SIZE];
184 char buf3[TEMP_BUF_SIZE];
185
186 get_part(font, 3, buf3);
187 get_part(font, 5, buf2);
188
189 if (!strcmp(buf2, "normal") && !strcmp(buf2, "Normal")
190 && !strcmp(buf2, "NORMAL"))
Bram Moolenaar051b7822005-05-19 21:00:46 +0000191 vim_snprintf(buf, TEMP_BUF_SIZE, "%s %s", buf3, buf2);
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000192 else
193 strcpy(buf, buf3);
194
195 get_part(font, 6, buf2);
196
197 if (buf2[0] != '\0')
Bram Moolenaar051b7822005-05-19 21:00:46 +0000198 vim_snprintf(buf3, TEMP_BUF_SIZE, "%s %s", buf, buf2);
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000199 else
200 strcpy(buf3, buf);
201
202 get_part(font, 4, buf2);
203
204 if (!strcmp(buf2, "o") || !strcmp(buf2, "O"))
Bram Moolenaar051b7822005-05-19 21:00:46 +0000205 vim_snprintf(buf, TEMP_BUF_SIZE, "%s oblique", buf3);
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000206 else if (!strcmp(buf2, "i") || !strcmp(buf2, "I"))
Bram Moolenaar051b7822005-05-19 21:00:46 +0000207 vim_snprintf(buf, TEMP_BUF_SIZE, "%s italic", buf3);
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000208
209 if (!strcmp(buf, " "))
210 strcpy(buf, "-");
211}
212
213/*
214 * Given a font name this function returns the part used in the third
215 * scroll list.
216 */
217 static void
218size_part(char *font, char *buf, int inPixels)
219{
220 int size;
221 float temp;
222
223 *buf = '\0';
224
225 if (inPixels)
226 {
227 get_part(font, 7, buf);
228 if (strlen(buf) > 0)
229 {
230 size = atoi(buf);
231 sprintf(buf, "%3d", size);
232 }
233 }
234 else
235 {
236 get_part(font, 8, buf);
237 if (strlen(buf) > 0)
238 {
239 size = atoi(buf);
240 temp = (float)size / 10.0;
241 size = temp;
242 if (buf[strlen(buf) - 1] == '0')
243 sprintf(buf, "%3d", size);
244 else
245 sprintf(buf, "%4.1f", temp);
246 }
247 }
248}
249
250/*
251 * Given a font name this function returns the part used in the choice menu.
252 */
253 static void
254encoding_part(char *font, char *buf)
255{
256 char buf1[TEMP_BUF_SIZE];
257 char buf2[TEMP_BUF_SIZE];
258
259 *buf = '\0';
260
261 get_part(font, 13, buf1);
262 get_part(font, 14, buf2);
263
264 if (strlen(buf1) > 0 && strlen(buf2))
Bram Moolenaar051b7822005-05-19 21:00:46 +0000265 vim_snprintf(buf, TEMP_BUF_SIZE, "%s-%s", buf1, buf2);
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000266 if (!strcmp(buf, " "))
267 strcpy(buf, "-");
268}
269
270/*
271 * Inserts a string into correct sorted position in a list.
272 */
273 static void
274add_to_list(char **buf, char *item, int *count)
275{
276 int i;
277 int j;
278
279 if (*count == MAX_ENTRIES_IN_LIST)
280 return;
281
282 /* avoid duplication */
283 for (i = 0; i < *count; ++i)
284 {
285 if (!strcmp(buf[i], item))
286 return;
287 }
288
289 /* find order place, but make sure that wild card comes first */
290 if (!strcmp(item, wild))
291 i = 0;
292 else
293 for (i = 0; i < *count; ++i)
294 if (strcmp(buf[i], item) > 0 && strcmp(buf[i], wild))
295 break;
296
297 /* now insert the item */
298 for (j = *count; j > i; --j)
299 buf[j] = buf[j-1];
300 buf[i] = XtNewString(item);
301
302 ++(*count);
303}
304
305/*
306 * True if the font matches some field.
307 */
308 static Boolean
309match(SharedFontSelData *data, enum ListSpecifier l, int i)
310{
311 char buf[TEMP_BUF_SIZE];
312
313 /* An empty selection or a wild card matches anything.
314 */
315 if (!data->sel[l] || !strcmp(data->sel[l], wild))
316 return True;
317
318 /* chunk out the desired part... */
319 switch (l)
320 {
321 case ENCODING:
322 encoding_part(fn(data, i), buf);
323 break;
324
325 case NAME:
326 name_part(fn(data, i), buf);
327 break;
328
329 case STYLE:
330 style_part(fn(data, i), buf);
331 break;
332
333 case SIZE:
334 size_part(fn(data, i), buf, data->in_pixels);
335 break;
336 default:
337 ;
338 }
339
340 /* ...and chew it now */
341
342 return !strcmp(buf, data->sel[l]);
343}
344
345 static Boolean
346proportional(char *font)
347{
348 char buf[TEMP_BUF_SIZE];
349
350 get_part(font, 11, buf);
351
352 return !strcmp(buf, "p") || !strcmp(buf, "P");
353}
354
355
356static void encoding_callback(Widget w, SharedFontSelData *data,
357 XtPointer dummy);
358
359/*
360 * Parse through the fontlist data and set up the three scroll lists. The fix
361 * parameter can be used to exclude a list from any changes. This is used for
362 * updates after selections caused by the users actions.
363 */
364 static void
365fill_lists(enum ListSpecifier fix, SharedFontSelData *data)
366{
367 char *list[NONE][MAX_ENTRIES_IN_LIST];
368 int count[NONE];
369 char buf[TEMP_BUF_SIZE];
370 XmString items[MAX_ENTRIES_IN_LIST];
371 int i;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000372 int idx;
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000373
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000374 for (idx = (int)ENCODING; idx < (int)NONE; ++idx)
375 count[idx] = 0;
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000376
377 /* First we insert the wild char into every single list. */
378 if (fix != ENCODING)
379 add_to_list(list[ENCODING], wild, &count[ENCODING]);
380 if (fix != NAME)
381 add_to_list(list[NAME], wild, &count[NAME]);
382 if (fix != STYLE)
383 add_to_list(list[STYLE], wild, &count[STYLE]);
384 if (fix != SIZE)
385 add_to_list(list[SIZE], wild, &count[SIZE]);
386
387 for (i = 0; i < data->num && i < MAX_ENTRIES_IN_LIST; i++)
388 {
389 if (proportional(fn(data, i)))
390 continue;
391
392 if (fix != ENCODING
393 && match(data, NAME, i)
394 && match(data, STYLE, i)
395 && match(data, SIZE, i))
396 {
397 encoding_part(fn(data, i), buf);
398 add_to_list(list[ENCODING], buf, &count[ENCODING]);
399 }
400
401 if (fix != NAME
402 && match(data, ENCODING, i)
403 && match(data, STYLE, i)
404 && match(data, SIZE, i))
405 {
406 name_part(fn(data, i), buf);
407 add_to_list(list[NAME], buf, &count[NAME]);
408 }
409
410 if (fix != STYLE
411 && match(data, ENCODING, i)
412 && match(data, NAME, i)
413 && match(data, SIZE, i))
414 {
415 style_part(fn(data, i), buf);
416 add_to_list(list[STYLE], buf, &count[STYLE]);
417 }
418
419 if (fix != SIZE
420 && match(data, ENCODING, i)
421 && match(data, NAME, i)
422 && match(data, STYLE, i))
423 {
424 size_part(fn(data, i), buf, data->in_pixels);
425 add_to_list(list[SIZE], buf, &count[SIZE]);
426 }
427 }
428
429 /*
430 * And now do the preselection in all lists where there was one:
431 */
432
433 if (fix != ENCODING)
434 {
435 Cardinal n_items;
436 WidgetList children;
437 Widget selected_button = 0;
438
439 /* Get and update the current button list. */
440 XtVaGetValues(data->encoding_pulldown,
441 XmNchildren, &children,
442 XmNnumChildren, &n_items,
443 NULL);
444
445 for (i = 0; i < count[ENCODING]; ++i)
446 {
447 Widget button;
448
449 items[i] = XmStringCreateLocalized(list[ENCODING][i]);
450
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +0000451 if (i < (int)n_items)
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000452 {
453 /* recycle old button */
454 XtVaSetValues(children[i],
455 XmNlabelString, items[i],
456 XmNuserData, i,
457 NULL);
458 button = children[i];
459 }
460 else
461 {
462 /* create a new button */
463 button = XtVaCreateManagedWidget("button",
464 xmPushButtonGadgetClass,
465 data->encoding_pulldown,
466 XmNlabelString, items[i],
467 XmNuserData, i,
468 NULL);
469 XtAddCallback(button, XmNactivateCallback,
470 (XtCallbackProc) encoding_callback, (XtPointer) data);
471 XtManageChild(button);
472 }
473
474 if (data->sel[ENCODING])
475 {
476 if (!strcmp(data->sel[ENCODING], list[ENCODING][i]))
477 selected_button = button;
478 }
479 XtFree(list[ENCODING][i]);
480 }
481
Bram Moolenaar2c7a7632007-05-10 18:19:11 +0000482 /* Destroy all the outstanding menu items.
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000483 */
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +0000484 for (i = count[ENCODING]; i < (int)n_items; ++i)
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000485 {
486 XtUnmanageChild(children[i]);
487 XtDestroyWidget(children[i]);
488 }
489
490 /* Preserve the current selection visually.
491 */
492 if (selected_button)
493 {
494 XtVaSetValues(data->encoding_menu,
495 XmNmenuHistory, selected_button,
496 NULL);
497 }
498
499 for (i = 0; i < count[ENCODING]; ++i)
500 XmStringFree(items[i]);
501 }
502
503 /*
504 * Now loop trough the remaining lists and set them up.
505 */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000506 for (idx = (int)NAME; idx < (int)NONE; ++idx)
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000507 {
508 Widget w;
509
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000510 if (fix == (enum ListSpecifier)idx)
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000511 continue;
512
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000513 switch ((enum ListSpecifier)idx)
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000514 {
515 case NAME:
516 w = data->list[NAME];
517 break;
518 case STYLE:
519 w = data->list[STYLE];
520 break;
521 case SIZE:
522 w = data->list[SIZE];
523 break;
524 default:
525 w = (Widget)0; /* for lint */
526 }
527
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000528 for (i = 0; i < count[idx]; ++i)
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000529 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000530 items[i] = XmStringCreateLocalized(list[idx][i]);
531 XtFree(list[idx][i]);
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000532 }
533 XmListDeleteAllItems(w);
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000534 XmListAddItems(w, items, count[idx], 1);
535 if (data->sel[idx])
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000536 {
537 XmStringFree(items[0]);
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000538 items[0] = XmStringCreateLocalized(data->sel[idx]);
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000539 XmListSelectItem(w, items[0], False);
540 XmListSetBottomItem(w, items[0]);
541 }
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000542 for (i = 0; i < count[idx]; ++i)
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000543 XmStringFree(items[i]);
544 }
545}
546
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000547 static void
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +0000548stoggle_callback(Widget w UNUSED,
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000549 SharedFontSelData *data,
550 XmToggleButtonCallbackStruct *call_data)
551{
552 int i, do_sel;
Bram Moolenaar051b7822005-05-19 21:00:46 +0000553 char newSize[TEMP_BUF_SIZE];
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000554 XmString str;
555
556 if (call_data->reason != (int)XmCR_VALUE_CHANGED)
557 return;
558
559 do_sel = (data->sel[SIZE] != NULL) && strcmp(data->sel[SIZE], wild);
560
561 for (i = 0; do_sel && (i < data->num); i++)
562 if (match(data, ENCODING, i)
563 && match(data, NAME, i)
564 && match(data, STYLE, i)
565 && match(data, SIZE, i))
566 {
567 size_part(fn(data, i), newSize, !data->in_pixels);
568 break;
569 }
570
571 data->in_pixels = !data->in_pixels;
572
573 if (data->sel[SIZE])
574 XtFree(data->sel[SIZE]);
575 data->sel[SIZE] = NULL;
576 fill_lists(NONE, data);
577
578 if (do_sel)
579 {
580 str = XmStringCreateLocalized(newSize);
581 XmListSelectItem(data->list[SIZE], str, True);
582 XmListSetBottomItem(data->list[SIZE], str);
583 XmStringFree(str);
584 }
585}
586
587/*
588 * Show the currently selected font in the sample text label.
589 */
590 static void
591display_sample(SharedFontSelData *data)
592{
593 Arg args[2];
594 int n;
595 XFontStruct * font;
596 XmFontList font_list;
597 Display * display;
598 XmString str;
599
600 display = XtDisplay(data->dialog);
601 font = XLoadQueryFont(display, data->font_name);
602 font_list = gui_motif_create_fontlist(font);
603
604 n = 0;
605 str = XmStringCreateLocalized("AaBbZzYy 0123456789");
606 XtSetArg(args[n], XmNlabelString, str); n++;
607 XtSetArg(args[n], XmNfontList, font_list); n++;
608
609 XtSetValues(data->sample, args, n);
610 XmStringFree(str);
611
612 if (data->old)
613 {
614 XFreeFont(display, data->old);
615 XmFontListFree(data->old_list);
616 }
617 data->old = font;
618 data->old_list = font_list;
619}
620
621
622 static Boolean
623do_choice(Widget w,
624 SharedFontSelData *data,
625 XmListCallbackStruct *call_data,
626 enum ListSpecifier which)
627{
628 char *sel;
629
630 XmStringGetLtoR(call_data->item, XmSTRING_DEFAULT_CHARSET, &sel);
631
632 if (!data->sel[which])
633 data->sel[which] = XtNewString(sel);
634 else
635 {
636 XtFree(data->sel[which]);
637 if (!strcmp(data->sel[which], sel))
638 {
639 /* unselecting current selection */
640 data->sel[which] = NULL;
641 if (w)
642 XmListDeselectItem(w, call_data->item);
643 }
644 else
645 data->sel[which] = XtNewString(sel);
646 }
647 XtFree(sel);
648
649 fill_lists(which, data);
650
651 /* If there is a font selection, we display it. */
652 if (data->sel[ENCODING]
653 && data->sel[NAME]
654 && data->sel[STYLE]
655 && data->sel[SIZE]
656 && strcmp(data->sel[ENCODING], wild)
657 && strcmp(data->sel[NAME], wild)
658 && strcmp(data->sel[STYLE], wild)
659 && strcmp(data->sel[SIZE], wild))
660 {
661 int i;
662
663 if (data->font_name)
664 XtFree(data->font_name);
665 data->font_name = NULL;
666
667 for (i = 0; i < data->num; i++)
668 {
669 if (match(data, ENCODING, i)
670 && match(data, NAME, i)
671 && match(data, STYLE, i)
672 && match(data, SIZE, i))
673 {
674 data->font_name = XtNewString(fn(data, i));
675 break;
676 }
677 }
678
679 if (data->font_name)
680 {
681 XmTextSetString(data->name, data->font_name);
682 display_sample(data);
683 }
684 else
685 do_dialog(VIM_ERROR,
686 (char_u *)_("Error"),
687 (char_u *)_("Invalid font specification"),
688 (char_u *)_("&Dismiss"), 1, NULL);
689
690 return True;
691 }
692 else
693 {
694 int n;
695 XmString str;
696 Arg args[4];
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000697 char *nomatch_msg = _("no specific match");
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000698
699 n = 0;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000700 str = XmStringCreateLocalized(nomatch_msg);
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000701 XtSetArg(args[n], XmNlabelString, str); ++n;
702 XtSetValues(data->sample, args, n);
703 apply_fontlist(data->sample);
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000704 XmTextSetString(data->name, nomatch_msg);
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000705 XmStringFree(str);
706
707 return False;
708 }
709}
710
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000711 static void
712encoding_callback(Widget w,
713 SharedFontSelData *data,
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +0000714 XtPointer dummy UNUSED)
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000715{
716 XmString str;
717 XmListCallbackStruct fake_data;
718
719 XtVaGetValues(w, XmNlabelString, &str, NULL);
720
721 if (!str)
722 return;
723
724 fake_data.item = str;
725
726 do_choice(0, data, &fake_data, ENCODING);
727}
728
729 static void
730name_callback(Widget w,
731 SharedFontSelData *data,
732 XmListCallbackStruct *call_data)
733{
734 do_choice(w, data, call_data, NAME);
735}
736
737 static void
738style_callback(Widget w,
739 SharedFontSelData *data,
740 XmListCallbackStruct *call_data)
741{
742 do_choice(w, data, call_data, STYLE);
743}
744
745 static void
746size_callback(Widget w,
747 SharedFontSelData *data,
748 XmListCallbackStruct *call_data)
749{
750 do_choice(w, data, call_data, SIZE);
751}
752
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000753 static void
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +0000754cancel_callback(Widget w UNUSED,
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000755 SharedFontSelData *data,
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +0000756 XmListCallbackStruct *call_data UNUSED)
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000757{
758 if (data->sel[ENCODING])
759 {
760 XtFree(data->sel[ENCODING]);
761 data->sel[ENCODING] = NULL;
762 }
763 if (data->sel[NAME])
764 {
765 XtFree(data->sel[NAME]);
766 data->sel[NAME] = NULL;
767 }
768 if (data->sel[STYLE])
769 {
770 XtFree(data->sel[STYLE]);
771 data->sel[STYLE] = NULL;
772 }
773 if (data->sel[SIZE])
774 {
775 XtFree(data->sel[SIZE]);
776 data->sel[SIZE] = NULL;
777 }
778
779 if (data->font_name)
780 XtFree(data->font_name);
781 data->font_name = NULL;
782
783 data->num = 0;
784 XFreeFontNames(data->names);
785 data->names = NULL;
786 data->exit = True;
787}
788
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000789 static void
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +0000790ok_callback(Widget w UNUSED,
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000791 SharedFontSelData *data,
Bram Moolenaar4bdbbf72009-05-21 21:27:43 +0000792 XmPushButtonCallbackStruct *call_data UNUSED)
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000793{
794 char *pattern;
795 char **name;
796 int i;
797
798 pattern = XmTextGetString(data->name);
799 name = XListFonts(XtDisplay(data->dialog), pattern, 1, &i);
800 XtFree(pattern);
801
802 if (i != 1)
803 {
804 do_dialog(VIM_ERROR,
805 (char_u *)_("Error"),
806 (char_u *)_("Invalid font specification"),
807 (char_u *)_("&Dismiss"), 1, NULL);
808 XFreeFontNames(name);
809 }
810 else
811 {
812 if (data->font_name)
813 XtFree(data->font_name);
814 data->font_name = XtNewString(name[0]);
815
816 if (data->sel[ENCODING])
817 {
818 XtFree(data->sel[ENCODING]);
819 data->sel[ENCODING] = NULL;
820 }
821 if (data->sel[NAME])
822 {
823 XtFree(data->sel[NAME]);
824 data->sel[NAME] = NULL;
825 }
826 if (data->sel[STYLE])
827 {
828 XtFree(data->sel[STYLE]);
829 data->sel[STYLE] = NULL;
830 }
831 if (data->sel[SIZE])
832 {
833 XtFree(data->sel[SIZE]);
834 data->sel[SIZE] = NULL;
835 }
836
837 XFreeFontNames(name);
838
839 data->num = 0;
840 XFreeFontNames(data->names);
841 data->names = NULL;
842 data->exit = True;
843 }
844}
845
846/*
847 * Returns pointer to an ASCII character string that contains the name of the
848 * selected font (in X format for naming fonts); it is the users responsibility
849 * to free the space allocated to this string.
850 */
851 char_u *
852gui_xm_select_font(char_u *current)
853{
854 static SharedFontSelData _data;
855
856 Widget parent;
857 Widget form;
858 Widget separator;
859 Widget sub_form;
860 Widget size_toggle;
861 Widget name;
862 Widget disp_frame;
863 Widget frame;
864 Arg args[64];
865 int n;
866 XmString str;
867 char big_font[MAX_FONT_NAME_LEN];
868 SharedFontSelData *data;
869
870 data = &_data;
871
872 parent = vimShell;
873 data->names = XListFonts(XtDisplay(parent), "-*-*-*-*-*-*-*-*-*-*-*-*-*-*",
874 MAX_FONTS, &data->num);
875
876 /*
877 * Find the name of the biggest font less than the given limit
878 * MAX_DISPLAY_SIZE used to set up the initial height of the display
879 * widget.
880 */
881
882 {
883 int i;
884 int max;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000885 int idx = 0;
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000886 int size;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000887 char buf[128];
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000888
889 for (i = 0, max = 0; i < data->num; i++)
890 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000891 get_part(fn(data, i), 7, buf);
892 size = atoi(buf);
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000893 if ((size > max) && (size < MAX_DISPLAY_SIZE))
894 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000895 idx = i;
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000896 max = size;
897 }
898 }
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +0000899 strcpy(big_font, fn(data, idx));
Bram Moolenaardfccaf02004-12-31 20:56:11 +0000900 }
901 data->old = XLoadQueryFont(XtDisplay(parent), big_font);
902 data->old_list = gui_motif_create_fontlist(data->old);
903
904 /* Set the title of the Dialog window. */
905 data->dialog = XmCreateDialogShell(parent, "fontSelector", NULL, 0);
906 str = XmStringCreateLocalized(_("Vim - Font Selector"));
907
908 /* Create form popup dialog widget. */
909 form = XtVaCreateWidget("form",
910 xmFormWidgetClass, data->dialog,
911 XmNdialogTitle, str,
912 XmNautoUnmanage, False,
913 XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL,
914 NULL);
915 XmStringFree(str);
916
917 sub_form = XtVaCreateManagedWidget("subForm",
918 xmFormWidgetClass, form,
919 XmNbottomAttachment, XmATTACH_FORM,
920 XmNbottomOffset, 4,
921 XmNrightAttachment, XmATTACH_FORM,
922 XmNrightOffset, 4,
923 XmNtopAttachment, XmATTACH_FORM,
924 XmNtopOffset, 4,
925 XmNorientation, XmVERTICAL,
926 NULL);
927
928 data->ok = XtVaCreateManagedWidget(_("OK"),
929 xmPushButtonGadgetClass, sub_form,
930 XmNleftAttachment, XmATTACH_FORM,
931 XmNrightAttachment, XmATTACH_FORM,
932 XmNtopAttachment, XmATTACH_FORM,
933 XmNtopOffset, 4,
934 NULL);
935 apply_fontlist(data->ok);
936
937 data->cancel = XtVaCreateManagedWidget(_("Cancel"),
938 xmPushButtonGadgetClass, sub_form,
939 XmNrightAttachment, XmATTACH_FORM,
940 XmNleftAttachment, XmATTACH_FORM,
941 XmNtopAttachment, XmATTACH_WIDGET,
942 XmNtopWidget, data->ok,
943 XmNtopOffset, 4,
944 XmNshowAsDefault, True,
945 NULL);
946 apply_fontlist(data->cancel);
947
948 /* Create the separator for beauty. */
949 n = 0;
950 XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
951 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
952 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
953 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
954 XtSetArg(args[n], XmNrightWidget, sub_form); n++;
955 XtSetArg(args[n], XmNrightOffset, 4); n++;
956 separator = XmCreateSeparatorGadget(form, "separator", args, n);
957 XtManageChild(separator);
958
959 /* Create font name text widget and the corresponding label. */
960 data->name = XtVaCreateManagedWidget("fontName",
961 xmTextWidgetClass, form,
962 XmNbottomAttachment, XmATTACH_FORM,
963 XmNbottomOffset, 4,
964 XmNleftAttachment, XmATTACH_FORM,
965 XmNleftOffset, 4,
966 XmNrightAttachment, XmATTACH_WIDGET,
967 XmNrightWidget, separator,
968 XmNrightOffset, 4,
969 XmNeditable, False,
970 XmNeditMode, XmSINGLE_LINE_EDIT,
971 XmNmaxLength, MAX_FONT_NAME_LEN,
972 XmNcolumns, 60,
973 NULL);
974
975 str = XmStringCreateLocalized(_("Name:"));
976 name = XtVaCreateManagedWidget("fontNameLabel",
977 xmLabelGadgetClass, form,
978 XmNlabelString, str,
979 XmNuserData, data->name,
980 XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
981 XmNleftWidget, data->name,
982 XmNbottomAttachment, XmATTACH_WIDGET,
983 XmNbottomWidget, data->name,
984 XmNtopOffset, 1,
985 NULL);
986 XmStringFree(str);
987 apply_fontlist(name);
988
989 /* create sample display label widget */
990 disp_frame = XtVaCreateManagedWidget("sampleFrame",
991 xmFrameWidgetClass, form,
992 XmNshadowType, XmSHADOW_ETCHED_IN,
993 XmNleftAttachment, XmATTACH_FORM,
994 XmNleftOffset, 4,
995 XmNbottomAttachment, XmATTACH_WIDGET,
996 XmNbottomWidget, name,
997 XmNrightAttachment, XmATTACH_WIDGET,
998 XmNrightWidget, separator,
999 XmNrightOffset, 4,
1000 XmNalignment, XmALIGNMENT_BEGINNING,
1001 NULL);
1002
1003 data->sample = XtVaCreateManagedWidget("sampleLabel",
1004 xmLabelWidgetClass, disp_frame,
1005 XmNleftAttachment, XmATTACH_FORM,
1006 XmNtopAttachment, XmATTACH_FORM,
1007 XmNbottomAttachment, XmATTACH_FORM,
1008 XmNrightAttachment, XmATTACH_FORM,
1009 XmNalignment, XmALIGNMENT_BEGINNING,
1010 XmNrecomputeSize, False,
1011 XmNfontList, data->old_list,
1012 NULL);
1013
1014 /* create toggle button */
1015 str = XmStringCreateLocalized(_("Show size in Points"));
1016 size_toggle = XtVaCreateManagedWidget("sizeToggle",
1017 xmToggleButtonGadgetClass, form,
1018 XmNlabelString, str,
1019 XmNleftAttachment, XmATTACH_FORM,
1020 XmNleftOffset, 4,
1021 XmNbottomAttachment, XmATTACH_WIDGET,
1022 XmNbottomWidget, disp_frame,
1023 XmNbottomOffset, 4,
1024 NULL);
1025 XmStringFree(str);
1026 apply_fontlist(size_toggle);
1027 XtManageChild(size_toggle);
1028
1029 /* Encoding pulldown menu.
1030 */
1031
1032 data->encoding_pulldown = XmCreatePulldownMenu(form,
1033 "encodingPulldown", NULL, 0);
1034 str = XmStringCreateLocalized(_("Encoding:"));
1035 n = 0;
1036 XtSetArg(args[n], XmNsubMenuId, data->encoding_pulldown); ++n;
1037 XtSetArg(args[n], XmNlabelString, str); ++n;
1038 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); ++n;
1039 XtSetArg(args[n], XmNleftOffset, 4); ++n;
1040 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); ++n;
1041 XtSetArg(args[n], XmNbottomWidget, size_toggle); ++n;
1042 XtSetArg(args[n], XmNbottomOffset, 4); ++n;
1043 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); ++n;
1044 XtSetArg(args[n], XmNrightWidget, separator); ++n;
1045 XtSetArg(args[n], XmNrightOffset, 4); ++n;
1046 data->encoding_menu = XmCreateOptionMenu(form, "encodingMenu", args, n);
1047 XmStringFree(str);
1048 XmAddTabGroup(data->encoding_menu);
1049
1050 /*
1051 * Create scroll list widgets in a separate subform used to manage the
1052 * different sizes of the lists.
1053 */
1054
1055 sub_form = XtVaCreateManagedWidget("subForm",
1056 xmFormWidgetClass, form,
1057 XmNbottomAttachment, XmATTACH_WIDGET,
1058 XmNbottomWidget, data->encoding_menu,
1059 XmNbottomOffset, 4,
1060 XmNleftAttachment, XmATTACH_FORM,
1061 XmNleftOffset, 4,
1062 XmNrightAttachment, XmATTACH_WIDGET,
1063 XmNrightWidget, separator,
1064 XmNrightOffset, 4,
1065 XmNtopAttachment, XmATTACH_FORM,
1066 XmNtopOffset, 2,
1067 XmNorientation, XmVERTICAL,
1068 NULL);
1069
1070 /* font list */
1071 frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, sub_form,
1072 XmNshadowThickness, 0,
1073 XmNtopAttachment, XmATTACH_FORM,
1074 XmNbottomAttachment, XmATTACH_FORM,
1075 XmNleftAttachment, XmATTACH_FORM,
1076 XmNrightAttachment, XmATTACH_POSITION,
1077 XmNrightPosition, 50,
1078 NULL);
1079
1080 str = XmStringCreateLocalized(_("Font:"));
1081 name = XtVaCreateManagedWidget("nameListLabel", xmLabelGadgetClass, frame,
1082 XmNchildType, XmFRAME_TITLE_CHILD,
1083 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
1084 XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING,
1085 XmNlabelString, str,
1086 NULL);
1087 XmStringFree(str);
1088 apply_fontlist(name);
1089
1090 n = 0;
1091 XtSetArg(args[n], XmNvisibleItemCount, 8); ++n;
1092 XtSetArg(args[n], XmNresizable, True); ++n;
1093 XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT); ++n;
1094 XtSetArg(args[n], XmNvisualPolicy, XmVARIABLE); ++n;
1095#ifdef LESSTIF_VERSION
1096 XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC); ++n;
1097#endif
1098 data->list[NAME] = XmCreateScrolledList(frame, "fontList", args, n);
1099 XtVaSetValues(name, XmNuserData, data->list[NAME], NULL);
1100
1101 /* style list */
1102 frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, sub_form,
1103 XmNshadowThickness, 0,
1104 XmNtopAttachment, XmATTACH_FORM,
1105 XmNbottomAttachment, XmATTACH_FORM,
1106 XmNleftAttachment, XmATTACH_POSITION,
1107 XmNleftPosition, 50,
1108 XmNleftOffset, 4,
1109 XmNrightAttachment, XmATTACH_POSITION,
1110 XmNrightPosition, 80,
1111 NULL);
1112
1113 str = XmStringCreateLocalized(_("Style:"));
1114 name = XtVaCreateManagedWidget("styleListLabel", xmLabelWidgetClass, frame,
1115 XmNchildType, XmFRAME_TITLE_CHILD,
1116 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
1117 XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING,
1118 XmNlabelString, str,
1119 NULL);
1120 XmStringFree(str);
1121 apply_fontlist(name);
1122
1123 n = 0;
1124 XtSetArg(args[n], XmNvisibleItemCount, 8); ++n;
1125 XtSetArg(args[n], XmNresizable, True); ++n;
1126 XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT); ++n;
1127 XtSetArg(args[n], XmNvisualPolicy, XmVARIABLE); ++n;
1128#ifdef LESSTIF_VERSION
1129 XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC); ++n;
1130#endif
1131 data->list[STYLE] = XmCreateScrolledList(frame, "styleList", args, n);
1132 XtVaSetValues(name, XmNuserData, data->list[STYLE], NULL);
1133
1134 /* size list */
1135 frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, sub_form,
1136 XmNshadowThickness, 0,
1137 XmNtopAttachment, XmATTACH_FORM,
1138 XmNbottomAttachment, XmATTACH_FORM,
1139 XmNleftAttachment, XmATTACH_POSITION,
1140 XmNleftPosition, 80,
1141 XmNleftOffset, 4,
1142 XmNrightAttachment, XmATTACH_FORM,
1143 NULL);
1144
1145 str = XmStringCreateLocalized(_("Size:"));
1146 name = XtVaCreateManagedWidget("sizeListLabel", xmLabelGadgetClass, frame,
1147 XmNchildType, XmFRAME_TITLE_CHILD,
1148 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
1149 XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING,
1150 XmNlabelString, str,
1151 NULL);
1152 XmStringFree(str);
1153 apply_fontlist(name);
1154
1155 n = 0;
1156 XtSetArg(args[n], XmNvisibleItemCount, 8); ++n;
1157 XtSetArg(args[n], XmNresizable, True); ++n;
1158 XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT); ++n;
1159 XtSetArg(args[n], XmNvisualPolicy, XmVARIABLE); ++n;
1160#ifdef LESSTIF_VERSION
1161 XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC); ++n;
1162#endif
1163 data->list[SIZE] = XmCreateScrolledList(frame, "sizeList", args, n);
1164 XtVaSetValues(name, XmNuserData, data->list[SIZE], NULL);
1165
1166 /* update form widgets cancel button */
1167 XtVaSetValues(form, XmNcancelButton, data->cancel, NULL);
1168
1169 XtAddCallback(size_toggle, XmNvalueChangedCallback,
1170 (XtCallbackProc)stoggle_callback, (XtPointer)data);
1171 XtAddCallback(data->list[NAME], XmNbrowseSelectionCallback,
1172 (XtCallbackProc)name_callback, (XtPointer)data);
1173 XtAddCallback(data->list[STYLE], XmNbrowseSelectionCallback,
1174 (XtCallbackProc)style_callback, (XtPointer)data);
1175 XtAddCallback(data->list[SIZE], XmNbrowseSelectionCallback,
1176 (XtCallbackProc)size_callback, (XtPointer)data);
1177 XtAddCallback(data->ok, XmNactivateCallback,
1178 (XtCallbackProc)ok_callback, (XtPointer)data);
1179 XtAddCallback(data->cancel, XmNactivateCallback,
1180 (XtCallbackProc)cancel_callback, (XtPointer)data);
1181
1182 XmProcessTraversal(data->list[NAME], XmTRAVERSE_CURRENT);
1183
1184 /* setup tabgroups */
1185
1186 XmAddTabGroup(data->list[NAME]);
1187 XmAddTabGroup(data->list[STYLE]);
1188 XmAddTabGroup(data->list[SIZE]);
1189 XmAddTabGroup(size_toggle);
1190 XmAddTabGroup(data->name);
1191 XmAddTabGroup(data->ok);
1192 XmAddTabGroup(data->cancel);
1193
1194 add_cancel_action(data->dialog, (XtCallbackProc)cancel_callback, data);
1195
1196 /* Preset selection data. */
1197
1198 data->exit = False;
1199 data->in_pixels= True;
1200 data->sel[ENCODING] = NULL;
1201 data->sel[NAME] = NULL;
1202 data->sel[STYLE] = NULL;
1203 data->sel[SIZE] = NULL;
1204 data->font_name = NULL;
1205
1206 /* set up current font parameters */
1207 if (current && current[0] != '\0')
1208 {
1209 int i;
1210 char **names;
1211
1212 names = XListFonts(XtDisplay(form), (char *) current, 1, &i);
1213
1214 if (i != 0)
1215 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00001216 char namebuf[TEMP_BUF_SIZE];
1217 char stylebuf[TEMP_BUF_SIZE];
1218 char sizebuf[TEMP_BUF_SIZE];
1219 char encodingbuf[TEMP_BUF_SIZE];
Bram Moolenaardfccaf02004-12-31 20:56:11 +00001220 char *found;
1221
1222 found = names[0];
1223
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00001224 name_part(found, namebuf);
1225 style_part(found, stylebuf);
1226 size_part(found, sizebuf, data->in_pixels);
1227 encoding_part(found, encodingbuf);
Bram Moolenaardfccaf02004-12-31 20:56:11 +00001228
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00001229 if (strlen(namebuf) > 0
1230 && strlen(stylebuf) > 0
1231 && strlen(sizebuf) > 0
1232 && strlen(encodingbuf) > 0)
Bram Moolenaardfccaf02004-12-31 20:56:11 +00001233 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00001234 data->sel[NAME] = XtNewString(namebuf);
1235 data->sel[STYLE] = XtNewString(stylebuf);
1236 data->sel[SIZE] = XtNewString(sizebuf);
1237 data->sel[ENCODING] = XtNewString(encodingbuf);
Bram Moolenaardfccaf02004-12-31 20:56:11 +00001238 data->font_name = XtNewString(names[0]);
1239 display_sample(data);
1240 XmTextSetString(data->name, data->font_name);
1241 }
1242 else
1243 {
1244 /* We can't preset a symbolic name, which isn't a full font
1245 * description. Therefore we just behave the same way as if the
1246 * user didn't have selected anything thus far.
1247 *
1248 * Unfortunately there is no known way to expand an abbreviated
1249 * font name.
1250 */
1251
1252 data->font_name = NULL;
1253 }
1254 }
1255 XFreeFontNames(names);
1256 }
1257
1258 fill_lists(NONE, data);
1259
1260 /* Unfortunately LessTif doesn't align the list widget's properly. I don't
1261 * have currently any idea how to fix this problem.
1262 */
1263 XtManageChild(data->list[NAME]);
1264 XtManageChild(data->list[STYLE]);
1265 XtManageChild(data->list[SIZE]);
1266 XtManageChild(data->encoding_menu);
1267 manage_centered(form);
1268
1269 /* modal event loop */
1270 while (!data->exit)
1271 XtAppProcessEvent(XtWidgetToApplicationContext(data->dialog),
1272 (XtInputMask)XtIMAll);
1273
1274 XtDestroyWidget(data->dialog);
1275
1276 if (data->old)
1277 {
1278 XFreeFont(XtDisplay(data->dialog), data->old);
1279 XmFontListFree(data->old_list);
1280 }
1281
1282 gui_motif_synch_fonts();
1283
1284 return (char_u *) data->font_name;
1285}