.B OK
button is provided anyway.
.PP
+If the
+.I message
+is
+.RB ` \- '
+then instead the message to display is read from standard input. If the
+first character of
+.I message
+is
+.RB ` % '
+then that character is removed.
+.PP
A button may be selected as being the default (i.e., may be chosen by
pressing
.IR enter ),
/* -*-c-*-
*
- * $Id: xmsg.c,v 1.2 2004/04/08 01:36:29 mdw Exp $
+ * $Id$
*
* Display a message to the user
*
button_v bv = DA_INIT;
button *b;
dstr d = DSTR_INIT;
+ dstr msgbuf = DSTR_INIT;
size_t n, i;
unsigned f = 0;
exit(EXIT_FAILURE);
}
message = argv[optind++];
+ if (*message == '%')
+ message++;
+ else if (strcmp(message, "-") == 0) {
+ for (;;) {
+ size_t n;
+
+ dstr_ensure(&msgbuf, 4096);
+ n = fread(msgbuf.buf + msgbuf.len, 1,
+ msgbuf.sz - msgbuf.len, stdin);
+ if (!n)
+ break;
+ msgbuf.len += n;
+ }
+ if (msgbuf.len && msgbuf.buf[msgbuf.len - 1])
+ msgbuf.len--;
+ dstr_putz(&msgbuf);
+ message = msgbuf.buf;
+ }
if (optind >= argc) {
DA_ENSURE(&bv, 1);