/
LIB3/
LIB3/D/ADMIN/
LIB3/D/ADMIN/OBJ/
LIB3/D/ADMIN/ROOM/W/
LIB3/D/HOME/
LIB3/D/HOME/CITY/ARENA/
LIB3/D/HOME/CITY/ITEMS/
LIB3/D/HOME/CITY/POSTOFFI/
LIB3/DOC/
LIB3/GLOBAL/SPECIAL/
LIB3/GLOBAL/VIRTUAL/
LIB3/NET/
LIB3/NET/CONFIG/
LIB3/NET/DAEMON/CHARS/
LIB3/NET/GOPHER/
LIB3/NET/INHERIT/
LIB3/NET/OBJ/
LIB3/NET/SAVE/
LIB3/NET/VIRTUAL/
LIB3/OBJ/B_DAY/
LIB3/OBJ/HANDLERS/TERM_TYP/
LIB3/PLAYERS/B/
LIB3/PLAYERS/N/
LIB3/ROOM/
LIB3/SAVE/
LIB3/SAVE/BOARDS/
LIB3/SAVE/ENVIRON/
LIB3/SAVE/POST/
LIB3/STD/COMMANDS/SHADOWS/
LIB3/STD/CREATOR/
LIB3/STD/DOM/
LIB3/STD/EFFECTS/
LIB3/STD/EFFECTS/HEALING/
LIB3/STD/EFFECTS/OTHER/
LIB3/STD/EFFECTS/POISONS/
LIB3/STD/ENVIRON/
LIB3/STD/GUILDS/
LIB3/STD/LIQUIDS/
LIB3/STD/ROOM/
LIB3/STD/TRIGGER/SHADOW/
LIB3/W/
LIB3/W/BANNOR/
LIB3/W/NEWSTYLE/
static int fsize, topl, botl;
static string last_search = "", *the_bit, finish_func, more_bit, stat_line;
static object finish_ob;

#define ROWS ((int)this_player()->query_rows())
#define COLS (int)this_player()->query_cols()

void    string_display_file()
{
    int     i;

    botl = topl + ROWS;
    for( i = topl; i < botl && i < fsize; i++ )
	write( the_bit[ i ] + "\n" );
}

void    more_string_status_line()
{
    string *frog;
    string  s;
    int     i, j, percentage;

    if( !stat_line )
	stat_line = "$N From $T to $B of $S ($%%) - h for help. ";
    s = "";
    frog = explode( stat_line, "$" );
    for( i = 0; i < sizeof( frog ); i++ )
    {
	if( frog[ i ] == "" )
	{
	    s += "$";
	    i++;
	}
	else
	    switch( frog[ i ][ 0 ] )
	    {
		case 'N':
		    s += more_bit + frog[ i ][ 1..1000 ];
		    break;
		case 'T':
		    s += topl + frog[ i ][ 1..1000 ];
		    break;
		case 'B':
		    if( botl > fsize )
			s += fsize + frog[ i ][ 1..100 ];
		    else
			s += botl + frog[ i ][ 1..100 ];
		    break;
		case '%':
		    {
			percentage = (botl * 100) / fsize;
			if( percentage > 100 )
			    percentage = 100;
			s += percentage + frog[ i ][ 1..100 ];
			break;
		    }
		case 'S':
		    s += fsize + frog[ i ][ 1..1000 ];
		    break;
	    }
    }
    write( s );
    return;
}

void    string_next_page( string str )
{
    int     num, noargs, i, j, k, redraw;
    string  s1, s2, *s3, s4, s5;

    if( !str )
	str = "";

    if( sscanf( str, "%d%s", num, str ) != 2 )
	noargs = 1;
    s1 = extract( str, 1 );
    str = extract( str, 0, 1 );
/* case statements WEEEEEE */
    switch( str )
    {
	case "q":
	    if( finish_func )
		call_other( finish_ob, finish_func );
	    finish_func = 0;
	    return;
	case "":
	case "f":
/* go on a number of pages... */
	    topl += ROWS;
	    redraw = 1;
	    break;
	case "/":
/* sigh */
	    i = topl + 4;
	    if( s1 == "" )
		s1 = last_search;
	    if( !s1 || s1 == "" )
		s1 = "bing!";
	    for( i = topl + 4; i < fsize; i++ )
		if( sscanf( the_bit[ k ], "%s" + s1 + "%s", s4, s5 ) == 2 )
		    if( num-- <= 0 )
			break;
	    if( i == fsize )
		write( "Sorry " + s1 + " not found.\n" );
	    else
		topl = i - 3;
	    redraw = 1;
	    break;
	case "?":
	    if( s1 == "" )
		s1 = last_search;
	    if( !s1 || s1 == "" )
		s1 = "bing!";
	    for( i = topl + 2; i > 0; i-- )
		if( sscanf( the_bit[ k ], "%s" + s1 + "%s", s4, s5 ) == 2 )
		    if( num-- <= 0 )
			break;
	    if( i == fsize )
		write( "Sorry " + s1 + " not found.\n" );
	    else
		topl = i - 3;
	    redraw = 1;
	    break;
	case "b":
	    if( topl > 0 )
	    {
		topl -= ROWS;
		redraw = 1;
		if( topl < 0 )
		    topl = 0;
	    }
	    break;
	case "g":
	    topl = num;
	    if( topl >= fsize )
		topl = fsize - 2;
	    redraw = 1;
	    break;
	case "G":
	    redraw = 1;
	    if( noargs )
		topl = fsize - ROWS;
	    else
		topl = num;
	    if( topl > fsize )
		topl = fsize - 2;
	    break;
    }
    if( redraw )
	string_display_file();
    if( topl < fsize )
    {
	more_string_status_line();
	input_to( "string_next_page" );
    }
    else
	if( finish_func )
	{
	    call_other( finish_ob, finish_func );
	    finish_func = 0;
	}
}

varargs int more_string( mixed str, string bity )
{

    if( bity )
	more_bit = bity;
    else
	more_bit = "--- MORE";
    last_search = "";

    if( !pointerp( str ) )
	the_bit = explode( str, "\n" );
    fsize = sizeof( the_bit );
    if( fsize == 0 )
    {
	notify_fail( "Empty String.\n" );
	return 0;
    }
    topl = 0;
    if( fsize < ROWS )
	botl = fsize;
    else
	botl = ROWS;
    string_display_file();
    if( fsize >= ROWS )
    {
	more_string_status_line();
	input_to( "string_next_page" );
    }
    else
	if( finish_func )
	{
	    call_other( finish_ob, finish_func );
	    finish_func = 0;
	}
    return 1;
}

int     set_finish_func( string str, object ob )
{
    finish_func = str;
    if( !ob )
	finish_ob = previous_object();
    else
	finish_ob = ob;
}