skylib_fluffos_v3/
skylib_fluffos_v3/bin/
skylib_fluffos_v3/bin/db/
skylib_fluffos_v3/fluffos-2.9-ds2.04/
skylib_fluffos_v3/fluffos-2.9-ds2.04/ChangeLog.old/
skylib_fluffos_v3/fluffos-2.9-ds2.04/Win32/
skylib_fluffos_v3/fluffos-2.9-ds2.04/compat/
skylib_fluffos_v3/fluffos-2.9-ds2.04/compat/simuls/
skylib_fluffos_v3/fluffos-2.9-ds2.04/include/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/clone/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/command/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/data/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/etc/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/include/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/inherit/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/inherit/master/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/log/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/single/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/single/tests/compiler/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/single/tests/efuns/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/single/tests/operators/
skylib_fluffos_v3/fluffos-2.9-ds2.04/testsuite/u/
skylib_fluffos_v3/fluffos-2.9-ds2.04/tmp/
skylib_fluffos_v3/fluffos-2.9-ds2.04/windows/
skylib_fluffos_v3/mudlib/
skylib_fluffos_v3/mudlib/cmds/
skylib_fluffos_v3/mudlib/cmds/admin/
skylib_fluffos_v3/mudlib/cmds/guild-race/
skylib_fluffos_v3/mudlib/cmds/living/broken/
skylib_fluffos_v3/mudlib/cmds/player/group_cmds/
skylib_fluffos_v3/mudlib/cmds/playtester/
skylib_fluffos_v3/mudlib/d/admin/
skylib_fluffos_v3/mudlib/d/admin/room/
skylib_fluffos_v3/mudlib/d/admin/room/we_care/
skylib_fluffos_v3/mudlib/d/admin/save/
skylib_fluffos_v3/mudlib/d/admin/text/
skylib_fluffos_v3/mudlib/d/learning/TinyTown/buildings/
skylib_fluffos_v3/mudlib/d/learning/TinyTown/map/
skylib_fluffos_v3/mudlib/d/learning/TinyTown/roads/
skylib_fluffos_v3/mudlib/d/learning/chars/
skylib_fluffos_v3/mudlib/d/learning/functions/
skylib_fluffos_v3/mudlib/d/learning/handlers/
skylib_fluffos_v3/mudlib/d/learning/help_topics/
skylib_fluffos_v3/mudlib/d/learning/help_topics/npcs/
skylib_fluffos_v3/mudlib/d/learning/help_topics/objects/
skylib_fluffos_v3/mudlib/d/learning/help_topics/rcs_demo/
skylib_fluffos_v3/mudlib/d/learning/help_topics/rcs_demo/RCS/
skylib_fluffos_v3/mudlib/d/learning/help_topics/rooms/
skylib_fluffos_v3/mudlib/d/learning/help_topics/rooms/crowd/
skylib_fluffos_v3/mudlib/d/learning/help_topics/rooms/situations/
skylib_fluffos_v3/mudlib/d/learning/save/
skylib_fluffos_v3/mudlib/d/learning/school/
skylib_fluffos_v3/mudlib/d/learning/school/add_sc/
skylib_fluffos_v3/mudlib/d/learning/school/characters/
skylib_fluffos_v3/mudlib/d/learning/school/general/
skylib_fluffos_v3/mudlib/d/learning/school/getting-started/
skylib_fluffos_v3/mudlib/d/learning/school/getting-started/basic_commands/
skylib_fluffos_v3/mudlib/d/learning/school/getting-started/edtutor/
skylib_fluffos_v3/mudlib/d/learning/school/getting-started/unix_tutor/
skylib_fluffos_v3/mudlib/d/learning/school/items/
skylib_fluffos_v3/mudlib/d/learning/school/npc_school/
skylib_fluffos_v3/mudlib/d/learning/school/room_school/
skylib_fluffos_v3/mudlib/d/learning/school/room_school/room_basic/
skylib_fluffos_v3/mudlib/d/learning/school/room_school/situations/
skylib_fluffos_v3/mudlib/d/learning/school/room_school/terrain_tutor/
skylib_fluffos_v3/mudlib/d/learning/text/
skylib_fluffos_v3/mudlib/d/liaison/
skylib_fluffos_v3/mudlib/d/mudlib/
skylib_fluffos_v3/mudlib/d/mudlib/changes/
skylib_fluffos_v3/mudlib/d/playtesters/
skylib_fluffos_v3/mudlib/d/playtesters/effects/
skylib_fluffos_v3/mudlib/d/playtesters/handlers/
skylib_fluffos_v3/mudlib/d/playtesters/items/
skylib_fluffos_v3/mudlib/d/sage/
skylib_fluffos_v3/mudlib/doc/
skylib_fluffos_v3/mudlib/doc/creator/
skylib_fluffos_v3/mudlib/doc/driver/
skylib_fluffos_v3/mudlib/doc/driver/efuns/arrays/
skylib_fluffos_v3/mudlib/doc/driver/efuns/buffers/
skylib_fluffos_v3/mudlib/doc/driver/efuns/calls/
skylib_fluffos_v3/mudlib/doc/driver/efuns/compile/
skylib_fluffos_v3/mudlib/doc/driver/efuns/filesystem/
skylib_fluffos_v3/mudlib/doc/driver/efuns/floats/
skylib_fluffos_v3/mudlib/doc/driver/efuns/functions/
skylib_fluffos_v3/mudlib/doc/driver/efuns/general/
skylib_fluffos_v3/mudlib/doc/driver/efuns/mappings/
skylib_fluffos_v3/mudlib/doc/driver/efuns/mixed/
skylib_fluffos_v3/mudlib/doc/driver/efuns/mudlib/
skylib_fluffos_v3/mudlib/doc/driver/efuns/numbers/
skylib_fluffos_v3/mudlib/doc/driver/efuns/parsing/
skylib_fluffos_v3/mudlib/doc/login/
skylib_fluffos_v3/mudlib/doc/lpc/basic_manual/
skylib_fluffos_v3/mudlib/doc/lpc/intermediate/
skylib_fluffos_v3/mudlib/doc/new/add_command/
skylib_fluffos_v3/mudlib/doc/new/events/
skylib_fluffos_v3/mudlib/doc/new/handlers/
skylib_fluffos_v3/mudlib/doc/new/living/race/
skylib_fluffos_v3/mudlib/doc/new/living/spells/
skylib_fluffos_v3/mudlib/doc/new/object/
skylib_fluffos_v3/mudlib/doc/new/player/
skylib_fluffos_v3/mudlib/doc/new/room/guild/
skylib_fluffos_v3/mudlib/doc/new/room/outside/
skylib_fluffos_v3/mudlib/doc/new/room/storeroom/
skylib_fluffos_v3/mudlib/doc/object/
skylib_fluffos_v3/mudlib/doc/playtesters/
skylib_fluffos_v3/mudlib/doc/policy/
skylib_fluffos_v3/mudlib/doc/weapons/
skylib_fluffos_v3/mudlib/global/
skylib_fluffos_v3/mudlib/global/creator/
skylib_fluffos_v3/mudlib/handlers/
skylib_fluffos_v3/mudlib/include/casino/
skylib_fluffos_v3/mudlib/include/cmds/
skylib_fluffos_v3/mudlib/include/effects/
skylib_fluffos_v3/mudlib/include/npc/
skylib_fluffos_v3/mudlib/include/room/
skylib_fluffos_v3/mudlib/include/shops/
skylib_fluffos_v3/mudlib/net/daemon/
skylib_fluffos_v3/mudlib/net/daemon/chars/
skylib_fluffos_v3/mudlib/net/inherit/
skylib_fluffos_v3/mudlib/net/obj/
skylib_fluffos_v3/mudlib/net/obj/BACKUPS/
skylib_fluffos_v3/mudlib/obj/amulets/
skylib_fluffos_v3/mudlib/obj/armours/plate/
skylib_fluffos_v3/mudlib/obj/b_day/
skylib_fluffos_v3/mudlib/obj/clothes/transport/horse/
skylib_fluffos_v3/mudlib/obj/faith/symbols/
skylib_fluffos_v3/mudlib/obj/fungi/
skylib_fluffos_v3/mudlib/obj/gatherables/
skylib_fluffos_v3/mudlib/obj/instruments/
skylib_fluffos_v3/mudlib/obj/media/
skylib_fluffos_v3/mudlib/obj/misc/player_shop/
skylib_fluffos_v3/mudlib/obj/monster/godmother/
skylib_fluffos_v3/mudlib/obj/monster/transport/
skylib_fluffos_v3/mudlib/obj/rings/
skylib_fluffos_v3/mudlib/obj/scabbards/
skylib_fluffos_v3/mudlib/obj/spells/
skylib_fluffos_v3/mudlib/obj/stationery/
skylib_fluffos_v3/mudlib/obj/stationery/envelopes/
skylib_fluffos_v3/mudlib/obj/toys/
skylib_fluffos_v3/mudlib/obj/vessels/
skylib_fluffos_v3/mudlib/obj/weapons/axes/
skylib_fluffos_v3/mudlib/obj/weapons/chains/
skylib_fluffos_v3/mudlib/obj/weapons/maces/BACKUPS/
skylib_fluffos_v3/mudlib/save/autodoc/
skylib_fluffos_v3/mudlib/save/book_handler/
skylib_fluffos_v3/mudlib/save/books/history/calarien/
skylib_fluffos_v3/mudlib/save/mail/
skylib_fluffos_v3/mudlib/save/new_soul/data/
skylib_fluffos_v3/mudlib/save/parcels/
skylib_fluffos_v3/mudlib/save/playerinfo/
skylib_fluffos_v3/mudlib/save/players/d/
skylib_fluffos_v3/mudlib/save/players/s/
skylib_fluffos_v3/mudlib/save/random_names/
skylib_fluffos_v3/mudlib/save/random_names/data/
skylib_fluffos_v3/mudlib/save/terrains/
skylib_fluffos_v3/mudlib/save/terrains/tutorial_desert/
skylib_fluffos_v3/mudlib/save/terrains/tutorial_grassy_field/
skylib_fluffos_v3/mudlib/save/terrains/tutorial_mountain/
skylib_fluffos_v3/mudlib/save/todo_lists/
skylib_fluffos_v3/mudlib/secure/
skylib_fluffos_v3/mudlib/secure/cmds/admin/
skylib_fluffos_v3/mudlib/secure/cmds/lord/
skylib_fluffos_v3/mudlib/secure/config/
skylib_fluffos_v3/mudlib/secure/handlers/autodoc/
skylib_fluffos_v3/mudlib/secure/handlers/intermud/
skylib_fluffos_v3/mudlib/secure/include/global/
skylib_fluffos_v3/mudlib/secure/save/
skylib_fluffos_v3/mudlib/secure/save/handlers/
skylib_fluffos_v3/mudlib/secure/std/
skylib_fluffos_v3/mudlib/secure/std/classes/
skylib_fluffos_v3/mudlib/secure/std/modules/
skylib_fluffos_v3/mudlib/std/creator/
skylib_fluffos_v3/mudlib/std/dom/
skylib_fluffos_v3/mudlib/std/effects/
skylib_fluffos_v3/mudlib/std/effects/external/
skylib_fluffos_v3/mudlib/std/effects/fighting/
skylib_fluffos_v3/mudlib/std/effects/magic/
skylib_fluffos_v3/mudlib/std/effects/magic/BACKUPS/
skylib_fluffos_v3/mudlib/std/effects/other/BACKUPS/
skylib_fluffos_v3/mudlib/std/effects/priest/
skylib_fluffos_v3/mudlib/std/effects/room/
skylib_fluffos_v3/mudlib/std/environ/
skylib_fluffos_v3/mudlib/std/guilds/
skylib_fluffos_v3/mudlib/std/guilds/old/
skylib_fluffos_v3/mudlib/std/languages/
skylib_fluffos_v3/mudlib/std/liquids/
skylib_fluffos_v3/mudlib/std/npc/
skylib_fluffos_v3/mudlib/std/npc/goals/
skylib_fluffos_v3/mudlib/std/npc/goals/basic/
skylib_fluffos_v3/mudlib/std/npc/goals/misc/
skylib_fluffos_v3/mudlib/std/npc/plans/
skylib_fluffos_v3/mudlib/std/npc/plans/basic/
skylib_fluffos_v3/mudlib/std/npc/types/
skylib_fluffos_v3/mudlib/std/npc/types/helper/
skylib_fluffos_v3/mudlib/std/npcs/
skylib_fluffos_v3/mudlib/std/outsides/
skylib_fluffos_v3/mudlib/std/races/shadows/
skylib_fluffos_v3/mudlib/std/room/basic/BACKUPS/
skylib_fluffos_v3/mudlib/std/room/basic/topography/
skylib_fluffos_v3/mudlib/std/room/controller/
skylib_fluffos_v3/mudlib/std/room/inherit/topography/
skylib_fluffos_v3/mudlib/std/room/topography/area/
skylib_fluffos_v3/mudlib/std/room/topography/iroom/
skylib_fluffos_v3/mudlib/std/room/topography/milestone/
skylib_fluffos_v3/mudlib/std/shadows/curses/
skylib_fluffos_v3/mudlib/std/shadows/disease/
skylib_fluffos_v3/mudlib/std/shadows/fighting/
skylib_fluffos_v3/mudlib/std/shadows/healing/
skylib_fluffos_v3/mudlib/std/shadows/magic/
skylib_fluffos_v3/mudlib/std/shadows/poison/
skylib_fluffos_v3/mudlib/std/shadows/room/
skylib_fluffos_v3/mudlib/std/shops/controllers/
skylib_fluffos_v3/mudlib/std/shops/objs/
skylib_fluffos_v3/mudlib/std/shops/player_shop/
skylib_fluffos_v3/mudlib/std/socket/
skylib_fluffos_v3/mudlib/std/soul/d/
skylib_fluffos_v3/mudlib/std/soul/e/
skylib_fluffos_v3/mudlib/std/soul/i/
skylib_fluffos_v3/mudlib/std/soul/j/
skylib_fluffos_v3/mudlib/std/soul/k/
skylib_fluffos_v3/mudlib/std/soul/l/
skylib_fluffos_v3/mudlib/std/soul/n/
skylib_fluffos_v3/mudlib/std/soul/o/
skylib_fluffos_v3/mudlib/std/soul/q/
skylib_fluffos_v3/mudlib/std/soul/r/
skylib_fluffos_v3/mudlib/std/soul/u/
skylib_fluffos_v3/mudlib/std/soul/v/
skylib_fluffos_v3/mudlib/std/soul/y/
skylib_fluffos_v3/mudlib/std/soul/z/
skylib_fluffos_v3/mudlib/std/stationery/
skylib_fluffos_v3/mudlib/w/
skylib_fluffos_v3/mudlib/w/default/
skylib_fluffos_v3/mudlib/w/default/armour/
skylib_fluffos_v3/mudlib/w/default/clothes/
skylib_fluffos_v3/mudlib/w/default/item/
skylib_fluffos_v3/mudlib/w/default/npc/
skylib_fluffos_v3/mudlib/w/default/room/
skylib_fluffos_v3/mudlib/w/default/weapon/
skylib_fluffos_v3/mudlib/www/
skylib_fluffos_v3/mudlib/www/java/
skylib_fluffos_v3/mudlib/www/secure/
skylib_fluffos_v3/mudlib/www/secure/lpc/advanced/
skylib_fluffos_v3/mudlib/www/secure/lpc/intermediate/
skylib_fluffos_v3/win32/
/**
 * This allows a piece of text to be placed into the players own
 * line editor (which ever one they wish to use).
 * <p>
 * Expansion of the editor.  We will now allow the player to use any
 * of three different editors.  One of them is the default (the old
 * one) one of them is ed and the other I am going to write in a
 * few secs....
 * <p>
 * cute line editor thing.  Which even a player could use!
 * @author Pinkfish
 */

