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