Example 18-15. Selection reply procedure (continued)
do {
Atom *targets = (Atom *)value;
char *target_name;
if (targets[--length]) {
target_name = (char *)xv_get(server, SERVER_ATOM_NAME,
targets[length]);
textsw_insert(textsw, "\t", 1);
textsw_insert(textsw, target_name, strlen(target_name));
textsw_insert(textsw, "\n", 1);
}
} while(length);
}
else
if (target == ATOM(server, "TIMESTAMP")) {
char buf[10];
textsw_insert(textsw, "TIMESTAMP of acquisition: ", 26);
sprintf(buf, "%U\n", *(unsigned long *)value);
textsw_insert(textsw, buf, strlen(buf));
}
else
if (target == ATOM(server, "LENGTH")) {
char buf[10];
textsw_insert(textsw, "Length of selection: ", 21);
sprintf(buf, "%d\n", *(int *)value);
textsw_insert(textsw, buf, strlen(buf));
}
else
if (target == ATOM(server, "STRING")) {
static int incr = False;
if (type == ATOM(server, "INCR")) {
textsw_insert(textsw, "Contents of the selection:\n", 27);
incr = True;
}
else
if (length) {
if (!incr)
textsw_insert(textsw, "Contents of the selection:\n", 27);
textsw_insert(textsw, (char *)value, length);
textsw_insert(textsw, "\n", 1);
}
else
incr = False;
}
else
if (target == ATOM(server, "DELETE")) {
textsw_insert(textsw, "The Selection has been deleted\n", 31);
}
textsw_insert(textsw, LINE, strlen(LINE));
}
428 XView Programming Manual
18.9.0.2 Sample error procedure
The error procedure for this example is shown in Example 18-16.
Example 18-16. Sample error procedure
SelectionError.c
SelectionError(sel, target, errorCode)
Selection_requestor sel;
Atom target;
int errorCode;
{
Atom rank;
char *rank_string;
char *target_string = (char *)xv_get(server,
SERVER_ATOM_NAME, target);
char msg[100];
rank = (Atom)xv_get(sel, SEL_RANK);
rank_string = (char *)xv_get(server, SERVER_ATOM_NAME, rank);
sprintf(msg, "Selection failed for rank %s on target %s: ",
rank_string, target_string);
textsw_insert(textsw, msg, strlen(msg));
switch(errorCode) {
case SEL_BAD_CONVERSION :
textsw_insert(textsw, "Conversion Rejected",
strlen("Conversion Rejected"));
break;
case SEL_BAD_TIME:
textsw_insert(textsw, "Bad Time Match",
strlen("Bad Time Match"));
break;
case SEL_BAD_WIN_ID:
textsw_insert(textsw, "Bad Window Match",
strlen("Bad Window Match"));
break;
case SEL_TIMEDOUT:
textsw_insert(textsw, "Timeout", strlen("Timeout"));
break;
}
}
Selections
Selections 429
18.10 Selection Package Summary
Table 18-3 lists the selection procedures. Table 18-4 lists the selection attributes, including
all the attributes for the SELECTION package, as well as the SELECTION_OWNER,
SELECTION_REQUESTOR, and the SELECTION_ITEM attributes. These attributes and proce-
dures are described fully in the XView Reference Manual.
Table 18-3. Selection Procedures
Procedure Package
sel_convert_proc() Selection Owner
sel_post_req() Selection Requestor
Table 18-4. Selection Attributes
SEL_APPEND_TYPE_NAMES SEL_PROP_FORMAT
SEL_APPEND_TYPES SEL_PROP_INFO
SEL_COPY SEL_PROP_LENGTH
SEL_CONVERT_PROC SEL_RANK
SEL_DATA SEL_RANK_NAME
SEL_DONE_PROC SEL_REPLY_PROC
SEL_FIRST_ITEM SEL_TIME
SEL_FORMAT SEL_TIMEOUT_VALUE
SEL_LENGTH SEL_TYPE
SEL_LOSE_PROC SEL_TYPE_INDEX
SEL_NEXT_ITEM SEL_TYPE_NAME
SEL_OWN SEL_TYPE_NAMES
SEL_PROP_DATA SEL_TYPES
XV_XID
430 XView Programming Manual
This page intentionally left blank
to preserve original page counts.
This page intentionally left blank
to preserve original page counts.

Get Volume 7A: XView Programming Manual now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.