annotate src/gui_xmdlg.c @ 12525:626fb8e8bb8a v8.0.1141

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