#include "ed.h"

private nosave string *_lines;
private nosave mixed _end_func;
private nosave object _ed_ob = 0;
private nosave int _insertion_point;
private string editor;
private nosave string _filename;

private nosave mixed _in_editor;

private void main_bit(string str);
int set_editor(string name);
private void editor_do_quit(string str);
private void editor_loop(string str);
private void editor_insert(string str);
private void editor_delete(string str);
private void editor_modify(string str);
private void editor_check_quit(string str);
private void editor_modify2(string str, int range1, int range2);
private void editor_modify3(string str, int range1, int range2,
                            string modify_string);

protected void create()  {
    editor = "menu";
} /* create() */

/** @ignore yes */
protected void editor_commands()  {
    add_command("editor", "{menu|ed|command}", (: set_editor($4[0]) :) );
} /* edito_commands() */

/**
 * Edit a string.  This will edit the string or file name and then
 * call the end function and end object at the end.  It will pas in
 * the string if the edit is successful, or 0 if it is not.
 * @param str the string to edit
 * @param end_f the function to call
 * @param end_o the object to call it on (defaul: previous_object())
 * @param fname a specific filename to edit
 * @param extra an array of any parameters you need to carry into the end function
 * @return 0 on failure.
 */
varargs int do_edit( string str, mixed end_f, object end_o, string fname,
                     mixed extra )  {
    if( !end_f ) {
        printf("Someone has stuffed up - there is no end function.\n");
        return 0;
    } else {
        _end_func = end_f;
    }

    if( !end_o )
        end_o = PO;

    if( !str )
        str = "";

    if( !strlen(fname) )
        _filename = TMP_FILE;
    else
        _filename = fname;


    if( !functionp(end_f) ) {
        if( extra )
            _end_func = (: call_other( $(end_o), $(end_f), $1, $(extra) ) :);
        else
            _end_func = (: call_other( $(end_o), $(end_f), $1 ) :);
    } else {
        if( extra )
            _end_func = (: evaluate( $(end_f), $1, $(extra) ) :);
        else
            _end_func = (: evaluate( $(end_f), $1 ) :);
    }

    switch( editor ) {
      case "menu":
        _lines = explode( str, "\n") - ({ 0 });
        printf("Enter your text.  Use ** on a line by itself to exit.\n");
        _insertion_point = sizeof(_lines);
        printf("%-2d] ", _insertion_point + 1 );
        _in_editor = 1;
        input_to( (: editor_loop :) );
        return 1;
      case "ed":
        if( strlen(str) && _filename == TMP_FILE )
            write_file( _filename, str );
        _in_editor = 1;
        ed(_filename, "editor_finish_ed", !creatorp(TO) );
        return 1;
      case "command":
        _lines = explode(str, "\n") - ({ 0 });
        printf("Enter your text.  Use ** on a line by itself to exit or "
               "~h for help.\n");
        _insertion_point = sizeof(_lines);
        printf("%-2d] ", _insertion_point + 1 );
        _in_editor = 1;
        input_to( (: editor_loop :) );
        return 1;
    }

} /* do_edit() */

