00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #if !defined( __EDIT_COMMAND_CODES )
00013 #define __EDIT_COMMAND_CODES
00014
00019 const
00020 int ufUpdate = 0x01,
00021 ufLine = 0x02,
00022 ufView = 0x04;
00023
00024 const
00025 int smExtend = 0x01,
00026 smDouble = 0x02;
00027
00028 const unsigned
00029 sfSearchFailed = UINT_MAX;
00030
00031 const
00032 int cmFind = 82,
00033 cmReplace = 83,
00034 cmSearchAgain = 84;
00035
00036 const
00037 int cmCharLeft = 500,
00038 cmCharRight = 501,
00039 cmWordLeft = 502,
00040 cmWordRight = 503,
00041 cmLineStart = 504,
00042 cmLineEnd = 505,
00043 cmLineUp = 506,
00044 cmLineDown = 507,
00045 cmPageUp = 508,
00046 cmPageDown = 509,
00047 cmTextStart = 510,
00048 cmTextEnd = 511,
00049 cmNewLine = 512,
00050 cmBackSpace = 513,
00051 cmDelChar = 514,
00052 cmDelWord = 515,
00053 cmDelStart = 516,
00054 cmDelEnd = 517,
00055 cmDelLine = 518,
00056 cmInsMode = 519,
00057 cmStartSelect = 520,
00058 cmHideSelect = 521,
00059 cmIndentMode = 522,
00060 cmUpdateTitle = 523;
00061
00065 const int
00066 edOutOfMemory = 0,
00067
00071 edReadError = 1,
00072
00076 edWriteError = 2,
00077
00081 edCreateError = 3,
00082
00086 edSaveModify = 4,
00087
00091 edSaveUntitled = 5,
00092
00096 edSaveAs = 6,
00097
00101 edFind = 7,
00102
00106 edSearchFailed = 8,
00107
00111 edReplace = 9,
00112
00116 edReplacePrompt = 10;
00117
00122 const int
00123 efCaseSensitive = 0x0001,
00124
00129 efWholeWordsOnly = 0x0002,
00130
00135 efPromptOnReplace = 0x0004,
00136
00141 efReplaceAll = 0x0008,
00142
00147 efDoReplace = 0x0010,
00148
00153 efBackupFiles = 0x0100;
00154
00158 const
00159 int maxLineLength = 256;
00160
00161 #endif // __EDIT_COMMAND_CODES
00162
00178 typedef ushort (*TEditorDialog)( int, ... );
00179
00188 ushort defEditorDialog( int dialog, ... );
00189
00190 #if defined( Uses_TIndicator ) && !defined( __TIndicator )
00191 #define __TIndicator
00192
00193 class TRect;
00194
00203 class TIndicator : public TView
00204 {
00205 public:
00209 TIndicator( const TRect& );
00214 virtual void draw();
00218 virtual TPalette& getPalette() const;
00223 virtual void setState( ushort, Boolean );
00230 void setValue( const TPoint& aLocation, Boolean aModified );
00234 static char dragFrame;
00238 static char normalFrame;
00239 protected:
00243 TPoint location;
00247 Boolean modified;
00248 private:
00249 virtual const char *streamableName() const
00250 { return name; }
00251 protected:
00255 TIndicator( StreamableInit );
00256 public:
00260 static const char * const name;
00264 static TStreamable *build();
00265 };
00266
00270 inline ipstream& operator >> ( ipstream& is, TIndicator& cl )
00271 { return is >> (TStreamable&)cl; }
00275 inline ipstream& operator >> ( ipstream& is, TIndicator*& cl )
00276 { return is >> (void *&)cl; }
00277
00281 inline opstream& operator << ( opstream& os, TIndicator& cl )
00282 { return os << (TStreamable&)cl; }
00286 inline opstream& operator << ( opstream& os, TIndicator* cl )
00287 { return os << (TStreamable *)cl; }
00288
00289 #endif // Uses_TIndicator
00290
00291
00292 #if defined( Uses_TEditor ) && !defined( __TEditor )
00293 #define __TEditor
00294
00295 class TRect;
00296 class TScrollBar;
00297 class TIndicator;
00298 class TEvent;
00299
00308 class TEditor : public TView
00309 {
00310 public:
00347 TEditor( const TRect& bounds, TScrollBar *aHScrollBar,
00348 TScrollBar *aVScrollBar, TIndicator *aIndicator, uint aBufSize );
00354 virtual ~TEditor();
00361 virtual void shutDown();
00365 char bufChar( uint p );
00370 uint bufPtr( uint p );
00378 virtual void changeBounds( const TRect& bounds );
00385 virtual void convertEvent( TEvent& event );
00390 Boolean cursorVisible();
00395 void deleteSelect();
00399 virtual void doneBuffer();
00403 virtual void draw();
00408 virtual TPalette& getPalette() const;
00417 virtual void handleEvent( TEvent& event );
00422 virtual void initBuffer();
00436 Boolean insertBuffer( char *p, uint offset, uint length,
00437 Boolean allowUndo, Boolean selectText );
00460 virtual Boolean insertFrom( TEditor *editor );
00467 Boolean insertText( const void *text, uint length, Boolean selectText );
00471 void scrollTo( int x, int y );
00487 Boolean search( const char *findStr, ushort opts );
00495 virtual Boolean setBufSize( uint newSize );
00505 void setCmdState( ushort command, Boolean enable );
00514 void setSelect( uint newStart, uint newEnd, Boolean curStart );
00524 virtual void setState( ushort aState, Boolean enable );
00530 void trackCursor( Boolean center );
00534 void undo();
00539 virtual void updateCommands();
00545 virtual Boolean valid( ushort command );
00552 uint charPos( uint p, uint target );
00558 uint charPtr( uint p, uint target );
00568 Boolean clipCopy();
00573 void clipCut();
00580 void clipPaste();
00586 void deleteRange( uint startPtr, uint endPtr, Boolean delSelect );
00599 void doUpdate();
00620 void doSearchReplace();
00625 void drawLines( int y, uint count, uint linePtr );
00630 void formatLine(void *buff, uint linePtr, int x, ushort color);
00660 void find();
00665 uint getMousePtr( TPoint m );
00671 Boolean hasSelection();
00678 void hideSelect();
00683 Boolean isClipboard();
00688 uint lineEnd( uint p );
00693 uint lineMove( uint p, int count );
00698 uint lineStart( uint p );
00702 void lock();
00708 void newLine();
00713 uint nextChar( uint p );
00718 uint nextLine( uint p );
00723 uint nextWord( uint p );
00728 uint prevChar( uint p );
00733 uint prevLine( uint p );
00738 uint prevWord( uint p );
00778 void replace();
00793 void setBufLen( uint length );
00799 void setCurPtr( uint p, uchar selectMode );
00804 void startSelect();
00809 void toggleInsMode();
00815 void unlock();
00820 void update( uchar aFlags );
00826 void checkScrollBar( const TEvent& event, TScrollBar *p, int& d );
00831 TScrollBar *hScrollBar;
00835 TScrollBar *vScrollBar;
00839 TIndicator *indicator;
00843 char *buffer;
00847 uint bufSize;
00852 uint bufLen;
00857 uint gapLen;
00861 uint selStart;
00865 uint selEnd;
00869 uint curPtr;
00873 TPoint curPos;
00877 TPoint delta;
00882 TPoint limit;
00887 int drawLine;
00892 uint drawPtr;
00897 uint delCount;
00902 uint insCount;
00906 Boolean isValid;
00910 Boolean canUndo;
00914 Boolean modified;
00919 Boolean selecting;
00923 Boolean overwrite;
00927 Boolean autoIndent;
00953 static TEditorDialog editorDialog;
00970 static ushort editorFlags;
00974 static char findStr[maxFindStrLen];
00978 static char replaceStr[maxReplaceStrLen];
00986 static TEditor * clipboard;
00992 uchar lockCount;
00998 uchar updateFlags;
01004 int keyState;
01005 private:
01006 virtual const char *streamableName() const
01007 { return name; }
01008 protected:
01016 TEditor( StreamableInit );
01020 virtual void write( opstream& os );
01024 virtual void *read( ipstream& is );
01025 public:
01029 static const char * const name;
01033 static TStreamable *build();
01034 };
01035
01039 inline ipstream& operator >> ( ipstream& is, TEditor& cl )
01040 { return is >> (TStreamable&)cl; }
01044 inline ipstream& operator >> ( ipstream& is, TEditor*& cl )
01045 { return is >> (void *&)cl; }
01046
01050 inline opstream& operator << ( opstream& os, TEditor& cl )
01051 { return os << (TStreamable&)cl; }
01055 inline opstream& operator << ( opstream& os, TEditor* cl )
01056 { return os << (TStreamable *)cl; }
01057
01058 #endif // Uses_TEditor
01059
01060 #if defined( Uses_TMemo ) && !defined( __TMemo )
01061 #define __TMemo
01062
01063 class TEvent;
01064
01069 struct TMemoData
01070 {
01074 ushort length;
01078 char buffer[1];
01079 };
01080
01087 class TMemo : public TEditor
01088 {
01089 public:
01094 TMemo( const TRect& bounds, TScrollBar *aHScrollBar,
01095 TScrollBar *aVScrollBar, TIndicator *aIndicator, uint aBufSize );
01096 virtual void getData( void *rec );
01097 virtual void setData( void *rec );
01103 virtual ushort dataSize();
01107 virtual TPalette& getPalette() const;
01113 virtual void handleEvent( TEvent& );
01114 private:
01115 virtual const char *streamableName() const
01116 { return name; }
01117 protected:
01125 TMemo( StreamableInit );
01129 virtual void write( opstream& );
01133 virtual void *read( ipstream& );
01134 public:
01138 static const char * const name;
01142 static TStreamable *build();
01143 };
01144
01148 inline ipstream& operator >> ( ipstream& is, TMemo& cl )
01149 { return is >> (TStreamable&)cl; }
01153 inline ipstream& operator >> ( ipstream& is, TMemo*& cl )
01154 { return is >> (void *&)cl; }
01155
01159 inline opstream& operator << ( opstream& os, TMemo& cl )
01160 { return os << (TStreamable&)cl; }
01164 inline opstream& operator << ( opstream& os, TMemo* cl )
01165 { return os << (TStreamable *)cl; }
01166
01167 #endif // Uses_TMemo
01168
01169
01170 #if defined( Uses_TFileEditor ) && !defined( __TFileEditor )
01171 #define __TFileEditor
01172
01173 #include <limits.h>
01174
01175 class TRect;
01176 class TScrollBar;
01177 class TIndicator;
01178 class TEvent;
01179
01185 class TFileEditor : public TEditor
01186 {
01187 public:
01191 char fileName[PATH_MAX];
01205 TFileEditor( const TRect& bounds,
01206 TScrollBar *aHScrollBar,
01207 TScrollBar *aVScrollBar,
01208 TIndicator *aIndicator,
01209 const char *aFileName
01210 );
01214 virtual void doneBuffer();
01222 virtual void handleEvent( TEvent& );
01226 virtual void initBuffer();
01234 Boolean loadFile();
01243 Boolean save();
01256 Boolean saveAs();
01266 Boolean saveFile();
01273 virtual Boolean setBufSize( uint newSize );
01277 virtual void shutDown();
01283 virtual void updateCommands();
01294 virtual Boolean valid( ushort );
01295 private:
01296 static const char * backupExt;
01297 virtual const char *streamableName() const
01298 { return name; }
01299 protected:
01307 TFileEditor( StreamableInit );
01311 virtual void write( opstream& );
01315 virtual void *read( ipstream& );
01316 public:
01320 static const char * const name;
01324 static TStreamable *build();
01325 };
01326
01330 inline ipstream& operator >> ( ipstream& is, TFileEditor& cl )
01331 { return is >> (TStreamable&)cl; }
01335 inline ipstream& operator >> ( ipstream& is, TFileEditor*& cl )
01336 { return is >> (void *&)cl; }
01337
01341 inline opstream& operator << ( opstream& os, TFileEditor& cl )
01342 { return os << (TStreamable&)cl; }
01346 inline opstream& operator << ( opstream& os, TFileEditor* cl )
01347 { return os << (TStreamable *)cl; }
01348
01349 #endif // Uses_TFileEditor
01350
01351
01352 #if defined( Uses_TEditWindow ) && !defined( __TEditWindow )
01353 #define __TEditWindow
01354
01355 class TFileEditor;
01356
01366 class TEditWindow : public TWindow
01367 {
01368 public:
01378 TEditWindow( const TRect& bounds, const char *fileName, int aNumber );
01383 virtual void close();
01388 virtual const char *getTitle( short );
01394 virtual void handleEvent( TEvent& event );
01398 virtual void sizeLimits( TPoint& min, TPoint& max );
01402 TFileEditor *editor;
01403 private:
01404 static const char * clipboardTitle;
01405 static const char * untitled;
01406 virtual const char *streamableName() const
01407 { return name; }
01408 protected:
01416 TEditWindow( StreamableInit );
01420 virtual void write( opstream& );
01424 virtual void *read( ipstream& );
01425 public:
01429 static const char * const name;
01433 static TStreamable *build();
01434 };
01435
01439 inline ipstream& operator >> ( ipstream& is, TEditWindow& cl )
01440 { return is >> (TStreamable&)cl; }
01444 inline ipstream& operator >> ( ipstream& is, TEditWindow*& cl )
01445 { return is >> (void *&)cl; }
01446
01450 inline opstream& operator << ( opstream& os, TEditWindow& cl )
01451 { return os << (TStreamable&)cl; }
01455 inline opstream& operator << ( opstream& os, TEditWindow* cl )
01456 { return os << (TStreamable *)cl; }
01457
01458 #endif // Uses_TEditWindow
01459
01460
01461 #if defined( Uses_TFindDialogRec ) && !defined( __TFindDialogRec )
01462 #define __TFindDialogRec
01463
01464 #include <string.h>
01465
01474 struct TFindDialogRec
01475 {
01479 TFindDialogRec( const char *str, ushort flgs )
01480 {
01481 strcpy( find, str );
01482 options = flgs;
01483 }
01487 char find[maxFindStrLen];
01491 ushort options;
01492 };
01493
01494 #endif // Uses_TFindDialogRec
01495
01496 #if defined( Uses_TReplaceDialogRec ) && !defined( __TReplaceDialogRec )
01497 #define __TReplaceDialogRec
01498
01499 #include <string.h>
01500
01509 struct TReplaceDialogRec
01510 {
01514 TReplaceDialogRec( const char *str, const char *rep, ushort flgs )
01515 {
01516 strcpy( find, str );
01517 strcpy( replace, rep );
01518 options = flgs;
01519 }
01523 char find[maxFindStrLen];
01527 char replace[maxReplaceStrLen];
01531 ushort options;
01532 };
01533
01534 #endif // Uses_TReplaceDialogRec