edit.h
mud++/src/edit.h · 3.4 KB
From the archive mud++0.1.tar.gz
Download the archive « Back to the archive contents
/*
....[@@@..[@@@..............[@.................. MUD++ is a written from
....[@..[@..[@..[@..[@..[@@@@@....[@......[@.... scratch multi-user swords and
....[@..[@..[@..[@..[@..[@..[@..[@@@@@..[@@@@@.. sorcery game written in C++.
....[@......[@..[@..[@..[@..[@....[@......[@.... This server is an ongoing
....[@......[@..[@@@@@..[@@@@@.................. development project. All
................................................ contributions are welcome.
....Copyright(C).1995.Melvin.Smith.............. Enjoy.
------------------------------------------------------------------------------
Melvin Smith (aka Fusion) msmith@falcon.mercer.peachnet.edu
MUD++ development mailing list mudpp-list@spice.com
------------------------------------------------------------------------------
edit.h
*/
#ifndef _EDIT_H
#define _EDIT_H
#include "string.h"
#include "llist.h"
#include "index.h"
#include "indexable.h"
#include "server.h"
#include "room.h"
#include "bit.h"
#include "pc.h"
class NPC;
class Area;
class Room;
class Object;
class Editor
{
protected:
// Since objects/npcs have no index, need an index while
// editing, before inserting into a IndexList
PC *pc;
Index index;
int state;
int state_last;
public:
Editor()
: pc(0), state(0), state_last(0)
{
}
Editor( PC * x )
: pc(x), state(0), state_last(0)
{
}
Editor( PC * x, const Index & y )
: pc(x), index(y), state(0), state_last(0)
{
}
virtual void command( String & ) = 0;
const Index & getIndex() { return index; }
void setIndex( const Index & x ) { index = x; }
};
class RoomEditor : public Editor
{
protected:
Room *room;
public:
RoomEditor()
: room(0)
{
}
RoomEditor( PC * x, Room * y )
: Editor(x), room(y)
{
}
virtual void command( String & );
};
class NPCEditor : public Editor
{
protected:
NPC *npc;
public:
NPCEditor()
: npc(0)
{
}
NPCEditor( PC * x, NPC * y )
: Editor(x), npc(y)
{
}
virtual void command( String & );
};
class ObjectEditor : public Editor
{
protected:
Object *obj;
public:
ObjectEditor()
: obj(0)
{
}
ObjectEditor( PC * x, Object * y )
: Editor(x), obj(y)
{
}
virtual void command( String & );
};
class AreaEditor : public Editor
{
protected:
Area *area;
public:
AreaEditor()
: area(0)
{
}
AreaEditor( PC * x, Area * y )
: Editor(x), area(y)
{
}
virtual void command( String & );
};
#define MAX_LINES 256
#define EDIT_APPEND 1
class TextEditor : public Editor
{
protected:
int lines;
int current;
int clipped;
String output;
String text[ MAX_LINES + 1 ];
String clipboard[32];
public:
TextEditor()
: lines(0), current(0), clipped(0)
{
}
TextEditor( String str )
: lines(0), current(0), clipped(0)
{
for( int i = 1; i < MAX_LINES; i++ )
{
text[ i - 1 ] = str.getLine( i );
if( !text[ i - 1 ] )
break;
lines++;
}
}
TextEditor( const char * )
: lines(0), current(0), clipped(0)
{
}
virtual void command( String & );
const char *chars();
const String & asStr();
const String & operator [] ( int i );
const String & format();
void clr();
void clrLine( int );
void cutLine( int );
void insertLine( const String &, int );
void insertLine( const char *, int );
void replaceLine( const String &, int );
void replaceLine( const char *, int );
void cutLines( int, int );
void pasteLines( int );
void append( const char * );
void append( const String & );
};
#endif