Color + Olc + Formatting

From: Patrick J. Dughi (dughi@IMAXX.NET)
Date: 08/08/97


        First - Who saw the Violent Femmes at Gencon lastnight? Cool :)

                Who else bought cheap pakastani throwing knives, and
leather restraints? Er.. well, maybe not the leather, but knives for
sure.....
                Who else thinks that mudding should be introed to gencon
in some way/shape/form....

        Boy, I wonder how far this freedom of mailing list thing goes -
just as long as I put an OBcircle at the bottom...........

                Bounce!Bounce!Bounce!Bounce!


Obcircle:

        As many of you may be aware, the addition of color and olc with
the new improved editor causes some minor problems The improved editor
tries to not cut words in half, and so will append linefeeds to the
correct area of lines which are too long, and put the rest of the sentance
on the next line.....
        Grab one color-happy builder who sees no problem with using more
than say, 20-40 colors in one line.. you get icky effects after using the
/f or /fi commands to format everything...

        BUT - its easy to fix.. here's what I did..

(keep in mind that this is based on color codes taking 4 characters per
pre-parsed color code (ie, \c00 = 4 chars...)
utils.c  - format_text() - replaces yours with this one

/* re-formats message type formatted char * */
/* (for strings edited with d->str) (mostly olc and mail)     */
void format_text(char **ptr_string, int mode, struct descriptor_data *d, int maxlen) {
   int total_chars, cap_next = TRUE, cap_next_next = FALSE;
   char *flow, *start = NULL, temp;
   /* warning: do not edit messages with max_str's of over this value */
   char formated[MAX_STRING_LENGTH];

   flow   = *ptr_string;
   if (!flow) return;

   if (IS_SET(mode, FORMAT_INDENT)) {
      strcpy(formated, "   ");
      total_chars = 3;
   }
   else {
      *formated = '\0';
      total_chars = 0;
   }
   while (*flow != '\0') {
      while ((*flow == '\n') ||
             (*flow == '\r') ||
             (*flow == '\f') ||
             (*flow == '\t') ||
             (*flow == '\v') ||
             (*flow == ' ')) flow++;

      if (*flow != '\0') {
         start = flow++;
         while ((*flow != '\0') &&
                (*flow != '\n') &&
                (*flow != '\r') &&
                (*flow != '\f') &&
                (*flow != '\t') &&
                (*flow != '\v') &&
                (*flow != ' ') &&
                (*flow != '.') &&
                (*flow != '?') &&
                (*flow != '!')) flow++;

         if (cap_next_next) {
            cap_next_next = FALSE;
            cap_next = TRUE;
         }
         /* this is so that if we stopped on a sentance .. we move off the
            sentance */
         while ((*flow == '.') || (*flow == '!') || (*flow == '?')) {
            cap_next_next = TRUE;
            flow++;
         }

         temp = *flow;
         *flow = '\0';

         if ((total_chars + strlen(start) + 1) > 79) {
            strcat(formated, "\r\n");
            total_chars = 0;
         }

         if (!cap_next) {
            if (total_chars > 0) {
               strcat(formated, " ");
               total_chars++;
              if(*flow == '\\')
                if(total_chars >4)
                  total_chars=total_chars-4;  /* heres the #*/
            }
         }
         else {
            cap_next = FALSE;
            *start = UPPER(*start);
         }

         total_chars += strlen(start);
         strcat(formated, start);

         *flow = temp;
      }
      if (cap_next_next) {
         if ((total_chars + 3) > 79) {
            strcat(formated, "\r\n");
            total_chars = 0;
         }
         else {
            strcat(formated, "  ");
            total_chars += 2;
         }
      }
   }
   strcat(formated, "\r\n");

   if (strlen(formated) > maxlen) formated[maxlen] = '\0';
   RECREATE(*ptr_string, char, MIN(maxlen, strlen(formated)+3));
   strcpy(*ptr_string, formated);
}

        Now, i'd have put in just the modified lines, but i was lazy, and
in a hurry, so i just c&p, rather than actually looking.  I believe I
changed about 3 lines, and added some lines within previously one line
"if" statements.

                                                        PjD


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST