Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/msgc provide APIs (currently mostly undocumented) to...



details:   https://anonhg.NetBSD.org/src/rev/e8891841a603
branches:  trunk
changeset: 474355:e8891841a603
user:      cgd <cgd%NetBSD.org@localhost>
date:      Sun Jul 04 07:40:51 1999 +0000

description:
provide APIs (currently mostly undocumented) to print pre-formatted
(table) text.

diffstat:

 usr.bin/msgc/msg_sys.def |  63 ++++++++++++++++++++++++++++++++----------------
 usr.bin/msgc/msgc.1      |   8 ++++-
 usr.bin/msgc/msgdb.c     |   6 +++-
 3 files changed, 52 insertions(+), 25 deletions(-)

diffs (221 lines):

diff -r 4f6dd8d31665 -r e8891841a603 usr.bin/msgc/msg_sys.def
--- a/usr.bin/msgc/msg_sys.def  Sun Jul 04 06:45:26 1999 +0000
+++ b/usr.bin/msgc/msg_sys.def  Sun Jul 04 07:40:51 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_sys.def,v 1.9 1999/06/23 17:42:11 cgd Exp $        */
+/*     $NetBSD: msg_sys.def,v 1.10 1999/07/04 07:40:51 cgd Exp $       */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -41,11 +41,8 @@
 static size_t cbuffersize;
 static int do_echo = 1;
 
-#if defined(DYNAMIC_MESSAGE_LAYOUT)
 static int last_i_was_nl, last_i_was_space;
 static int last_o_was_punct, last_o_was_space;
-#endif /* defined(DYNAMIC_MESSAGE_LAYOUT) */
-
 
 /* Routines */
 
@@ -83,10 +80,8 @@
 {
        wclear (msg_win);
        wrefresh (msg_win);
-#if defined(DYNAMIC_MESSAGE_LAYOUT)
        last_o_was_punct = 0;
        last_o_was_space = 1;
-#endif /* defined(DYNAMIC_MESSAGE_LAYOUT) */
 }
 
 void msg_standout(void)
@@ -99,17 +94,27 @@
        wstandend(msg_win);
 }
 
-int msg_vprintf (char *fmt, va_list ap)
+int msg_vprintf (int auto_fill, char *fmt, va_list ap)
 {
-#if defined(DYNAMIC_MESSAGE_LAYOUT)
        const char *wstart, *afterw;
        int wordlen, nspaces;
-#endif /* defined(DYNAMIC_MESSAGE_LAYOUT) */
        int ret;
 
        ret = vsnprintf (cbuffer, cbuffersize, fmt, ap);
 
-#if defined(DYNAMIC_MESSAGE_LAYOUT)
+       if (!auto_fill) {
+               waddstr(msg_win, cbuffer);
+
+               /*
+                * nothing is perfect if they flow text after a table,
+                * but this may be decent.
+                */
+               last_i_was_nl = last_i_was_space = 1;
+               last_o_was_punct = 0;
+               last_o_was_space = 1;
+               goto out;
+       }
+
        for (wstart = afterw = cbuffer; *wstart; wstart = afterw) {
 
                /* eat one space, or a whole word of non-spaces */
@@ -119,7 +124,6 @@
                        while (*afterw && !isspace(*afterw))
                                afterw++;
 
-               /* last was an nl, this is an nl: paragraph break */
                /* this is an nl: special formatting necessary */
                if (*wstart == '\n') {
                        if (last_i_was_nl || last_i_was_space) {
@@ -209,10 +213,8 @@
                last_o_was_punct = 0;
                last_o_was_space = 1;
        }
-#else /* defined(DYNAMIC_MESSAGE_LAYOUT) */
-       waddstr (msg_win, cbuffer);
-#endif /* defined(DYNAMIC_MESSAGE_LAYOUT) */
 
+out:
        wrefresh (msg_win);
        return ret;
 }
@@ -224,7 +226,7 @@
        msg_clear();
 
        va_start(ap, msg_no);
-       (void)msg_vprintf (msg_list[msg_no], ap);
+       (void)msg_vprintf(0/*XXX*/, msg_list[msg_no], ap);
        va_end(ap);
 }
 
@@ -233,7 +235,7 @@
        va_list ap;
 
        va_start (ap, msg_no);
-       (void)msg_vprintf (msg_list[msg_no], ap);
+       (void)msg_vprintf(0/*XXX*/, msg_list[msg_no], ap);
        va_end (ap);
 }
 
@@ -245,7 +247,7 @@
        msg_clear();
 
        va_start (ap, fmt);
