lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev (patch) - show list of statusline messages from history page


From: Leonid Pauzner
Subject: lynx-dev (patch) - show list of statusline messages from history page
Date: Mon, 19 Apr 1999 04:31:51 +0400 (MSD)

* HTAlert, HTUserMsg and HTInfoMsg statusline messages now stored in a cyrcled
  buffer and accessible from the History Page as LYNXMESSAGES:/ link.
  This allow us to decrease the messages delay in lynx.cfg when we feel
  messages too annoying, but have a nice history list for diagnostic purposes.
  Idea belongs to Bela Lubkin. Buffer of 40 lines long. - LP




diff -u old/htalert.c ./htalert.c
--- old/htalert.c       Tue Apr 13 02:39:16 1999
+++ ./htalert.c Mon Apr 19 03:52:04 1999
@@ -18,6 +18,7 @@
 #include <LYClean.h>
 #include <GridText.h>
 #include <LYCookie.h>
+#include <LYHistory.h> /* store statusline messages */

 #include <LYLeaks.h>

@@ -30,6 +31,7 @@
     CTRACE(tfp, "\nAlert!: %s\n\n", Msg);
     CTRACE_FLUSH(tfp);
     _user_message(ALERT_FORMAT, Msg);
+    _store_message2(ALERT_FORMAT, Msg);

     sleep(AlertSecs);
 }
@@ -69,6 +71,7 @@
     _statusline(Msg);
     if (Msg && *Msg) {
        CTRACE(tfp, "Info message: %s\n", Msg);
+       _store_message(Msg);
        sleep(InfoSecs);
     }
 }
@@ -82,6 +85,7 @@
     _statusline(Msg);
     if (Msg && *Msg) {
        CTRACE(tfp, "User message: %s\n", Msg);
+       _store_message(Msg);
        sleep(MessageSecs);
     }
 }
@@ -95,6 +99,7 @@
        CTRACE(tfp, "User message: ");
        CTRACE(tfp, Msg2, Arg);
        CTRACE(tfp, "\n");
+       _store_message2(Msg2, Arg);
        sleep(MessageSecs);
     }
 }
Only in .: lyexit.c
Only in .: lyexit.h
diff -u old/lygetfil.c ./lygetfil.c
--- old/lygetfil.c      Tue Apr 13 02:39:16 1999
+++ ./lygetfil.c        Mon Apr 19 03:52:06 1999
@@ -259,6 +259,10 @@
                    return(lynx_compile_opts(doc));
 #endif