/** @ignore yes */
private void main_bit( string str ) {
    int i;
    string s;

    if( str != "") {
        while( str[0] == ' ')
            str = str[1..];

        switch( str[0] ) {
          case 'i':
          case 'I':
            printf("Insert before line: ");
            input_to( (: editor_insert :) );
            return;
          case 'd':
          case 'D':
            printf("Delete (line no, or n..m ie 1..2): ");
            input_to( (: editor_delete :) );
            return;
          case 'l':
          case 'L':
            if( !sizeof(_lines) ) {
                main_bit("");
            } else {
                s = "";
                for( i = 0; i < sizeof(_lines); i++ )
                    s += sprintf("%3d: %s\n", i + 1, _lines[i] );
                TO->set_finish_func("end_of_edit_more");
                TO->more_string(s);
            }
            return;
          case 'm':
          case 'M':
            printf("Modify which line (line no, or n..m ie 1..2): ");
            input_to( (: editor_modify :) );
            return;
          case 'c':
          case 'C':
            _insertion_point = sizeof(_lines);
            printf("Okay, back into insertion mode.  Use ** on a line "
                   "by itself to exit.\n%-2d] ", _insertion_point + 1 );
            input_to( (: editor_loop :) );
            return;
          case 'e':
          case 'E':
            printf("Entering ed... Use \"q\" to quit, \"x\" to save and "
                   "quit, \"Q\" to quite without saving changes and \"h\" "
                   "for help.\n");
            write_file( _filename, implode(_lines, "\n") );
            ed( _filename, "editor_exit_ed", !creatorp(TO) );
            return;
          case 's':
          case 'S':
            printf("Quitting and saving.\n");
            editor_do_quit( implode(_lines, "\n") );
            return;
          case 'q':
          case 'Q':
            printf("Are you sure you want to quit? (Y/N) ");
            input_to( (: editor_check_quit :) );
            return;
          case 'h':
          case 'H':
            s = read_file(ED_HELP_FILE);
            TO->set_finish_func("end_of_edit_more");
            TO->more_string(s);
            return;
          default:
            printf("I do not understand you.  Try %s for help.\n",
                  ( editor == "command" ? "~h" : "h" ) );
            main_bit("");
            return;
        }
    }
  
    if( editor == "menu") {
        printf( "%i lines - Choose from IDLMCESQ or H for help.", sizeof(_lines) );
        input_to( (: main_bit :) );
    } else {
        printf("%-2d] ", _insertion_point + 1 );
        input_to( (: editor_loop :) );
    }

    return;

} /* main_bit() */

/** @ignore yes */
void end_of_edit_more()  {
    TO->set_finish_func(0);
    main_bit("");
} /* end_of_edit_more() */

/** @ignore yes */
private void editor_delete( string str ) {
    int num1, num2, tmp;

    if( sscanf(str, "%d..%d", num1, num2 ) == 2 )  {
        if( num1 > num2 )  {
            tmp = num1;
            num1 = num2;
            num2 = tmp;
        }
    
        if( num1 < 1 || num2 > sizeof(_lines) + 1 ) {
            printf("Out of bounds.\n");
            main_bit("");
        }
    
        printf("Deleting from line %d to line %d.\n", num1, num2 );
        _lines = delete( _lines, num1 - 1, num2 - num1 + 1 );
        printf("Okay.\n");
        main_bit("");
        return;
    }

    if( sscanf( str, "%d", num1 ) == 1 )  {
        if( num1 < 1 || num1 > sizeof(_lines) )  {
            printf("Line number out of range.\n");
            main_bit("");
            return;
        }
        printf("Deleting line %d.\n", num1 );
        _lines = delete( _lines, num1 - 1, 1 );
        printf("Okay.\n");
        main_bit("");
        return;
    }

    printf("Error: invalid data %s.\n", str );
    main_bit("");
    return;

} /* editor_delete() */

/** @ignore yes */
private void editor_insert( string str ) {
    int num;

    if( sscanf( str, "%d", num ) != 1 )  {
        printf("Error: must be a number.\n");
        main_bit("");
        return;
    }

    if( num < 1 || num > sizeof(_lines) + 1 ) {
        printf("Error: number out of bounds.\n");
        main_bit("");
        return;
    }

    _insertion_point = num - 1;
    printf("Inserting before line %d.  Entering insertion mode.  Use ** on a "
           "line by itself to exit\n%-2d] ", num, num );

    input_to( (: editor_loop :) );
    return;

} /* editor_insert() */

/** @ignore yes */
private void editor_loop( string str ) {
    if( strlen(str) > 1 && str[0] == '~' && editor == "command") {
        main_bit(str[1..]);
        return;
    }
  
    if( str == "**") {
        if( editor == "menu")
            main_bit("");
        else if( sizeof(_lines) )
            editor_do_quit( implode( _lines, "\n") );
        else
            editor_do_quit(0);
        return;
    }
  
    _lines = _lines[0.._insertion_point - 1] + ({ str }) +
             _lines[_insertion_point..];
    ++_insertion_point;
    printf("%-2d] ", _insertion_point + 1 );

    input_to( (: editor_loop :) );
    return;

} /* editor_loop() */