-       res = msg_vprintf (fmt, ap);
+       res = msg_vprintf (0/*XXX*/, fmt, ap);
        va_end (ap);
        return res;
 }
@@ -256,7 +258,7 @@
        int  res;
 
        va_start (ap, fmt);
-       res = msg_vprintf (fmt, ap);
+       res = msg_vprintf (0/*XXX*/, fmt, ap);
        va_end (ap);
        return res;
 }
@@ -270,7 +272,7 @@
        int y,x;
        char *ibuf = alloca(max_chars);
 
-       msg_vprintf (msg, ap);
+       msg_vprintf (0, msg, ap);
        if (def != NULL && *def) {
                waddstr (msg_win, " [");
                waddstr (msg_win, def);
@@ -336,10 +338,8 @@
        }
        if (do_echo) {
                waddch(msg_win, '\n');
-#if defined(DYNAMIC_MESSAGE_LAYOUT)
                last_o_was_punct = 0;
                last_o_was_space = 1;
-#endif /* defined(DYNAMIC_MESSAGE_LAYOUT) */
        }
 
        /* copy the appropriate string to the output */
@@ -401,3 +401,24 @@
 {
        do_echo = 1;
 }
+
+void msg_table(int msg_no, ...)
+{
+       va_list ap;
+
+       msg_clear();
+
+       va_start(ap, msg_no);
+       (void)msg_vprintf(0, msg_list[msg_no], ap);
+       va_end(ap);
+}
+
+void msg_table_add(int msg_no, ...)
+{
+       va_list ap;
+
+       va_start (ap, msg_no);
+       (void)msg_vprintf(0, msg_list[msg_no], ap);
+       va_end (ap);
+}
+
diff -r 4f6dd8d31665 -r e8891841a603 usr.bin/msgc/msgc.1
--- a/usr.bin/msgc/msgc.1       Sun Jul 04 06:45:26 1999 +0000
+++ b/usr.bin/msgc/msgc.1       Sun Jul 04 07:40:51 1999 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: msgc.1,v 1.4 1999/04/25 09:10:07 veego Exp $
+.\"    $NetBSD: msgc.1,v 1.5 1999/07/04 07:40:51 cgd Exp $
 .\"
 .\" Copyright 1997 Piermont Information Systems Inc.
 .\" All rights reserved.
@@ -62,7 +62,7 @@
 .Ft void 
 .Fn msg_display_add "int msg_no" ...
 .Ft int  
-.Fn msg_vprintf  "char *fmt" "va_list ap"
+.Fn msg_vprintf  "int auto_fill" "char *fmt" "va_list ap"
 .Ft int  
 .Fn msg_printf  "char *fmt" ...
 .Ft int  
@@ -79,6 +79,10 @@
 .Fn msg_echo  "void"
 .Ft void 
 .Fn msg_noecho  "void"
+.Ft void 
+.Fn msg_table "int msg_no" ...
+.Ft void 
+.Fn msg_table_add "int msg_no" ...
 .Sh DESCRIPTION
 This implements a curses based message display system.  A source file that 
 lists messages with associated names is given to
diff -r 4f6dd8d31665 -r e8891841a603 usr.bin/msgc/msgdb.c
--- a/usr.bin/msgc/msgdb.c      Sun Jul 04 06:45:26 1999 +0000
+++ b/usr.bin/msgc/msgdb.c      Sun Jul 04 07:40:51 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msgdb.c,v 1.5 1999/06/22 15:00:37 cgd Exp $    */
+/*     $NetBSD: msgdb.c,v 1.6 1999/07/04 07:40:51 cgd Exp $    */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -150,7 +150,7 @@
                "void msg_standend(void);\n"
                "void msg_display(int msg_no,...);\n"
                "void msg_display_add(int msg_no,...);\n"
-               "int  msg_vprintf (char *fmt, va_list ap);\n"
+               "int  msg_vprintf (int auto_fill, char *fmt, va_list ap);\n"
                "int  msg_printf (char *fmt, ...);\n"
                "int  msg_printf_add (char *fmt, ...);\n"
                "void msg_prompt_str (char *msg, char *def, char *val,"
@@ -163,6 +163,8 @@
                        " int max_chars, ...);\n"
                "void msg_echo (void);\n"
                "void msg_noecho (void);\n"
+               "void msg_table(int msg_no,...);\n"
+               "void msg_table_add(int msg_no,...);\n"
                "\n"
                "/* Message names */\n"
              );



Home | Main Index | Thread Index | Old Index