[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Smaug web who, colored?

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Smaug web who, colored?
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Samson   USA  (683 posts)  [Biography] bio
Date Mon 24 Oct 2005 02:47 AM (UTC)  quote  ]
Message
Of course if you wanted to get fancier about it you can use some CSS styling and then go with a white-space:pre and hope that works. Not all browsers will understand it though as far as I know. <pre> text tends to look uglier than the CSSified versions.

SmaugMuds.org: http://www.smaugmuds.org - The Smaug MUDs Community Center

"The past was erased, the erasure was forgotten, the lie became truth." -- George Orwell, 1984
[Go to top] top

Posted by Zeno   USA  (2,867 posts)  [Biography] bio   Moderator
Date Sat 15 Oct 2005 04:45 PM (UTC)  quote  ]

Amended on Sat 15 Oct 2005 05:05 PM (UTC) by Zeno

Message
Thanks, but now I have some issues. In this function:
int send_buf(int fd, char* buf, bool filter )
{
/*
   if ( filter )
   {
        send(fd, "<CODE>", 6, 0);
        buf = text2html(buf);
        send(fd, "</CODE>", 7, 0);
   }
*/
        return send(fd, buf, strlen(buf), 0);
}

I had to comment that bit out or else the code would not work because of the text2html. But now, the color works but the formatting (like the spaces etc) is lost as well as the font. Any ideas? This is what I have:
        web_colourconv( col_buf, buf );
      send_buf(wdesc->fd, col_buf, TRUE);
      send_buf(wdesc->fd,"<BR>",FALSE);  /*Equiv to /n/r --GW */


[EDIT] I fixed the font. All that's left to fix is this tab issue. This is on the MUD:
Owner          Zeno McDohl, the council is inducting  [Head of Newbie Council]

Owner Zeno McDohl, the council is inducting  [Head of Newbie Council] 

The above is on the web who. It used to work without the color. Any idea how to fix this?

[EDIT 2] Fixed. There was a <BR> in there, so I removed that and stuck in <PRE>

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Sat 15 Oct 2005 06:39 AM (UTC)  quote  ]
Message
This is actually the functions that I use, can't remember where I got it from, but mine was originally the Wolfpaw server as well, though at this points it's much different.
int web_colour(char type, char *string)
{
        char code[50];  /* Either this is MSL, or all the things below are 50, i chose this, faster */
        char     *p = '\0';

        switch (type)
        {
        default:
                break;
        case '&':
                mudstrlcpy(code, "&", 50);
                break;
        case 'x':
                mudstrlcpy(code, "</font><font color=#000000>", 50);
                break;
        case 'b':
                mudstrlcpy(code, "</font><font color=#00007F>", 50);
                break;
        case 'c':
                mudstrlcpy(code, "</font><font color=#007F7F>", 50);
                break;
        case 'g':
                mudstrlcpy(code, "</font><font color=#007F00>", 50);
                break;
        case 'r':
                mudstrlcpy(code, "</font><font color=#7F0000>", 50);
                break;
        case 'w':
                mudstrlcpy(code, "</font><font color=#BFBFBF>", 50);
                break;
        case 'y':
                mudstrlcpy(code, "</font><font color=#FFFF00>", 50);
                break;
        case 'Y':
                mudstrlcpy(code, "</font><font color=#FFFF00>", 50);
                break;
        case 'B':
                mudstrlcpy(code, "</font><font color=#0000FF>", 50);
                break;
        case 'C':
                mudstrlcpy(code, "</font><font color=#00FFFF>", 50);
                break;
        case 'G':
                mudstrlcpy(code, "</font><font color=#00FF00>", 50);
                break;
        case 'R':
                mudstrlcpy(code, "</font><font color=#FF0000>", 50);
                break;
        case 'W':
                mudstrlcpy(code, "</font><font color=#FFFFFF>", 50);
                break;
        case 'z':
                mudstrlcpy(code, "</font><font color=#7F7F7F>", 50);
                break;
        case 'o':
                mudstrlcpy(code, "</font><font color=#FFFF00>", 50);
                break;
        case 'O':
                mudstrlcpy(code, "</font><font color=#7F7F00>", 50);
                break;
        case 'p':
                mudstrlcpy(code, "</font><font color=#7F007F>", 50);
                break;
        case 'P':
                mudstrlcpy(code, "</font><font color=#FF00FF>", 50);
                break;

        case '/':
                mudstrlcpy(code, "<br>", 50);
                break;
        case '{':
                snprintf(code, 50, "%c", '{');
                break;
        case '-':
                snprintf(code, 50, "%c", '~');
                break;
        }
        p = code;
        while (*p != '\0')
        {
                *string = *p++;
                *++string = '\0';
        }
        return (strlen(code));
}

void web_colourconv(char *buffer, const char *txt)
{
        const char *point;
        int skip = 0;

        if (txt == NULL || buffer == NULL)
        {
                bug("Null txt or buffer", 0);
                return;
        }
        for (point = txt; *point; point++)
        {
                if (*point == '&')
                {
                        point++;
                        skip = web_colour(*point, buffer);
                        while (skip-- > 0)
                                ++buffer;
                        continue;
                }
                *buffer = *point;
                *++buffer = '\0';
        }
        *buffer = '\0';
        return;
}

int send_buf(int fd, char *buf, int filter)
{
        char string[MSL * 10];

        if (filter == 1)
        {
                send(fd, "<CODE>", 6, 0);
                buf = smash_color(buf);
                buf = text2html(buf);
                send(fd, "</CODE>", 7, 0);
        }
        if (filter == 2)
        {
                web_colourconv(string, buf);
                return send(fd, string, strlen(string), 0);
        }
        return send(fd, buf, strlen(buf), 0);
}

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by Zeno   USA  (2,867 posts)  [Biography] bio   Moderator
Date Sat 15 Oct 2005 01:50 AM (UTC)  quote  ]

Amended on Sat 15 Oct 2005 02:02 AM (UTC) by Zeno

Message
I've noticed quite a few MUD websites have a web who that is colored. While I have a web who, it is not colored. I am using the Wolfpaw snippet, and I was wondering if anyone could explain how I could have colors on web who?

I realize I'd probably have to go through a strip and replace Smaug tokens with HTML codes, but I'm not good with that kind of string changes.

I noticed in the Wolfpaw snippet:
/* Rip out the Smaug Color Sequences --GW */
/* Hey -- I didnt sayit was perfect.. a hack at most*/

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


2,413 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]