/* * An EntityTextEd is a deriviation of Sted for viewing rsl code. The * EntityTextEdList is a list of entity editors, one of which is current. Each * editor in the list is displayed in its own canvas. The default canvas is * the one at the bottom of the initial browser interface. Each additional * canvas is in its own top-level window. See the users manual for further * details of canvas window management */ #ifndef rtextedIncluded #define rtextedIncluded #include "newstr.h" #include "sted.h" #include "strlist.h" #include "entity.h" #include "paintlabel.h" class EntityTextEdList; class EntityTextEdListElem; class Sted; class RSLBrowser; class EntityTextEd : public Sted { friend class EntityTextEdListElem; public: EntityTextEd::EntityTextEd(int rows, int cols, bool readonly, RSLBrowser* browser); /* * Construct by supplying number of rows and cols. The other sted * consturctor parms are fixed. Also, pass in list of which this editor * is an elem. */ EntityTextEd(int rows, int cols, bool readonly, EntityTextEdList* parent, const char* filename, RSLBrowser* browser); /* * A la above constructor, but open filename initially. */ ~EntityTextEd(); EntityTextEd* ScrollToName(EntityStruct* es); /* * Scroll the editor so that the name of the given entity is highlighted * in the middle of the this's window. If the file of the given entity * is not currently open in this, open it and then do the scrolling. */ EntityTextEd* ScrollToPosition(int line, int col); /* * Scroll the editor so that the given line and column are centered in * the middle of the editor's window. */ private: EntityStruct* es; /* Currently displayed entity. */ EntityTextEdList* parent; /* The list this is in. */ /* NO on next one -- it duplicates member filename that sted already has */ //char* filename; /* The file that's currently open in this ed */ }; class EntityTextEdList : public List { public: EntityTextEdList(); /* * Construct a list; one intial editor will be set with SetFixedEd. */ EntityTextEd* CurEd(); /* * Return the current editor. */ EntityTextEdList* EntityTextEdList::SetFixedEd(EntityTextEd* ed); /* * Set current editor. Cant be done in constructor because EntityTextEd * and EntityTextEdList are mutually referencial. */ EntityTextEdList* Add(char* pathname = 0); /* * Add a new editor containing the contents of the given path. Make the * new editor current. If path == 0, then editor is intially empty. */ EntityTextEdList* Add(EntityTextEd* ed); /* * Add the given new editor to the current list and make it current. */ EntityTextEdList* MakeCurrent(char* pathname); /* * Make the ed containing the given file current if it is not already. * If the file is not currently open in an ed, open it. * * NOT CURRENTLY USED. It would be used if locating an entity meant * moving to an ed window that contains the entity def, rather than what * it presently means. Viz., it presently means opening the file that * conatins the entity def in the *current* ed window, not searching for * a previously open ed window that contains for file, or opening a new * ed window on the file. */ EntityTextEdList* Open(const char* pathname); /* * Fill the current editor with the contents of the given path. */ EntityTextEdList* Del(char* pathname = 0); /* * Delete the editor containing the given path. If path == 0, del the * current editor. */ EntityTextEdList* MakeCur(char* pathname); /* * Make the editor containing the given path contents the current editor. */ EntityTextEdList* MakeCur(EntityTextEd* ed); /* * Make the given editor the current editor. */ EntityTextEdList* ScrollToName(EntityStruct* es); /* * Call ScrollToName on the current editor. */ EntityTextEdList* ScrollToPosition(int line, int col); /* * Call ScrollToPosition on the current editor. */ EntityTextEdList* SearchForw(const char* string); /* * Search for the given string in the current editor. */ EntityTextEdList* SearchBack(const char* string); /* * Ibid. */ EntityTextEdList* GotoLine(int line); /* * Goto the specified line in the current editor. */ EntityTextEdList* NewEditor(char* filename = null, int rows = 24, int cols = 80); /* * Create a new, detached, text ed window and make it current. Its * contents are intially empty. */ EntityTextEdList* ReadonlyOn(); /* * Turn readonly mode on in the current editor. */ EntityTextEdList* ReadonlyOff(); /* * Turn readonly mode off in the current editor. */ Box* InitialLayout(); /* * Initial layout (gee, that's a useful comment). */ EntityTextEdListElem* Find(const char* k); /* * Standard specialization of List::Find. */ int FindPos(const char* k); /* * Standard specialization of List::FindPos. */ EntityTextEdListElem* DelNth(int n); /* * Standard specialization of List::DelNth. */ EntityTextEdListElem* Enum(); /* * Standard specialization of List::Enum. */ private: EntityTextEd* fixedEd; /* Fixed text ed within the browser window */ EntityTextEd* curEd; /* Pointer to the current editor. */ }; class EntityTextEdListElemKey; class EntityTextEdListElem : public ListElem { friend class EntityTextEdList; public: EntityTextEdListElem(EntityTextEd* ed); ListElemKey* Key(); int KeyCompare(ListElemKey* key); EntityTextEd* GetData(); private: EntityTextEd* data; }; class EntityTextEdListElemKey : public ListElemKey {}; #endif