Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ help with word wrap in online edit buffer

help with word wrap in online edit buffer

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Bryn   (14 posts)  Bio
Date Tue 07 Jan 2003 05:06 AM (UTC)
Message
I found this code for a word wrap function in the edit buffer for smaug, but when i used it, it would not recognize any other commands.

/* added format command - shogar */
if ( !str_cmp( cmd+1, "f" ) )
{
char cword[MAX_INPUT_LENGTH];
char cline[MAX_INPUT_LENGTH + 80];
char *sptr,*lwptr,*wptr,*tptr;
int x,linecnt = -1, spacercnt=0;

pager_printf( ch, "Reformating...\n\r");
for ( x = edit->on_line; x < edit->numlines; x++ )
{
if(linecnt < 0)
{
linecnt = x;
lwptr = edit->line[linecnt];
}
tptr = edit->line[x];
while(*tptr)
{
if(!isspace(*tptr))
break;
tptr++;
}
if(! *tptr)
{
if(! spacercnt)
{
linecnt++;
lwptr = edit->line[linecnt];
*lwptr=0;
linecnt++;
spacercnt++;
lwptr = edit->line[linecnt];
}
continue;
}
spacercnt = 0;
strcpy(cline,edit->line[x]);
sptr=cline;
*lwptr = 0;
while(*sptr)
{
wptr = cword;
while(isspace(*sptr) && *sptr)
sptr++;
while(!isspace(*sptr) && *sptr)
*wptr++ = *sptr++;
*wptr=0;

if(! *cword)
{
sptr = cline;
*sptr = 0;
continue;
}
if((strlen(edit->line[linecnt]) + strlen(cword) + 1) > 79)

{
if ( edit->numlines >= max_buf_lines )
{
send_to_pager( "Buffer is full.\n\r> ", ch );
return;
}
else
{
strcpy(edit->line[edit->numlines],"");
edit->numlines++;
linecnt++;
lwptr = edit->line[linecnt];
*lwptr = 0;

}
}
strcat(lwptr,cword);
lwptr += strlen(cword);
strcat(lwptr," ");
lwptr++;
}
}
if(linecnt != -1)
{
for ( x = linecnt + 1; x < edit->numlines; x++ )
{
strcpy(edit->line[x],"");
}
edit->numlines = linecnt + 2;
edit->on_line = linecnt + 1;
}
pager_printf( ch, "Reformating done...\n\r> ");
return;

}

can some one help me?

-Bryn
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #1 on Tue 07 Jan 2003 06:18 AM (UTC)
Message
That is actually specific to the note editor. It applies to the .f command to format a note before posting. It is also used by various description editors thruout the olc for formatting.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by Bryn   (14 posts)  Bio
Date Reply #2 on Tue 07 Jan 2003 06:23 AM (UTC)
Message
ah, ok. Does anyone know where i can find a word wrap snippet for the edit buffer?
Top

Posted by Bryn   (14 posts)  Bio
Date Reply #3 on Tue 07 Jan 2003 06:23 AM (UTC)
Message
ah, ok. Does anyone know where i can find a word wrap snippet for the edit buffer?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Tue 07 Jan 2003 09:15 PM (UTC)
Message
The Area Editor (available on this site) lets you type in descriptions which wrap and then forces them into 78-character lines when you finish.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


17,150 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.