Funny you'd ask that.  I was just working on that a few days ago.

I ended up implementing NAWS (negotiate about window size) as a telnet
option to automatically gather window size information from players.
Given that information, all you need to do, then, is add initialization,
and move the cursor before/after prompt writes.

Implementing NAWS is the hardest part.  You could just skip this step and
let players define their own size, as is done with scroll.  If you'd like
the code I ended up using for NAWS, let me know.

As for the actual cursor location/initialization:

                /* This code lives in process_output.  Half goes above 
bust_a_prompt,
                the other half after.

                bit N turns on the new prompt.  d->size[0] should be 3, if NAWS
                was negotiated correctly.  (3 means uninitialized, 4 means 
initialized)

                wsize[1] is width, d->wsize[2] is height. */

            if (ch->bits[CHAR_BIT_GENERAL] & N && d->wsize[0] == 3 &&
d->wsize[1] > 2 && d->wsize[2] > 2)
            {
                sprintf(buf,"\ec\e[1;%dr", d->wsize[2] - 1); /* \ec - reset
status.  Should be optional.
                                                                                
    \e[x;xr - set scroll region, as discussed
                                                                                
    in the link you provided. */

                write_to_buffer(d,buf,0);

                d->wsize[0] = 4;  /* Set to initialized */
            }

                /* Same ifcheck as above, only, it makes sure that the scroll 
region is
already set */

            if (ch->bits[CHAR_BIT_GENERAL] & N && d->wsize[0] == 4 &&
d->wsize[1] > 2 && d->wsize[2] > 2)
            {
                sprintf(buf,"\e[%d;0H\e[2K", /* \e[x;xH - Move the cursor to
x x, in this case d->wsize[2],
                                                                            or 
the bottom of the screen.
                                                                \e[2K - Erase 
the line that used to be here. */
                    d->wsize[2]);

                write_to_buffer(d,buf,0);
            }

            bust_a_prompt( d->character );  /* Write the actual prompt */

                /* Same ifcheck as above */

            if (ch->bits[CHAR_BIT_GENERAL] & N && d->wsize[0] == 4 &&
d->wsize[1] > 2 && d->wsize[2] > 2)
            {
                sprintf(buf,"\e[%d;0H", d->wsize[2] - 1); /* Again, move the
cursor.  This time, move it to
                                                                                
 1 above the bottom of the screen.  This is also
                                                                                
 the bototm of the scroll region. */

                write_to_buffer(d, buf, 0);
            }

Assuming you aren't interested in NAWS and can collect the above information
directly from players, then, this should be all you need.

It is worth noting that Zmud isn't a big fan of scroll regions.  It's pretty
much a non-issue, though, unless you happen to be scrolling up right as the
cursor is moved to write a new prompt.  Otherwise, it seems to work
perfectly
with every client supporting NAWS.

Also note that the comments were added after the fact, in an effort to make
it
more helpful to you.  Everything should be right, though!

Finally, it is worth noting that you COULD try to remember the previous
cursor
location rather than just setting it back to being 1 above the bottom of the
screen, but... I ran in to compatability issues.  I ended up just using the
above to make sure that it'd work right for more people.

Good luck.
Azuel

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, April 01, 2003 7:38 PM
To: [email protected]
Subject: VT100 Prompts


Hello List,

First time poster.. I was just wondering if anyone out there has
implemented VT100 prompts in a Rom2.4 based MUD. I just read Erwin's
letter back from 1996 (http://www.andreasen.org/letters/vt100.txt) and
recently saw this on another mud. Basically, the prompt does not move
from the bottom few lines of the terminal and simply gets updated when
hp, mana, etc change. This feature provides for a much less spammy
mudding experience.

Anyway, if anyone has written such code and would be willing to
contribute it let me know. Or if anyone knows where it is available on
the web, that would be great too.

Thanks in advance,
John




Reply via email to