1 | // ================================================================ // |
---|
2 | // // |
---|
3 | // File : AWT_asciiprint.cxx // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Institute of Microbiology (Technical University Munich) // |
---|
7 | // http://www.arb-home.de/ // |
---|
8 | // // |
---|
9 | // ================================================================ // |
---|
10 | |
---|
11 | #include "awt_asciiprint.hxx" |
---|
12 | #include "awt.hxx" |
---|
13 | |
---|
14 | #include <aw_window.hxx> |
---|
15 | #include <aw_root.hxx> |
---|
16 | #include <aw_question.hxx> |
---|
17 | #include <aw_awar.hxx> |
---|
18 | #include <aw_msg.hxx> |
---|
19 | #include <arbdbt.h> |
---|
20 | |
---|
21 | static double awt_aps_get_xy_ratio(AW_root *awr) { |
---|
22 | // AWT_asciiprint_paper_size psize = (AWT_asciiprint_paper_size)awr->awar(AWAR_APRINT_PAPER_SIZE)->read_int(); |
---|
23 | AWT_asciiprint_orientation ori = AWT_asciiprint_orientation(awr->awar(AWAR_APRINT_ORIENTATION)->read_int()); |
---|
24 | double res = 1.0; |
---|
25 | switch (ori) { |
---|
26 | case AWT_APRINT_ORIENTATION_PORTRAIT: |
---|
27 | res = 112.0/90.0; |
---|
28 | break; |
---|
29 | case AWT_APRINT_ORIENTATION_LANDSCAPE: |
---|
30 | res = 112.0/50.0; |
---|
31 | break; |
---|
32 | case AWT_APRINT_ORIENTATION_DOUBLE_PORTRAIT: |
---|
33 | res = 103.0/90.0; |
---|
34 | break; |
---|
35 | } |
---|
36 | return res; |
---|
37 | } |
---|
38 | |
---|
39 | static int awt_aps_get_default_lines_per_page(AW_root *awr) { |
---|
40 | AWT_asciiprint_orientation ori = AWT_asciiprint_orientation(awr->awar(AWAR_APRINT_ORIENTATION)->read_int()); |
---|
41 | switch (ori) { |
---|
42 | case AWT_APRINT_ORIENTATION_PORTRAIT: |
---|
43 | return 80; |
---|
44 | case AWT_APRINT_ORIENTATION_LANDSCAPE: |
---|
45 | return 60; |
---|
46 | case AWT_APRINT_ORIENTATION_DOUBLE_PORTRAIT: |
---|
47 | return 80; |
---|
48 | } |
---|
49 | return -1; |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
53 | static void awt_aps_calc_pages_needed(AW_root *awr) { |
---|
54 | int mag = awr->awar(AWAR_APRINT_MAGNIFICATION)->read_int(); |
---|
55 | if (mag < 25) { |
---|
56 | awr->awar(AWAR_APRINT_MAGNIFICATION)->write_int(mag*2); |
---|
57 | return; |
---|
58 | } |
---|
59 | if (mag > 250) { |
---|
60 | awr->awar(AWAR_APRINT_MAGNIFICATION)->write_int(250); |
---|
61 | return; |
---|
62 | } |
---|
63 | |
---|
64 | int x = awr->awar(AWAR_APRINT_SX)->read_int() * mag / 100; |
---|
65 | int y = awr->awar(AWAR_APRINT_SY)->read_int() * mag / 100; |
---|
66 | int default_lpp = awt_aps_get_default_lines_per_page(awr); |
---|
67 | double xy_ratio = awt_aps_get_xy_ratio(awr); |
---|
68 | int default_cpp = int(default_lpp * xy_ratio); |
---|
69 | |
---|
70 | awr->awar(AWAR_APRINT_DX)->write_float(double(x)/default_cpp); |
---|
71 | awr->awar(AWAR_APRINT_DY)->write_float(double(y)/default_lpp); |
---|
72 | x += default_cpp-1; |
---|
73 | y += default_lpp-1; |
---|
74 | x /= default_cpp; |
---|
75 | y /= default_lpp; |
---|
76 | |
---|
77 | awr->awar(AWAR_APRINT_PAGES)->write_int(x* y); |
---|
78 | } |
---|
79 | |
---|
80 | |
---|
81 | static void awt_aps_set_magnification_to_fit_xpage(AW_root *awr) { |
---|
82 | int x = awr->awar(AWAR_APRINT_SX)->read_int(); |
---|
83 | |
---|
84 | int dx = int(awr->awar(AWAR_APRINT_DX)->read_float()+.5); |
---|
85 | if (dx < 1) dx = 1; |
---|
86 | if (dx > 99) dx = 99; |
---|
87 | |
---|
88 | int default_lpp = awt_aps_get_default_lines_per_page(awr); |
---|
89 | double xy_ratio = awt_aps_get_xy_ratio(awr); |
---|
90 | int default_cpp = int(default_lpp * xy_ratio); |
---|
91 | int mag = 100 * default_cpp * dx / x; |
---|
92 | awr->awar(AWAR_APRINT_MAGNIFICATION)->write_int(mag); |
---|
93 | awt_aps_calc_pages_needed(awr); |
---|
94 | } |
---|
95 | |
---|
96 | static void awt_aps_set_magnification_to_fit_ypage(AW_root *awr) { |
---|
97 | int y = awr->awar(AWAR_APRINT_SY)->read_int(); |
---|
98 | |
---|
99 | int dy = int(awr->awar(AWAR_APRINT_DY)->read_float()+.5); |
---|
100 | if (dy < 1) dy = 1; |
---|
101 | if (dy > 99) dy = 99; |
---|
102 | |
---|
103 | int default_lpp = awt_aps_get_default_lines_per_page(awr); |
---|
104 | int mag = 100 * default_lpp * dy / y; |
---|
105 | awr->awar(AWAR_APRINT_MAGNIFICATION)->write_int(mag); |
---|
106 | awt_aps_calc_pages_needed(awr); |
---|
107 | } |
---|
108 | |
---|
109 | static void awt_aps_set_magnification_to_fit_xpage(AW_window *aww) { |
---|
110 | awt_aps_set_magnification_to_fit_xpage(aww->get_root()); |
---|
111 | } |
---|
112 | static void awt_aps_set_magnification_to_fit_ypage(AW_window *aww) { |
---|
113 | awt_aps_set_magnification_to_fit_ypage(aww->get_root()); |
---|
114 | } |
---|
115 | static void awt_aps_text_changed(AW_root *awr) { |
---|
116 | char *text = awr->awar(AWAR_APRINT_TEXT)->read_string(); |
---|
117 | { |
---|
118 | char *rtext = GBS_replace_tabs_by_spaces(text); |
---|
119 | delete text; |
---|
120 | text = rtext; |
---|
121 | } int maxx, y; |
---|
122 | maxx = 1; y = 0; |
---|
123 | char *s; |
---|
124 | char *ns; |
---|
125 | for (s = text; s; s=ns) { |
---|
126 | ns = strchr(s, '\n'); |
---|
127 | if (ns) { |
---|
128 | ns[0] = 0; |
---|
129 | ns++; |
---|
130 | } |
---|
131 | int slen = strlen(s); |
---|
132 | if (slen > maxx) { |
---|
133 | maxx = slen; |
---|
134 | } |
---|
135 | y++; |
---|
136 | } |
---|
137 | if (!y) y++; |
---|
138 | awr->awar(AWAR_APRINT_SX)->write_int(maxx); |
---|
139 | awr->awar(AWAR_APRINT_SY)->write_int(y); |
---|
140 | delete text; |
---|
141 | awt_aps_set_magnification_to_fit_xpage(awr); |
---|
142 | } |
---|
143 | |
---|
144 | static void write_file(const char *filename, const char *file) { |
---|
145 | fprintf(stderr, "Printing to ASCII file '%s'\n", filename); |
---|
146 | FILE *f = fopen(filename, "r"); |
---|
147 | if (f) { |
---|
148 | fclose(f); |
---|
149 | if (aw_question("overwrite_file", GBS_global_string("File '%s' already exist", filename), "Overwrite,Cancel")) { |
---|
150 | return; |
---|
151 | } |
---|
152 | } |
---|
153 | f = fopen(filename, "w"); |
---|
154 | if (!f) { |
---|
155 | aw_message(GBS_global_string("Cannot write to '%s'", filename)); |
---|
156 | return; |
---|
157 | } |
---|
158 | fprintf(f, "%s", file); |
---|
159 | fclose(f); |
---|
160 | } |
---|
161 | |
---|
162 | static char *printFile(AW_root *awr) { |
---|
163 | const char *home = GB_getenv("HOME"); |
---|
164 | const char *name = awr->awar(AWAR_APRINT_FILE)->read_char_pntr(); |
---|
165 | return GBS_global_string_copy("%s/%s", home, name); |
---|
166 | } |
---|
167 | |
---|
168 | static void awt_aps_go(AW_window *aww) { |
---|
169 | AW_root *awr = aww->get_root(); |
---|
170 | char *text = awr->awar(AWAR_APRINT_TEXT)->read_string(); |
---|
171 | |
---|
172 | freeset(text, GBS_replace_tabs_by_spaces(text)); |
---|
173 | |
---|
174 | AWT_asciiprint_destination dest = (AWT_asciiprint_destination)awr->awar(AWAR_APRINT_PRINTTO)->read_int(); |
---|
175 | if (dest == AWT_APRINT_DEST_FILE_ASCII) { |
---|
176 | char *file = printFile(awr); |
---|
177 | write_file(file, text); |
---|
178 | free(file); |
---|
179 | } |
---|
180 | else { |
---|
181 | char *tmp_file; |
---|
182 | FILE *tmpf; |
---|
183 | { |
---|
184 | char *name = GB_unique_filename("arb_aprint", "txt"); |
---|
185 | tmpf = GB_fopen_tempfile(name, "wt", &tmp_file); |
---|
186 | free(name); |
---|
187 | } |
---|
188 | |
---|
189 | GB_ERROR error = NULL; |
---|
190 | if (!tmpf) { |
---|
191 | error = GBS_global_string("awt_aps_go: %s", GB_await_error()); |
---|
192 | } |
---|
193 | else { |
---|
194 | char *y_begin = text; |
---|
195 | int last_y = 0; |
---|
196 | |
---|
197 | double xy_ratio = awt_aps_get_xy_ratio(awr); |
---|
198 | int mag = awr->awar(AWAR_APRINT_MAGNIFICATION)->read_int(); |
---|
199 | |
---|
200 | int default_lpp = awt_aps_get_default_lines_per_page(awr); |
---|
201 | int default_cpp = int(default_lpp * xy_ratio); |
---|
202 | default_cpp = default_cpp * 100 / mag; |
---|
203 | default_lpp = default_lpp * 100 / mag; |
---|
204 | |
---|
205 | int text_width = awr->awar(AWAR_APRINT_SX)->read_int(); |
---|
206 | int text_height = awr->awar(AWAR_APRINT_SY)->read_int(); |
---|
207 | |
---|
208 | int x; |
---|
209 | int y; |
---|
210 | |
---|
211 | for (y = 0; y < text_height; y += default_lpp) { |
---|
212 | while (last_y < y) { |
---|
213 | last_y ++; |
---|
214 | y_begin = strchr(y_begin, '\n'); |
---|
215 | if (!y_begin) break; |
---|
216 | y_begin++; |
---|
217 | } |
---|
218 | if (!y_begin) break; |
---|
219 | |
---|
220 | for (x = 0; x < text_width; x += default_cpp) { |
---|
221 | char *line = y_begin; |
---|
222 | int i; |
---|
223 | for (i=0; i<default_lpp; i++) { |
---|
224 | if (line) { |
---|
225 | char *next_line = strchr(line, '\n'); |
---|
226 | int line_length; |
---|
227 | if (next_line) { |
---|
228 | line_length = next_line - line; // exclusive '\n' |
---|
229 | next_line ++; |
---|
230 | } |
---|
231 | else { |
---|
232 | line_length = strlen(line); |
---|
233 | } |
---|
234 | if (line_length > x + default_cpp) { |
---|
235 | line_length = x + default_cpp; |
---|
236 | } |
---|
237 | if (line_length > x) { |
---|
238 | fwrite(line + x, sizeof(char), line_length - x, tmpf); |
---|
239 | } |
---|
240 | line = next_line; |
---|
241 | } |
---|
242 | fprintf(tmpf, "\n"); |
---|
243 | } |
---|
244 | } |
---|
245 | } |
---|
246 | fclose(tmpf); |
---|
247 | |
---|
248 | char *a2ps_call = 0; |
---|
249 | { |
---|
250 | AWT_asciiprint_orientation ori = AWT_asciiprint_orientation(awr->awar(AWAR_APRINT_ORIENTATION)->read_int()); |
---|
251 | const char *oristring = ""; |
---|
252 | switch (ori) { |
---|
253 | case AWT_APRINT_ORIENTATION_PORTRAIT: |
---|
254 | oristring = "-p -1 "; |
---|
255 | break; |
---|
256 | case AWT_APRINT_ORIENTATION_LANDSCAPE: |
---|
257 | oristring = "-l -1 "; |
---|
258 | break; |
---|
259 | case AWT_APRINT_ORIENTATION_DOUBLE_PORTRAIT: |
---|
260 | oristring = "-p -2 "; |
---|
261 | break; |
---|
262 | } |
---|
263 | char *header = awr->awar(AWAR_APRINT_TITLE)->read_string(); |
---|
264 | a2ps_call = GBS_global_string_copy("arb_a2ps -ns -nP '-H%s' %s -l%i %s", |
---|
265 | header, oristring, default_lpp, tmp_file); |
---|
266 | free(header); |
---|
267 | } |
---|
268 | |
---|
269 | const char *scall = 0; |
---|
270 | switch (dest) { |
---|
271 | case AWT_APRINT_DEST_PRINTER: { |
---|
272 | char *printer = awr->awar(AWAR_APRINT_PRINTER)->read_string(); |
---|
273 | scall = GBS_global_string("%s |%s; rm -f %s", a2ps_call, printer, tmp_file); |
---|
274 | free(printer); |
---|
275 | break; |
---|
276 | } |
---|
277 | case AWT_APRINT_DEST_FILE_PS: { |
---|
278 | char *file = printFile(awr); |
---|
279 | fprintf(stderr, "Printing to PS file '%s'\n", file); |
---|
280 | scall = GBS_global_string("%s >%s;rm -f %s", a2ps_call, file, tmp_file); |
---|
281 | free(file); |
---|
282 | break; |
---|
283 | } |
---|
284 | case AWT_APRINT_DEST_PREVIEW: { |
---|
285 | char *tmp_file2; |
---|
286 | { |
---|
287 | char *name_only; |
---|
288 | GB_split_full_path(tmp_file, NULL, NULL, &name_only, NULL); |
---|
289 | tmp_file2 = GB_create_tempfile(GBS_global_string("%s.ps", name_only)); |
---|
290 | free(name_only); |
---|
291 | } |
---|
292 | |
---|
293 | if (!tmp_file2) error = GB_await_error(); |
---|
294 | else { |
---|
295 | scall = GBS_global_string("%s >%s;(%s %s;rm -f %s %s)&", |
---|
296 | a2ps_call, tmp_file2, |
---|
297 | GB_getenvARB_GS(), tmp_file2, |
---|
298 | tmp_file, tmp_file2); |
---|
299 | free(tmp_file2); |
---|
300 | } |
---|
301 | break; |
---|
302 | } |
---|
303 | default: |
---|
304 | awt_assert(0); |
---|
305 | break; |
---|
306 | } |
---|
307 | |
---|
308 | if (scall) { |
---|
309 | GB_informationf("executing '%s'", scall); |
---|
310 | if (system(scall) != 0) error = GBS_global_string("Error while calling '%s'", scall); |
---|
311 | } |
---|
312 | |
---|
313 | free(a2ps_call); |
---|
314 | } |
---|
315 | if (error) aw_message(error); |
---|
316 | free(tmp_file); |
---|
317 | } |
---|
318 | free(text); |
---|
319 | } |
---|
320 | |
---|
321 | static void cutExt(char *name, const char *removeExt) { |
---|
322 | char *found = strstr(name, removeExt); |
---|
323 | if (found && strcmp(found, removeExt) == 0) { |
---|
324 | found[0] = 0; |
---|
325 | } |
---|
326 | } |
---|
327 | static char *correct_extension(const char *name, const char *newExt) { |
---|
328 | char *noExt = strdup(name); |
---|
329 | cutExt(noExt, ".ps"); |
---|
330 | cutExt(noExt, ".txt"); |
---|
331 | |
---|
332 | char *result = (char*)malloc(strlen(noExt)+strlen(newExt)+1); |
---|
333 | strcpy(result, noExt); |
---|
334 | strcat(result, newExt); |
---|
335 | if (strcmp(name, result) == 0) freenull(result); |
---|
336 | |
---|
337 | free(noExt); |
---|
338 | return result; |
---|
339 | } |
---|
340 | |
---|
341 | static void aps_correct_filename(AW_root *aw_root) { |
---|
342 | int type = aw_root->awar(AWAR_APRINT_PRINTTO)->read_int(); |
---|
343 | if (type == AWT_APRINT_DEST_FILE_PS || type == AWT_APRINT_DEST_FILE_ASCII) { |
---|
344 | AW_awar *awar_name = aw_root->awar(AWAR_APRINT_FILE); |
---|
345 | const char *name = awar_name->read_char_pntr(); |
---|
346 | char *new_name = NULL; |
---|
347 | |
---|
348 | if (type == AWT_APRINT_DEST_FILE_PS) { |
---|
349 | new_name = correct_extension(name, ".ps"); |
---|
350 | } |
---|
351 | else { |
---|
352 | awt_assert((type == AWT_APRINT_DEST_FILE_ASCII)); |
---|
353 | new_name = correct_extension(name, ".txt"); |
---|
354 | } |
---|
355 | if (new_name) { |
---|
356 | awar_name->write_string(new_name); |
---|
357 | free(new_name); |
---|
358 | } |
---|
359 | } |
---|
360 | } |
---|
361 | |
---|
362 | void AWT_create_ascii_print_window(AW_root *awr, const char *text_to_print, const char *title) { |
---|
363 | static AW_window_simple *aws = 0; |
---|
364 | |
---|
365 | awr->awar_string(AWAR_APRINT_TEXT)->write_string(text_to_print); |
---|
366 | if (title) { |
---|
367 | awr->awar_string(AWAR_APRINT_TITLE)->write_string(title); |
---|
368 | } |
---|
369 | if (aws) { |
---|
370 | awr->awar_float(AWAR_APRINT_DX)->write_float(1.0); |
---|
371 | } |
---|
372 | else { |
---|
373 | aws = new AW_window_simple; |
---|
374 | aws->init(awr, "PRINT", "PRINT"); |
---|
375 | aws->load_xfig("awt/ascii_print.fig"); |
---|
376 | awr->awar_string(AWAR_APRINT_TITLE); |
---|
377 | awr->awar_string(AWAR_APRINT_TEXT) ->add_callback(awt_aps_text_changed); |
---|
378 | |
---|
379 | awr->awar_int(AWAR_APRINT_PAPER_SIZE, (int)AWT_APRINT_PAPERSIZE_A4) ->add_callback(awt_aps_set_magnification_to_fit_xpage); |
---|
380 | awr->awar_int(AWAR_APRINT_MAGNIFICATION, 100) ->add_callback(awt_aps_calc_pages_needed); |
---|
381 | awr->awar_int(AWAR_APRINT_PAGES, 1); |
---|
382 | awr->awar_int(AWAR_APRINT_SX, 1); |
---|
383 | awr->awar_int(AWAR_APRINT_SY, 1); |
---|
384 | |
---|
385 | awr->awar_float(AWAR_APRINT_DX, 1.0); |
---|
386 | awr->awar_float(AWAR_APRINT_DY, 1.0); |
---|
387 | |
---|
388 | awr->awar_string(AWAR_APRINT_FILE, "print.ps")->add_callback(aps_correct_filename); |
---|
389 | |
---|
390 | awr->awar_int(AWAR_APRINT_ORIENTATION, (int)AWT_APRINT_ORIENTATION_PORTRAIT)->add_callback(awt_aps_set_magnification_to_fit_xpage); |
---|
391 | awr->awar_int(AWAR_APRINT_PRINTTO, int(AWT_APRINT_DEST_PRINTER))->add_callback(aps_correct_filename); |
---|
392 | aps_correct_filename(awr); |
---|
393 | |
---|
394 | { |
---|
395 | char *print_command; |
---|
396 | if (getenv("PRINTER")) { |
---|
397 | print_command = GBS_eval_env("lpr -h -P$(PRINTER)"); |
---|
398 | } |
---|
399 | else { |
---|
400 | print_command = strdup("lpr -h"); |
---|
401 | } |
---|
402 | |
---|
403 | awr->awar_string(AWAR_APRINT_PRINTER, print_command); |
---|
404 | free(print_command); |
---|
405 | } |
---|
406 | |
---|
407 | awt_aps_text_changed(awr); |
---|
408 | |
---|
409 | aws->at("close"); |
---|
410 | aws->callback(AW_POPDOWN); |
---|
411 | aws->create_button("CLOSE", "CLOSE"); |
---|
412 | |
---|
413 | |
---|
414 | aws->at("help"); |
---|
415 | aws->callback(makeHelpCallback("asciiprint.hlp")); |
---|
416 | aws->create_button("HELP", "HELP"); |
---|
417 | |
---|
418 | aws->at("go"); |
---|
419 | aws->callback(awt_aps_go); |
---|
420 | aws->create_button("PRINT", "PRINT"); |
---|
421 | |
---|
422 | aws->at("title"); |
---|
423 | aws->create_input_field(AWAR_APRINT_TITLE); |
---|
424 | |
---|
425 | aws->at("text"); |
---|
426 | aws->create_text_field(AWAR_APRINT_TEXT); |
---|
427 | |
---|
428 | aws->button_length(5); |
---|
429 | aws->at("rows"); |
---|
430 | aws->create_button(0, AWAR_APRINT_SY); |
---|
431 | |
---|
432 | aws->at("columns"); |
---|
433 | aws->create_button(0, AWAR_APRINT_SX); |
---|
434 | |
---|
435 | aws->at("magnification"); |
---|
436 | aws->create_input_field(AWAR_APRINT_MAGNIFICATION, 4); |
---|
437 | |
---|
438 | aws->at("paper_size"); |
---|
439 | { |
---|
440 | aws->create_toggle_field(AWAR_APRINT_PAPER_SIZE, 1); |
---|
441 | aws->insert_toggle("A4", "A", int(AWT_APRINT_PAPERSIZE_A4)); |
---|
442 | aws->insert_toggle("US", "U", int(AWT_APRINT_PAPERSIZE_US)); |
---|
443 | aws->update_toggle_field(); |
---|
444 | } |
---|
445 | |
---|
446 | aws->at("orientation"); |
---|
447 | { |
---|
448 | aws->create_toggle_field(AWAR_APRINT_ORIENTATION, 1); |
---|
449 | aws->insert_toggle("#print/portrait.xpm", "P", int(AWT_APRINT_ORIENTATION_PORTRAIT)); |
---|
450 | aws->insert_toggle("#print/landscape.xpm", "P", int(AWT_APRINT_ORIENTATION_LANDSCAPE)); |
---|
451 | aws->update_toggle_field(); |
---|
452 | } |
---|
453 | |
---|
454 | |
---|
455 | aws->at("pages"); |
---|
456 | aws->create_button(0, AWAR_APRINT_PAGES); |
---|
457 | |
---|
458 | aws->at("dcol"); |
---|
459 | aws->callback(awt_aps_set_magnification_to_fit_xpage); |
---|
460 | aws->create_input_field(AWAR_APRINT_DX, 4); |
---|
461 | |
---|
462 | aws->at("drows"); |
---|
463 | aws->callback(awt_aps_set_magnification_to_fit_ypage); |
---|
464 | aws->create_input_field(AWAR_APRINT_DY, 4); |
---|
465 | |
---|
466 | |
---|
467 | aws->at("printto"); |
---|
468 | aws->create_toggle_field(AWAR_APRINT_PRINTTO); |
---|
469 | aws->insert_toggle("Printer", "P", int(AWT_APRINT_DEST_PRINTER)); |
---|
470 | aws->insert_toggle("File (Postscript)", "F", int(AWT_APRINT_DEST_FILE_PS)); |
---|
471 | aws->insert_toggle("File (ASCII)", "A", int(AWT_APRINT_DEST_FILE_ASCII)); |
---|
472 | aws->insert_toggle("Preview", "V", int(AWT_APRINT_DEST_PREVIEW)); |
---|
473 | aws->update_toggle_field(); |
---|
474 | |
---|
475 | aws->at("printer"); |
---|
476 | aws->create_input_field(AWAR_APRINT_PRINTER, 16); |
---|
477 | |
---|
478 | aws->at("filename"); |
---|
479 | aws->create_input_field(AWAR_APRINT_FILE, 16); |
---|
480 | } |
---|
481 | aws->activate(); |
---|
482 | } |
---|
483 | |
---|
484 | |
---|
485 | void AWT_show_file(AW_root *awr, const char *filename) { |
---|
486 | char *text = GB_read_file(filename); |
---|
487 | if (!text) { |
---|
488 | aw_message(GB_await_error()); |
---|
489 | } |
---|
490 | else { |
---|
491 | AWT_create_ascii_print_window(awr, text, filename); |
---|
492 | free(text); |
---|
493 | } |
---|
494 | } |
---|