annotate src/gui_xmdlg.c @ 21457:26bdc67a3918 v8.2.1279

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