+               } else if (url_type == LYNXMESSAGES_URL_TYPE) {
+                   /* show list of recent statusline messages */
+                   return(LYshow_statusline_messages(doc));
+
 #ifndef DISABLE_NEWS
                } else if (url_type == NEWSPOST_URL_TYPE ||
                           url_type == NEWSREPLY_URL_TYPE ||
diff -u old/lyhistor.c ./lyhistor.c
--- old/lyhistor.c      Thu Apr 15 15:43:46 1999
+++ ./lyhistor.c        Mon Apr 19 03:52:10 1999
@@ -14,6 +14,7 @@
 #include <LYSignal.h>
 #include <LYStrings.h>
 #include <LYCharUtils.h>
+#include <LYGetFile.h>

 #ifdef DIRED_SUPPORT
 #include <LYUpload.h>
@@ -83,6 +84,7 @@
        !strcmp((doc->title ? doc->title : ""), ADDRLIST_PAGE_TITLE) ||
 #endif
        !strcmp((doc->title ? doc->title : ""), SHOWINFO_TITLE) ||
+       !strcmp((doc->title ? doc->title : ""), STATUSLINES_TITLE) ||
        !strcmp((doc->title ? doc->title : ""), CONFIG_DEF_TITLE) ||
        !strcmp((doc->title ? doc->title : ""), LYNXCFG_TITLE) ||
        !strcmp((doc->title ? doc->title : ""), COOKIE_JAR_TITLE) ||
@@ -392,7 +394,11 @@

     BeginInternalPage(fp0, HISTORY_PAGE_TITLE, HISTORY_PAGE_HELP);

+    fprintf(fp0, "<tr align=right> <a href=\"LYNXMESSAGES:\">[%s]</a> </tr>\n",
+                            gettext("Your recent statusline messages"));
+
     fprintf(fp0, "<pre>\n");
+
     fprintf(fp0, "<em>%s</em>\n", gettext("You selected:"));
     for (x = nhist-1; x >= 0; x--) {
        /*
@@ -595,3 +601,133 @@
     FREE(Address);
     return(0);
 }
+
+
+/*
+ *  Keep cycled buffer for statusline messages.
+ */
+#define STATUSBUFSIZE   40
+PRIVATE char * buffstack[STATUSBUFSIZE];
+PRIVATE int topOfStack = 0;
+
+PUBLIC void to_stack ARGS1(char *, str)
+{
+    /*
+     *  Cycle buffer:
+     */
+    if (topOfStack == STATUSBUFSIZE) {
+       topOfStack = 0;
+    }
+
+    /*
+     *  Register string.
+     */
+    FREE(buffstack[topOfStack]);
+    buffstack[topOfStack] = str;
+    topOfStack++;
+}
+
+#ifdef LY_FIND_LEAKS
+PRIVATE void free_messages_stack NOARGS
+{
+    topOfStack = STATUSBUFSIZE;
+
+    while (--topOfStack >= 0) {
+       FREE(buffstack[topOfStack]);
+    }
+}
+#endif
+
+/*
+ *  Status line messages list, LYNXMESSAGES:/ internal page,
+ *  called from getfile() cyrcle.
+ */
+PUBLIC int LYshow_statusline_messages ARGS1(
+    document *,                       newdoc)
+{
+    static char tempfile[LY_MAXPATH];
+    static char *info_url;
+    DocAddress WWWDoc;  /* need on exit */
+    FILE *fp0;
+    int i;
+
+
+       LYRemoveTemp(tempfile);
+       if ((fp0 = LYOpenTemp (tempfile, HTML_SUFFIX, "w")) == 0) {
+           HTAlert(CANNOT_OPEN_TEMP);
+           return(NOT_FOUND);
+       }
+       LYLocalFileToURL(&info_url, tempfile);
+
+       LYforce_no_cache = TRUE;  /* don't cache this doc */
+
+       BeginInternalPage (fp0, STATUSLINES_TITLE, NULL);
+       fprintf(fp0, "<pre>\n");
+
+
+           fprintf(fp0,  "<ol>\n");
+
+           i = topOfStack;
+           while (--i >= 0) {
+               if (buffstack[i] != NULL)
+               fprintf(fp0,  "<li> <em>%s</em>\n",  buffstack[i]);
+           }
+           i = STATUSBUFSIZE;
+           while (--i >= topOfStack) {
+               if (buffstack[i] != NULL)
+               fprintf(fp0,  "<li> <em>%s</em>\n",  buffstack[i]);
+           }
+
+           fprintf(fp0,  "</ol>\n");
+
+
+       fprintf(fp0, "</pre>\n");
+       EndInternalPage(fp0);
+       LYCloseTempFP(fp0);
+
+
+    /* exit to getfile() cyrcle */
+    StrAllocCopy(newdoc->address, info_url);
+    WWWDoc.address = newdoc->address;
+    WWWDoc.post_data = newdoc->post_data;
+    WWWDoc.post_content_type = newdoc->post_content_type;
+    WWWDoc.bookmark = newdoc->bookmark;
+    WWWDoc.isHEAD = newdoc->isHEAD;
+    WWWDoc.safe = newdoc->safe;
+
+    if (!HTLoadAbsolute(&WWWDoc))
+       return(NOT_FOUND);
+    return(NORMAL);
+}
+
+
+PUBLIC void _store_message2 ARGS2(
+       CONST char *,   message,
+       CONST char *,   argument)
+{
+    char *temp = NULL;
+
+    if (message == NULL)
+       return;
+
+    HTSprintf(&temp, message, (argument == 0) ? "" : argument);
+
+    to_stack(temp);
+
+    return;
+}
+PUBLIC void _store_message ARGS1(
+       CONST char *,   message)
+{
+    char *temp = NULL;
+
+    if (message == NULL)
+       return;
+
+    HTSprintf(&temp, message);
+
+    to_stack(temp);
+
+    return;
+}
+
diff -u old/lyhistor.h ./lyhistor.h
--- old/lyhistor.h      Mon Sep  7 03:02:16 1998
+++ ./lyhistor.h        Mon Apr 19 03:52:12 1999
@@ -14,4 +14,8 @@
 extern void LYpop_num PARAMS((int number, document *doc));
 extern void LYpush PARAMS((document *doc, BOOLEAN force_push));

+extern void _store_message2 PARAMS((CONST char *message, CONST char 
*argument));
+extern void _store_message PARAMS((CONST char *message));
+extern int LYshow_statusline_messages PARAMS((document *newdoc));
+
 #endif /* LYHISTORY_H */
diff -u old/lymessag.h ./lymessag.h
--- old/lymessag.h      Tue Mar 30 09:10:38 1999
+++ ./lymessag.h        Mon Apr 19 03:52:14 1999
@@ -793,6 +793,7 @@
 #define PERMIT_OPTIONS_TITLE   gettext("File Permission Options")
 #define PRINT_OPTIONS_TITLE    gettext("Printing Options")
 #define SHOWINFO_TITLE         gettext("Information about the current 
document")
+#define STATUSLINES_TITLE      gettext("Your recent statusline messages")
 #define UPLOAD_OPTIONS_TITLE   gettext("Upload Options")
 #define VISITED_LINKS_TITLE    gettext("Visited Links Page")

diff -u old/lyutils.c ./lyutils.c
--- old/lyutils.c       Tue Apr 13 02:39:16 1999
+++ ./lyutils.c Mon Apr 19 03:52:18 1999
@@ -2706,6 +2706,12 @@
         */
        return(LYNXCFG_URL_TYPE);

+    } else if (compare_type(cp, "LYNXMESSAGES:", 13)) {
+       /*
+        *  Special Internal Lynx type.
+        */
+       return(LYNXMESSAGES_URL_TYPE);
+
     } else if (compare_type(cp, "LYNXCOMPILEOPTS:", 16)) {
        /*
         *  Special Internal Lynx type.
diff -u old/lyutils.h ./lyutils.h
--- old/lyutils.h       Tue Mar 30 09:10:38 1999
+++ ./lyutils.h Mon Apr 19 03:52:20 1999
@@ -186,10 +186,11 @@
 #define LYNXOPTIONS_URL_TYPE   36
 #define LYNXCFG_URL_TYPE       37
 #define LYNXCOMPILE_OPTS_URL_TYPE 38
+#define LYNXMESSAGES_URL_TYPE  39

-#define PROXY_URL_TYPE         39
+#define PROXY_URL_TYPE         40

-#define UNKNOWN_URL_TYPE       40
+#define UNKNOWN_URL_TYPE       41

 /*
  *  For change_sug_filename().




reply via email to

[Prev in Thread] Current Thread [Next in Thread]