/** @ignore yes */
private void editor_modify( string str ) {
    int num1, num2, tmp;

    if( sscanf( str, "%d..%d", num1, num2 ) == 2 )  {
        if( num1 > num2 ) {
            tmp = num1;
            num1 = num2;
            num2 = tmp;
        }
    
        if( num1 < 1 || num2 > sizeof(_lines) + 1 ) {
            printf("Error: number out of bounds.\n");
            main_bit("");
        }
    
        printf("Modifying from line %d to line %d.\n", num1, num2 );
        printf("Text to change? ");
        input_to( (: editor_modify2 :), 0, num1, num2 );
        return;
    }
  
    if( sscanf(str, "%d", num1 ) == 1 ) {
        if( num1 < 1 || num1 > sizeof(_lines) + 1 ) {
            printf("Error: line number out of range.\n");
            main_bit("");
            return;
        }

        printf("Modifying line %d.\n", num1 );
        printf("Text to change? ");
        input_to( (: editor_modify2 :), 0, num1, num1 );
        return;
    }
  
    printf("Error: invalid data %s.\n", str );
    main_bit("");
    return;

} /* editor_modify() */

/** @ignore yes */
private void editor_modify2( string str, int range1, int range2 ) {
    if( !strlen(str) ) {
        printf("Aborting.\n");
        main_bit("");
        return;
    }
  
    printf("Change to: ");
    input_to( (: editor_modify3 :), 0, range1, range2, str );
    return;

} /* editor_modify2() */

