-----Original Message----- From: Chris Hyde <slugger@CRYOGEN.FERRIS.EDU> To: CIRCLE@post.queensu.ca <CIRCLE@post.queensu.ca> Date: Thursday, March 26, 1998 7:48 PM Subject: Function for centering text >Hello again =) > >I used the same formula that is used in the autowiz code, but it still >will not work. The autowiz uses a call to fputc(), and that requires as >an argument a FILE stream to write to. I tried using puts(), printf(), >etc, and it still doesn't work(crashes with a seg fault). I am trying to >get it to work as a console program before incorporating it into my MUD >code, but am having no luck. Does anyone know of another way to write >strings to the screen that I havent tried? I realize that once >incorporated, it will have to work with the send_to_char(), but I can >tackle that later. <snip> I won't comment on fputs, local console output or the rest. But.. for doing this in the normal context of a CircleMUD I'll give a shot at it. Seems to me you need to define the following variables and then you write a routine to wrap around send_to_char. 1) Screen width (how wide is their screen.. 40/80/132?) 2) How wide is the line you are sending? Given those two pieces of info, here's an approach using Mailer Code FWIW: #define MIN_USER_SCREEN_WIDTH 40 void send_to_char_centered(char *to_send, struct char_data *ch, shint user_width) { shint spaces=0; shint line_width=0; char buf[MAX_STRING_LENGTH]; if (*to_send) line_width = strlen(to_send); if ( (line_width > user_width) || (user_width <MIN_USER_SCREEN_WIDTH ) || (line_width <1) ) return; /* you can deal with these problems :-) */ spaces = (user_width/2) - (line_width/2); buf[0]='\0'; for(x=0;x<spaces;x++) buf[x] = ' '; buf[spaces]='\0' strcat(buf, to_send); send_to_char(buf,ch); } --Mallory +------------------------------------------------------------+ | 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/15/00 PST