/*
* editors.h
*
* Turbo Vision - Version 2.0
*
* Copyright (c) 1994 by Borland International
* All Rights Reserved.
*
* Modified by Sergio Sigala <ssigala@globalnet.it>
*/
#if !defined( __EDIT_COMMAND_CODES )
#define __EDIT_COMMAND_CODES
const
int ufUpdate = 0x01,
ufLine = 0x02,
ufView = 0x04;
const
int smExtend = 0x01,
smDouble = 0x02;
const unsigned
sfSearchFailed = UINT_MAX;
const
int cmFind = 82,
cmReplace = 83,
cmSearchAgain = 84;
const
int cmCharLeft = 500,
cmCharRight = 501,
cmWordLeft = 502,
cmWordRight = 503,
cmLineStart = 504,
cmLineEnd = 505,
cmLineUp = 506,
cmLineDown = 507,
cmPageUp = 508,
cmPageDown = 509,
cmTextStart = 510,
cmTextEnd = 511,
cmNewLine = 512,
cmBackSpace = 513,
cmDelChar = 514,
cmDelWord = 515,
cmDelStart = 516,
cmDelEnd = 517,
cmDelLine = 518,
cmInsMode = 519,
cmStartSelect = 520,
cmHideSelect = 521,
cmIndentMode = 522,
cmUpdateTitle = 523;
const
int edOutOfMemory = 0,
edReadError = 1,
edWriteError = 2,
edCreateError = 3,
edSaveModify = 4,
edSaveUntitled = 5,
edSaveAs = 6,
edFind = 7,
edSearchFailed = 8,
edReplace = 9,
edReplacePrompt = 10;
const
int efCaseSensitive = 0x0001,
efWholeWordsOnly = 0x0002,
efPromptOnReplace = 0x0004,
efReplaceAll = 0x0008,
efDoReplace = 0x0010,
efBackupFiles = 0x0100;
const
int maxLineLength = 256;
#endif // __EDIT_COMMAND_CODES
typedef ushort (*TEditorDialog)( int, ... );
ushort defEditorDialog( int dialog, ... );
#if defined( Uses_TIndicator ) && !defined( __TIndicator )
#define __TIndicator
class TRect;
class TIndicator : public TView
{
public:
TIndicator( const TRect& );
virtual void draw();
virtual TPalette& getPalette() const;
virtual void setState( ushort, Boolean );
void setValue( const TPoint&, Boolean );
static char dragFrame;
static char normalFrame;
protected:
TPoint location;
Boolean modified;
private:
virtual const char *streamableName() const
{ return name; }
protected:
TIndicator( StreamableInit );
public:
static const char * const name;
static TStreamable *build();
};
inline ipstream& operator >> ( ipstream& is, TIndicator& cl )
{ return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TIndicator*& cl )
{ return is >> (void *&)cl; }
inline opstream& operator << ( opstream& os, TIndicator& cl )
{ return os << (TStreamable&)cl; }
inline opstream& operator << ( opstream& os, TIndicator* cl )
{ return os << (TStreamable *)cl; }
#endif // Uses_TIndicator
#if defined( Uses_TEditor ) && !defined( __TEditor )
#define __TEditor
class TRect;
class TScrollBar;
class TIndicator;
class TEvent;
/**
* This class implements a text editor.
* @short A text editor
*/
class TEditor : public TView
{
public:
/**
* Constructor.
*
* `bounds' is the bounding rectangle of the view. `aHScrollBar' is a
* pointer to the horizontal scroll bar. `aVScrollBar' is a pointer to the
* vertical scroll bar. `aIndicator' is a pointer to the indicator view.
* Any of these pointers may be set to 0 if you don't use the associated
* view. `aBufSize' is the buffer initial size; 0 is its common value.
* @see TIndicator
* @see TScrollBar
*/
TEditor( const TRect& bounds, TScrollBar *aHScrollBar,
TScrollBar *aVScrollBar, TIndicator *aIndicator, uint aBufSize );
/**
* Destructor.
*
* Does nothing.
*/
virtual ~TEditor();
/**
* YYY
*/
virtual void shutDown();
/**
* YYY
*/
char bufChar( uint p );
/**
* YYY
*/
uint bufPtr( uint p );
/**
* YYY
*/
virtual void changeBounds( const TRect& bounds );
/**
* YYY
*/
virtual void convertEvent( TEvent& event );
/**
* YYY
*/
Boolean cursorVisible();
/**
* YYY
*/
void deleteSelect();
/**
* YYY
*/
virtual void doneBuffer();
/**
* YYY
*/
virtual void draw();
/**
* YYY
*/
virtual TPalette& getPalette() const;
/**
* YYY
*/
virtual void handleEvent( TEvent& event );
/**
* YYY
*/
virtual void initBuffer();
/**
* YYY
*/
Boolean insertBuffer( char *p, uint offset, uint length,
Boolean allowUndo, Boolean selectText );
/**
* YYY
*/
virtual Boolean insertFrom( TEditor *editor );
/**
* YYY
*/
Boolean insertText( const void *text, uint length, Boolean selectText );
/**
* YYY
*/
void scrollTo( int x, int y );
/*
* YYY
*/
Boolean search( const char *, ushort );
/**
* YYY
*/
virtual Boolean setBufSize( uint );
/**
* YYY
*/
void setCmdState( ushort, Boolean );
/**
* YYY
*/
void setSelect( uint, uint, Boolean);
/**
* YYY
*/
virtual void setState( ushort, Boolean );
/**
* YYY
*/
void trackCursor( Boolean );
/**
* YYY
*/
void undo();
/**
* YYY
*/
virtual void updateCommands();
/**
* YYY
*/
virtual Boolean valid( ushort );
/**
* YYY
*/
uint charPos( uint, uint );
/**
* YYY
*/
uint charPtr( uint, uint );
/**
* YYY
*/
Boolean clipCopy();
/**
* YYY
*/
void clipCut();
/**
* YYY
*/
void clipPaste();
/**
* YYY
*/
void deleteRange( uint, uint, Boolean );
/**
* YYY
*/
void doUpdate();
/**
* YYY
*/
void doSearchReplace();
/**
* YYY
*/
void drawLines( int, uint, uint );
/**
* YYY
*/
void formatLine(void *, uint, int, ushort );
/**
* YYY
*/
void find();
/**
* YYY
*/
uint getMousePtr( TPoint );
/**
* YYY
*/
Boolean hasSelection();
/**
* YYY
*/
void hideSelect();
/**
* YYY
*/
Boolean isClipboard();
/**
* YYY
*/
uint lineEnd( uint );
/**
* YYY
*/
uint lineMove( uint, int );
/**
* YYY
*/
uint lineStart( uint );
/**
* YYY
*/
void lock();
/**
* YYY
*/
void newLine();
/**
* YYY
*/
uint nextChar( uint );
/**
* YYY
*/
uint nextLine( uint );
/**
* YYY
*/
uint nextWord( uint );
/**
* YYY
*/
uint prevChar( uint );
/**
* YYY
*/
uint prevLine( uint );
/**
* YYY
*/
uint prevWord( uint );
/**
* YYY
*/
void replace();
/**
* YYY
*/
void setBufLen( uint );
/**
* YYY
*/
void setCurPtr( uint, uchar );
/**
* YYY
*/
void startSelect();
/**
* YYY
*/
void toggleInsMode();
/**
* YYY
*/
void unlock();
/**
* YYY
*/
void update( uchar );
/**
* YYY
*/
void checkScrollBar( const TEvent&, TScrollBar *, int& );
/**
* YYY
*/
TScrollBar *hScrollBar;
/**
* YYY
*/
TScrollBar *vScrollBar;
/**
* YYY
*/
TIndicator *indicator;
/**
* YYY
*/
char *buffer;
/**
* YYY
*/
uint bufSize;
/**
* YYY
*/
uint bufLen;
/**
* YYY
*/
uint gapLen;
/**
* YYY
*/
uint selStart;
/**
* YYY
*/
uint selEnd;
/**
* YYY
*/
uint curPtr;
/**
* YYY
*/
TPoint curPos;
/**
* YYY
*/
TPoint delta;
/**
* YYY
*/
TPoint limit;
/**
* YYY
*/
int drawLine;
/**
* YYY
*/
uint drawPtr;
/**
* YYY
*/
uint delCount;
/**
* YYY
*/
uint insCount;
/**
* YYY
*/
Boolean isValid;
/**
* YYY
*/
Boolean canUndo;
/**
* YYY
*/
Boolean modified;
/**
* YYY
*/
Boolean selecting;
/**
* YYY
*/
Boolean overwrite;
/**
* YYY
*/
Boolean autoIndent;
/**
* YYY
*/
static TEditorDialog editorDialog;
/**
* YYY
*/
static ushort editorFlags;
static char findStr[maxFindStrLen];
static char replaceStr[maxReplaceStrLen];
/**
* YYY
*/
static TEditor * clipboard;
/**
* YYY
*/
uchar lockCount;
/**
* YYY
*/
uchar updateFlags;
/**
* YYY
*/
int keyState;
private:
virtual const char *streamableName() const
{ return name; }
protected:
/**
* YYY
*/
TEditor( StreamableInit );
/**
* YYY
*/
virtual void write( opstream& os );
/**
* YYY
*/
virtual void *read( ipstream& is );
public:
static const char * const name;
/**
* YYY
*/
static TStreamable *build();
};
inline ipstream& operator >> ( ipstream& is, TEditor& cl )
{ return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TEditor*& cl )
{ return is >> (void *&)cl; }
inline opstream& operator << ( opstream& os, TEditor& cl )
{ return os << (TStreamable&)cl; }
inline opstream& operator << ( opstream& os, TEditor* cl )
{ return os << (TStreamable *)cl; }
#endif // Uses_TEditor
#if defined( Uses_TMemo ) && !defined( __TMemo )
#define __TMemo
class TEvent;
struct TMemoData
{
ushort length;
char buffer[1];
};
class TMemo : public TEditor
{
public:
TMemo( const TRect&, TScrollBar *, TScrollBar *, TIndicator *, ushort );
virtual void getData( void *rec );
virtual void setData( void *rec );
virtual ushort dataSize();
virtual TPalette& getPalette() const;
virtual void handleEvent( TEvent& );
private:
virtual const char *streamableName() const
{ return name; }
protected:
TMemo( StreamableInit );
virtual void write( opstream& );
virtual void *read( ipstream& );
public:
static const char * const name;
static TStreamable *build();
};
inline ipstream& operator >> ( ipstream& is, TMemo& cl )
{ return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TMemo*& cl )
{ return is >> (void *&)cl; }
inline opstream& operator << ( opstream& os, TMemo& cl )
{ return os << (TStreamable&)cl; }
inline opstream& operator << ( opstream& os, TMemo* cl )
{ return os << (TStreamable *)cl; }
#endif // Uses_TMemo
#if defined( Uses_TFileEditor ) && !defined( __TFileEditor )
#define __TFileEditor
#include <limits.h>
class TRect;
class TScrollBar;
class TIndicator;
class TEvent;
class TFileEditor : public TEditor
{
public:
char fileName[PATH_MAX];
TFileEditor( const TRect&,
TScrollBar *,
TScrollBar *,
TIndicator *,
const char *
);
virtual void doneBuffer();
virtual void handleEvent( TEvent& );
virtual void initBuffer();
Boolean loadFile();
Boolean save();
Boolean saveAs();
Boolean saveFile();
virtual Boolean setBufSize( uint );
virtual void shutDown();
virtual void updateCommands();
virtual Boolean valid( ushort );
private:
static const char * backupExt;
virtual const char *streamableName() const
{ return name; }
protected:
TFileEditor( StreamableInit );
virtual void write( opstream& );
virtual void *read( ipstream& );
public:
static const char * const name;
static TStreamable *build();
};
inline ipstream& operator >> ( ipstream& is, TFileEditor& cl )
{ return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TFileEditor*& cl )
{ return is >> (void *&)cl; }
inline opstream& operator << ( opstream& os, TFileEditor& cl )
{ return os << (TStreamable&)cl; }
inline opstream& operator << ( opstream& os, TFileEditor* cl )
{ return os << (TStreamable *)cl; }
#endif // Uses_TFileEditor
#if defined( Uses_TEditWindow ) && !defined( __TEditWindow )
#define __TEditWindow
class TFileEditor;
class TEditWindow : public TWindow
{
public:
TEditWindow( const TRect&, const char *, int );
virtual void close();
virtual const char *getTitle( short );
virtual void handleEvent( TEvent& );
virtual void sizeLimits( TPoint& min, TPoint& max );
TFileEditor *editor;
private:
static const char * clipboardTitle;
static const char * untitled;
virtual const char *streamableName() const
{ return name; }
protected:
TEditWindow( StreamableInit );
virtual void write( opstream& );
virtual void *read( ipstream& );
public:
static const char * const name;
static TStreamable *build();
};
inline ipstream& operator >> ( ipstream& is, TEditWindow& cl )
{ return is >> (TStreamable&)cl; }
inline ipstream& operator >> ( ipstream& is, TEditWindow*& cl )
{ return is >> (void *&)cl; }
inline opstream& operator << ( opstream& os, TEditWindow& cl )
{ return os << (TStreamable&)cl; }
inline opstream& operator << ( opstream& os, TEditWindow* cl )
{ return os << (TStreamable *)cl; }
#endif // Uses_TEditWindow
#if defined( Uses_TFindDialogRec ) && !defined( __TFindDialogRec )
#define __TFindDialogRec
#include <string.h>
struct TFindDialogRec
{
TFindDialogRec( const char *str, ushort flgs )
{
strcpy( find, str );
options = flgs;
}
char find[maxFindStrLen];
ushort options;
};
#endif // Uses_TFindDialogRec
#if defined( Uses_TReplaceDialogRec ) && !defined( __TReplaceDialogRec )
#define __TReplaceDialogRec
#include <string.h>
struct TReplaceDialogRec
{
TReplaceDialogRec( const char *str, const char *rep, ushort flgs )
{
strcpy( find, str );
strcpy( replace, rep );
options = flgs;
}
char find[maxFindStrLen];
char replace[maxReplaceStrLen];
ushort options;
};
#endif // Uses_TReplaceDialogRec
Documentation generated by sergio@athena.milk.it on Wed Feb 10 22:11:47 CET 1999