/** @ignore yes */
private void editor_modify3( string str, int range1, int range2,
                             string modify_string ) {
    int i, pos;
    string s1, s2;

    printf("Changing all occurrences of \"%s\" to \"%s\" from line %d to "
           "line %d.\n", modify_string, str, range1, range2 );
  
    for( i = range1 - 1; i < range2 && i < sizeof(_lines); i++ ) {
        pos = strsrch( _lines[i], modify_string );
        if( pos != -1 ) {
            s1 = _lines[i][0..pos-1];
            s1 += str;
            s2 = _lines[i][pos + strlen(modify_string)..];
            
            do {
                pos = strsrch( s2, modify_string );
                if( pos != -1 ) {
                    s1 += s2[0..pos-1];
                    s2 = s2[pos + strlen(modify_string)..];
                }
            } while( pos != -1 );

            _lines[i] = s1 + s2;
            printf("%3d: %s\n", i + 1, _lines[i] );
        }
    }

    printf("Done.\n");
    main_bit("");
    return;

} /* editor_modify3() */

/** @ignore yes */
void editor_exit_ed()  {
    string str;

    str = read_file(_filename);
    
    if( file_size(_filename) >= 0 && !rm(_filename) )
        log_file( LOG_FILE, "ed: couldn't rm %s\n", _filename );

    _lines = explode("#" + str, "\n");
    _lines[0] = _lines[0][1..];

    main_bit("");
    return;

} /* editor_exit_ed() */

/** @ignore yes */
void editor_finish_ed() {
    string str;

    str = read_file(_filename);
    if( file_size(_filename) >= 0 && _filename == TMP_FILE &&
        !rm(_filename) )
        log_file( LOG_FILE, "ed: couldn't rm %s\n", _filename );

    if( !str ) {
        printf("Aborted.\n");
        editor_do_quit(0);
        return;
    }

    if( _filename == TMP_FILE )
        editor_do_quit(str);
    else
        editor_do_quit(0);

    return;

} /* editor_finish_ed() */

/** @ignore yes */
void editor_do_quit( string str ) {
    _lines = ({ });
    _in_editor = 0;
  
    if( _ed_ob )
        destruct(_ed_ob);

    evaluate( _end_func, str );

} /* editor_do_quit() */

/** @ignore yes */
private void editor_check_quit( string str ) {
    if( str != "" && str[0] != 'y' && str[0] != 'Y') {
        printf("Returning to the editor.\n");
        main_bit("");
        return;
    }

    printf("Quitting.\n");
    editor_do_quit(0);
    return;

} /* editor_check_quit() */

/** @ignore yes */
int set_editor( string str ) {
    editor = str;
    printf("Editor set to %s.\n", str );
    return 1;
} /* set_editor() */

/**
 * This method will create the signature to append to whatever needs
 * a signature.
 * @return the players signature
 */
string append_signature() {
    mapping sig;
    string sigstr, *siglines;
    int i, lines;

    sig = TO->query_aliases();

    if( siglines = sig[".signature"] ) {
        sigstr = replace( FINGER_H->make_string(siglines),
                          ({";", "\n", "%^", ""}) ) + "\n";

        for( i = lines = 0; i < sizeof(sigstr) && lines < 4; i++ ) {
            if( sigstr[i] == '\n')
                lines++;
        }

        return "\n--\n" + sigstr[0..i-1] + "%^RESET%^";
    }

    return "";

} /* append_signature() */

/** @ignore yes */
void editor_check_do_quit()  {
    if( _in_editor ) {
        // Force them to save the thingy they are editing.
        printf("Saving what you are editing.\n");
        if( editor != "ed")
            editor_do_quit( implode( _lines, "\n") );
        else
            editor_finish_ed();
    }
} /* editor_check_do_quit() */

/**
 * This method will return the players current editor setting.
 * @return the current editor setting.
 */
string query_editor() { return editor; }

/**
 * This method returns the value of the in editor flag.
 * It will return non-zero if the player is in an editor.
 * @return non-zero in editor, 0 not in an editor
 * @see set_in_editor()
 */
int query_in_editor() { return _in_editor; }

/**
 * This method sets the current in editor flag.
 * @param what the new value of the in editor flag
 * @see query_in_editor()
 */
void set_in_editor( mixed what ) { _in_editor = what; }