1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xaw/Paned.h>
#include <X11/Xaw/Label.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/AsciiText.h>
#include "xzwrite.h"
extern Widget toplevel, editor, editTitle;
extern Defaults defs;
extern DestRec current_dest;
void edit_win_init()
{
edit_set_title(¤t_dest);
}
void send_message()
{
char *buf;
int ret;
Widget text_source;
/* I should do more interesting things with these error conditions */
XtVaGetValues(editor, XtNstring, (XtArgVal) &buf,
XtNtextSource, (XtArgVal) &text_source, NULL);
ret = zeph_send_message(¤t_dest, buf);
XawAsciiSourceFreeString(text_source);
switch (ret) {
case SEND_OK:
break;
case SENDFAIL_SEND:
case SENDFAIL_RECV:
case SENDFAIL_ACK:
if (defs.verbose)
XBell(XtDisplay(toplevel), 0);
break;
}
/* Only the second argument matters */
if (defs.close_on_send)
XtCallActionProc(toplevel, "CloseSend", NULL, NULL, 0);
if (defs.clear_on_send)
XtCallActionProc(toplevel, "ClearEditor", NULL, NULL, 0);
}
void edit_set_title(dest)
Dest dest;
{
char *title;
/* alloc two extra bytes for * in case zinst or zrecip are "" */
title = (char *) Malloc( strlen(dest->zclass) + strlen(dest->zinst) +
strlen(dest->zrecip) + 20, "while setting title",
NULL);
sprintf(title, "Sending to <%s, %s, %s>", dest->zclass,
*dest->zinst ? dest->zinst : "*",
*dest->zrecip ? dest->zrecip : "*");
XtVaSetValues(editTitle,
XtNlabel, title,
NULL);
free(title);
}
void edit_clear()
{
XtVaSetValues(editor,
XtNstring, "",
NULL);
}
void edit_yank_prev()
{
Yank yank;
yank = yank_prev();
if (! yank)
return;
XtVaSetValues(editor,
XtNstring, (XtArgVal) yank->msg,
NULL);
if (defs.yank_dest) {
dest_set_current_dest(&yank->dest);
edit_set_title(&yank->dest);
}
}
void edit_yank_next()
{
Yank yank;
yank = yank_next();
if (! yank)
return;
XtVaSetValues(editor,
XtNstring, (XtArgVal) yank->msg,
NULL);
if (defs.yank_dest) {
dest_set_current_dest(&yank->dest);
edit_set_title(&yank->dest);
}
}
void edit_yank_store()
{
char *buf;
Widget text_source;
XtVaGetValues(editor, XtNstring, (XtArgVal) &buf,
XtNtextSource, (XtArgVal) &text_source, NULL);
if (buf != NULL && *buf != '\0')
yank_store(¤t_dest, buf);
XawAsciiSourceFreeString(text_source);
}
|