Commit | Line | Data |
---|---|---|
059ec3d9 PH |
1 | /************************************************* |
2 | * Exim Monitor * | |
3 | *************************************************/ | |
4 | ||
c4ceed07 | 5 | /* Copyright (c) University of Cambridge 1995 - 2012 */ |
059ec3d9 PH |
6 | /* See the file NOTICE for conditions of use and distribution. */ |
7 | ||
8 | ||
9 | #include "em_hdr.h" | |
10 | ||
11 | ||
12 | /* This module contains functions for displaying text in a | |
13 | text widget. It is not used for the log widget, because that | |
14 | is dynamically updated and has special scrolling requirements. */ | |
15 | ||
16 | ||
17 | /* Count of characters displayed */ | |
18 | ||
19 | static int text_count = 0; | |
20 | ||
21 | ||
22 | /************************************************* | |
23 | * Empty the widget * | |
24 | *************************************************/ | |
25 | ||
26 | void text_empty(Widget w) | |
27 | { | |
28 | XawTextBlock b; | |
29 | b.firstPos = 0; | |
30 | b.ptr = CS &b; | |
31 | b.format = FMT8BIT; | |
32 | b.length = 0; | |
33 | XawTextReplace(w, 0, text_count, &b); | |
34 | text_count = 0; | |
35 | XawTextSetInsertionPoint(w, text_count); | |
36 | } | |
37 | ||
38 | ||
39 | ||
40 | /************************************************* | |
41 | * Display text * | |
42 | *************************************************/ | |
43 | ||
44 | void text_show(Widget w, uschar *s) | |
45 | { | |
46 | XawTextBlock b; | |
47 | b.firstPos = 0; | |
48 | b.ptr = CS s; | |
49 | b.format = FMT8BIT; | |
50 | b.length = Ustrlen(s); | |
51 | XawTextReplace(w, text_count, text_count, &b); | |
52 | text_count += b.length; | |
53 | XawTextSetInsertionPoint(w, text_count); | |
54 | } | |
55 | ||
56 | ||
57 | /************************************************* | |
58 | * Display text from format * | |
59 | *************************************************/ | |
60 | ||
e0df1c83 DM |
61 | void text_showf(Widget w, char *s, ...) PRINTF_FUNCTION(2,3); |
62 | ||
059ec3d9 PH |
63 | void text_showf(Widget w, char *s, ...) |
64 | { | |
65 | va_list ap; | |
66 | uschar buffer[1024]; | |
67 | va_start(ap, s); | |
68 | vsprintf(CS buffer, s, ap); | |
69 | va_end(ap); | |
70 | text_show(w, buffer); | |
71 | } | |
72 | ||
73 | /* End of em_text.c */ |