* New experimental message formatter - try it, you'll like it!
authorMichael Hampton <io_error@uncensored.citadel.org>
Sun, 1 Dec 2002 11:02:57 +0000 (11:02 +0000)
committerMichael Hampton <io_error@uncensored.citadel.org>
Sun, 1 Dec 2002 11:02:57 +0000 (11:02 +0000)
citadel/ChangeLog
citadel/citadel_ipc.c
citadel/commands.c
citadel/configure.ac
citadel/messages.c

index 83333b5f9785144a30c403227023a1adfb3b9435..6184af63251a8579aea17a28639861b34225d1ce 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 601.80  2002/12/01 11:02:57  error
+ * New experimental message formatter - try it, you'll like it!
+
  Revision 601.79  2002/12/01 04:48:24  ajc
  * The code to check for sending invitations needs to happen *after* save
 
@@ -4267,4 +4270,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 3e9da92895135c5a56be8d0790dff9ca81605413..825917ef2221eca2f6d50d52b2e9be87e8fadc8e 100644 (file)
@@ -566,12 +566,13 @@ int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime,
                                        }
                                        remove_token(bbb, 0, '\n');
                                } while ((bbb[0] != 0) && (bbb[0] != '\n'));
+               /*ooga*/                remove_token(bbb, 0, '\n');
                        }
 
 
                }
                if (strlen(bbb)) {
-                       /* Strip trailing whitespace */
+                       /* FIXME: Strip trailing whitespace */
                        bbb = (char *)realloc(bbb, (size_t)(strlen(bbb) + 1));
                } else {
                        bbb = (char *)realloc(bbb, 1);
index cfb6b97614eb8c4c97104ea211905d64ec9e7fa1..fc6322170077ae52274e59ba6723fe06f21f0c1a 100644 (file)
@@ -1344,8 +1344,17 @@ FMTA:    while ((eof_flag == 0) && (strlen(buffer) < 126)) {
        if (a <= 0)
                goto FMTEND;
 
-       if (((a == 13) || (a == 10)) && (old != 13) && (old != 10))
-               a = 32;
+       /*
+       if (a == 10) scr_printf("<a==10>");
+       if (a == 13) scr_printf("<a==13>");
+       */
+
+       if ((a == 13) || (a == 10)) {
+               if ((old != 13) && (old != 10))
+                       a = 32;
+               if ((old == 13) || (old == 10))
+                       a = 0;
+       }
        if (((old == 13) || (old == 10)) && (isspace(real))) {
                if (fpout) {
                        fprintf(fpout, "\n");
@@ -1424,6 +1433,147 @@ FMTEND:
 }
 
 
+/*
+ * fmout() - Citadel text formatter and paginator
+ */
+int fmout2(
+       int width,      /* screen width to use */
+       FILE *fpin,     /* file to read from, or NULL to format given text */
+       char *text,     /* text to be formatted (when fpin is NULL */
+       FILE *fpout,    /* file to write to, or NULL to write to screen */
+       char pagin,     /* nonzero if we should use the paginator */
+       int height,     /* screen height to use */
+       int starting_lp,/* starting value for lines_printed, -1 for global */
+       int subst)      /* nonzero if we should use hypertext mode */
+{
+       char *buffer = NULL;    /* The current message */
+       char *word = NULL;      /* What we are about to actually print */
+       char *e;                /* Pointer to position in text */
+       char old = 0;           /* The previous character */
+       int column = 0;         /* Current column */
+       size_t i;               /* Generic counter */
+
+       word = (char *)calloc(1, width);
+       if (!word) {
+               err_printf("Can't alloc memory to print message: %s!\n",
+                               strerror(errno));
+               logoff(NULL, 3);
+       }
+
+       if (fpin) {
+               size_t got = 0;
+
+               rewind(fpin);
+               i = ftell(fpin);
+               buffer = (char *)calloc(1, i + 1);
+               if (!buffer) {
+                       err_printf("Can't alloc memory for message: %s!\n",
+                                       strerror(errno));
+                       logoff(NULL, 3);
+               }
+               while (got < i) {
+                       size_t g = 0;
+
+                       g = fread(buffer + got, i - got, 1, fpin);
+                       if (g < 1) {    /* error reading or eof */
+                               i = got;
+                               break;
+                       }
+                       got += g;
+               }
+               buffer[i] = 0;
+       } else {
+               buffer = text;
+       }
+
+       if (starting_lp >= 0)
+               lines_printed = starting_lp;
+
+       e = buffer;
+
+       while (*e) {
+               /* First, are we looking at a newline? */
+               if (*e == '\n') {
+                       e++;
+                       if (*e == ' ') {
+                               if (fpout) {
+                                       fprintf(fpout, "\n");
+                               } else {
+                                       scr_printf("\n");
+                                       ++lines_printed;
+                                       lines_printed = checkpagin(lines_printed, pagin, height);
+                               }
+                               column = 0;
+                       } else if (old != ' ') {
+                               if (fpout) {
+                                       fprintf(fpout, " ");
+                               } else {
+                                       scr_printf(" ");
+                               }
+                               column++;
+                       }
+               }
+               old = *e;
+               /* Or are we looking at a space? */
+               if (*e == ' ') {
+                       e++;
+                       if (column >= width - 1) {
+                               if (fpout) {
+                                       fprintf(fpout, "\n");
+                               } else {
+                                       scr_printf("\n");
+                                       ++lines_printed;
+                                       lines_printed = checkpagin(lines_printed, pagin, height);
+                               }
+                               column = 0;
+                       } else if (!(column == 0 && old == ' ')) {
+                               if (fpout) {
+                                       fprintf(fpout, " ");
+                               } else {
+                                       scr_printf(" ");
+                               }
+                               column++;
+                       }
+                       continue;
+               }
+
+               /* Read a word and decide what to do with it */
+               i = 0;
+               while (*e) {
+                       if (isspace(e[i]))
+                               break;
+                       i++;
+               }
+               if (i >= width)         /* Break up really long words */
+                       i = width - 1;
+               strncpy(word, e, i);
+               word[i] = 0;
+               if (column + i >= width) {
+                       if (fpout) {
+                               fprintf(fpout, "\n");
+                       } else {
+                               scr_printf("\n");
+                               ++lines_printed;
+                               lines_printed = checkpagin(lines_printed, pagin, height);
+                       }
+                       column = 0;
+               }
+               if (fpout) {
+                       fprintf(fpout, "%s", word);
+               } else {
+                       scr_printf("%s", word);
+               }
+               column += i;
+               e += i;
+       }
+
+       free(word);
+       if (fpin)
+               free(buffer);
+       return 0;
+}
+
+
 /*
  * support ANSI color if defined
  */
index f8dd6eb387a135f8d3f58fe874f7382eec78f68c..1250be7eeb6c2b01935cc84807dc8719b0a31eb0 100644 (file)
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 dnl $Id$
 AC_PREREQ(2.52)
-AC_INIT([Citadel/UX], [5.91], [http://uncensored.citadel.org/])
+AC_INIT([Citadel/UX], [6.02], [http://uncensored.citadel.org/])
 AC_REVISION([$Revision$])
 AC_CONFIG_SRCDIR([citserver.c])
 AC_PREFIX_DEFAULT(/usr/local/citadel)
@@ -511,6 +511,42 @@ fi
 
 AC_REPLACE_FUNCS(snprintf getutline)
 
+# AC_CACHE_CHECK([the weather], ac_cv_weather, [
+#      sleep 1
+#      echo $ECHO_N "opening your window... $ECHO_C" >&6
+#      sleep 2
+#      month=`date | cut -f 2 -d ' '`
+#      case $month in
+#      Dec | Jan | Feb)
+#              ac_cv_weather="it's cold!"
+#              ;;
+#      Mar | Apr)
+#              ac_cv_weather="it's wet!"
+#              ;;
+#      Jul | Aug)
+#              ac_cv_weather="it's hot!"
+#              ;;
+#      Oct | Nov)
+#              ac_cv_weather="it's cool"
+#              ;;
+#      May | Jun | Sep | *)
+#              ac_cv_weather="it's fine"
+#              ;;
+#      esac
+#      ])
+
+AC_CACHE_CHECK([under the bed], ac_cv_under_the_bed, [
+       number=`date | cut -c 19`
+       case $number in
+       7)
+               ac_cv_under_the_bed="lunatics and monsters found"
+               ;;
+       *)
+               ac_cv_under_the_bed="dust bunnies found"
+               ;;
+       esac
+       ])
+
 dnl Done! Now write the Makefile and sysdep.h
 AC_SUBST(AUTH)
 AC_SUBST(CHKPWD)
index f89c55aca76bdba5c10f112772424df5c7d51916..71b5bbc8dc9726bca4c1356c3efd11c6755a52e9 100644 (file)
@@ -581,7 +581,7 @@ int read_message(CtdlIPC *ipc,
         * Here we go
         */
        if (format_type == 0) {
-               fr = fmout(screenwidth, NULL, message->text, dest,
+               fr = fmout2(screenwidth, NULL, message->text, dest,
                           ((pagin == 1) ? 1 : 0), screenheight, (-1), 1);
        } else {
                char *msgtext;