You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

532 lines
12 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /***************************************************************/
  2. /* */
  3. /* this header-file was modified by Robert Hoehne */
  4. /* to use it with DJ's port of gcc */
  5. /* */
  6. /***************************************************************/
  7. /* ------------------------------------------------------------------------*/
  8. /* */
  9. /* EDITORS.H */
  10. /* */
  11. /* Copyright (c) Borland International 1991 */
  12. /* All Rights Reserved. */
  13. /* */
  14. /* defines the classes TIndicator, TEditor, TMemo, TFileEditor, */
  15. /* and TEditWindow */
  16. /* */
  17. /* ------------------------------------------------------------------------*/
  18. #if !defined( __EDIT_COMMAND_CODES )
  19. #define __EDIT_COMMAND_CODES
  20. const int
  21. ufUpdate = 0x01,
  22. ufLine = 0x02,
  23. ufView = 0x04;
  24. const int
  25. smExtend = 0x01,
  26. smDouble = 0x02;
  27. const unsigned
  28. sfSearchFailed = UINT_MAX;
  29. const int
  30. cmSave = 80,
  31. cmSaveAs = 81,
  32. cmFind = 82,
  33. cmReplace = 83,
  34. cmSearchAgain = 84;
  35. const int
  36. cmCharLeft = 500,
  37. cmCharRight = 501,
  38. cmWordLeft = 502,
  39. cmWordRight = 503,
  40. cmLineStart = 504,
  41. cmLineEnd = 505,
  42. cmLineUp = 506,
  43. cmLineDown = 507,
  44. cmPageUp = 508,
  45. cmPageDown = 509,
  46. cmTextStart = 510,
  47. cmTextEnd = 511,
  48. cmNewLine = 512,
  49. cmBackSpace = 513,
  50. cmDelChar = 514,
  51. cmDelWord = 515,
  52. cmDelStart = 516,
  53. cmDelEnd = 517,
  54. cmDelLine = 518,
  55. cmInsMode = 519,
  56. cmStartSelect = 520,
  57. cmHideSelect = 521,
  58. cmIndentMode = 522,
  59. cmUpdateTitle = 523,
  60. cmInsertText = 524;
  61. const int
  62. edOutOfMemory = 0,
  63. edReadError = 1,
  64. edWriteError = 2,
  65. edCreateError = 3,
  66. edSaveModify = 4,
  67. edSaveUntitled = 5,
  68. edSaveAs = 6,
  69. edFind = 7,
  70. edSearchFailed = 8,
  71. edReplace = 9,
  72. edReplacePrompt = 10;
  73. const int
  74. efCaseSensitive = 0x0001,
  75. efWholeWordsOnly = 0x0002,
  76. efPromptOnReplace = 0x0004,
  77. efReplaceAll = 0x0008,
  78. efDoReplace = 0x0010,
  79. efBackupFiles = 0x0100;
  80. const int
  81. maxLineLength = 256;
  82. // SET: Added these old constants here
  83. const unsigned
  84. cmOpen = 100,
  85. cmNew = 101,
  86. cmChangeDrct = 102,
  87. cmDosShell = 103,
  88. cmCalculator = 104,
  89. cmShowClip = 105,
  90. cmMacros = 106;
  91. #endif // __EDIT_COMMAND_CODES
  92. typedef ushort (*TEditorDialog)( int, ... );
  93. ushort defEditorDialog( int dialog, ... );
  94. #if defined( Uses_TIndicator ) && !defined( __TIndicator )
  95. #define __TIndicator
  96. class far TRect;
  97. class TIndicator : public TView
  98. {
  99. public:
  100. TIndicator( const TRect& );
  101. virtual void draw();
  102. virtual TPalette& getPalette() const;
  103. virtual void setState( ushort, Boolean );
  104. void setValue( const TPoint&, Boolean );
  105. protected:
  106. TPoint location;
  107. Boolean modified;
  108. #ifndef NO_STREAM
  109. private:
  110. static const char near dragFrame;
  111. static const char near normalFrame;
  112. virtual const char *streamableName() const
  113. { return name; }
  114. protected:
  115. TIndicator( StreamableInit );
  116. public:
  117. static const char * const near name;
  118. static TStreamable *build();
  119. #endif
  120. };
  121. #ifndef NO_STREAM
  122. inline ipstream& operator >> ( ipstream& is, TIndicator& cl )
  123. { return is >> (TStreamable&)cl; }
  124. inline ipstream& operator >> ( ipstream& is, TIndicator*& cl )
  125. { return is >> (void *&)cl; }
  126. inline opstream& operator << ( opstream& os, TIndicator& cl )
  127. { return os << (TStreamable&)cl; }
  128. inline opstream& operator << ( opstream& os, TIndicator* cl )
  129. { return os << (TStreamable *)cl; }
  130. #endif // NO_STREAM
  131. #endif // Uses_TIndicator
  132. #if defined( Uses_TEditor ) && !defined( __TEditor )
  133. #define __TEditor
  134. class TRect;
  135. class TScrollBar;
  136. class TIndicator;
  137. class TEvent;
  138. class TEditor : public TView
  139. {
  140. public:
  141. TEditor( const TRect&, TScrollBar *, TScrollBar *, TIndicator *, uint32 );
  142. virtual ~TEditor();
  143. virtual void shutDown();
  144. char bufChar( uint32 );
  145. uint32 bufPtr( uint32 );
  146. virtual void changeBounds( const TRect& );
  147. virtual void convertEvent( TEvent& );
  148. Boolean cursorVisible();
  149. void deleteSelect();
  150. virtual void doneBuffer();
  151. virtual void draw();
  152. virtual TPalette& getPalette() const;
  153. virtual void handleEvent( TEvent& );
  154. virtual void initBuffer();
  155. Boolean insertBuffer( char *, uint32, uint32, Boolean, Boolean );
  156. virtual Boolean insertFrom( TEditor * );
  157. Boolean insertText( const void *, uint32, Boolean );
  158. void scrollTo( int, int );
  159. Boolean search( const char *, ushort );
  160. virtual Boolean setBufSize( uint32 );
  161. void setCmdState( ushort, Boolean );
  162. void setSelect( uint32, uint32, Boolean);
  163. virtual void setState( ushort, Boolean );
  164. void trackCursor( Boolean );
  165. void undo();
  166. virtual void updateCommands();
  167. virtual Boolean valid( ushort );
  168. int charPos( uint32, uint32 );
  169. uint32 charPtr( uint32, int );
  170. Boolean clipCopy();
  171. void clipCut();
  172. void clipPaste();
  173. void deleteRange( uint32, uint32, Boolean );
  174. void doUpdate();
  175. void doSearchReplace();
  176. void drawLines( int, int, uint32 );
  177. virtual void formatLine(void *, uint32, int, ushort );
  178. void find();
  179. uint32 getMousePtr( TPoint );
  180. Boolean hasSelection();
  181. void hideSelect();
  182. Boolean isClipboard();
  183. uint32 lineEnd( uint32 );
  184. uint32 lineMove( uint32, int );
  185. uint32 lineStart( uint32 );
  186. void lock();
  187. void newLine();
  188. uint32 nextChar( uint32 );
  189. uint32 nextLine( uint32 );
  190. uint32 nextWord( uint32 );
  191. uint32 prevChar( uint32 );
  192. uint32 prevLine( uint32 );
  193. uint32 prevWord( uint32 );
  194. void replace();
  195. void setBufLen( uint32 );
  196. void setCurPtr( uint32, uchar );
  197. void startSelect();
  198. void toggleInsMode();
  199. void unlock();
  200. void update( uchar );
  201. void checkScrollBar( const TEvent&, TScrollBar *, int& );
  202. TScrollBar *hScrollBar;
  203. TScrollBar *vScrollBar;
  204. TIndicator *indicator;
  205. char *buffer;
  206. uint32 bufSize;
  207. uint32 bufLen;
  208. uint32 gapLen;
  209. uint32 selStart;
  210. uint32 selEnd;
  211. uint32 curPtr;
  212. TPoint curPos;
  213. TPoint delta;
  214. TPoint limit;
  215. int drawLine;
  216. uint32 drawPtr;
  217. uint32 delCount;
  218. uint32 insCount;
  219. Boolean isValid;
  220. Boolean canUndo;
  221. Boolean modified;
  222. Boolean selecting;
  223. Boolean overwrite;
  224. Boolean autoIndent;
  225. static TEditorDialog editorDialog;
  226. static ushort editorFlags;
  227. static char findStr[maxFindStrLen];
  228. static char replaceStr[maxReplaceStrLen];
  229. static TEditor * clipboard;
  230. static uint32 tabSize;
  231. uchar lockCount;
  232. uchar updateFlags;
  233. int keyState;
  234. #ifndef NO_STREAM
  235. private:
  236. virtual const char *streamableName() const
  237. { return name; }
  238. protected:
  239. TEditor( StreamableInit );
  240. virtual void write( opstream& );
  241. virtual void *read( ipstream& );
  242. public:
  243. static const char * const name;
  244. static TStreamable *build();
  245. #endif
  246. };
  247. #ifndef NO_STREAM
  248. inline ipstream& operator >> ( ipstream& is, TEditor& cl )
  249. { return is >> (TStreamable&)cl; }
  250. inline ipstream& operator >> ( ipstream& is, TEditor*& cl )
  251. { return is >> (void *&)cl; }
  252. inline opstream& operator << ( opstream& os, TEditor& cl )
  253. { return os << (TStreamable&)cl; }
  254. inline opstream& operator << ( opstream& os, TEditor* cl )
  255. { return os << (TStreamable *)cl; }
  256. #endif // NO_STREAM
  257. #endif // Uses_TEditor
  258. #if defined( Uses_TMemo ) && !defined( __TMemo )
  259. #define __TMemo
  260. class TEvent;
  261. struct TMemoData
  262. {
  263. uint32 length;
  264. char buffer[65536];
  265. };
  266. class TMemo : public TEditor
  267. {
  268. public:
  269. TMemo( const TRect&, TScrollBar *, TScrollBar *, TIndicator *, uint32 );
  270. virtual void getData( void *rec );
  271. virtual void setData( void *rec );
  272. virtual uint32 dataSize();
  273. virtual TPalette& getPalette() const;
  274. virtual void handleEvent( TEvent& );
  275. #ifndef NO_STREAM
  276. private:
  277. virtual const char *streamableName() const
  278. { return name; }
  279. protected:
  280. TMemo( StreamableInit );
  281. virtual void write( opstream& );
  282. virtual void *read( ipstream& );
  283. public:
  284. static const char * const name;
  285. static TStreamable *build();
  286. #endif // NO_STREAM
  287. };
  288. #ifndef NO_STREAM
  289. inline ipstream& operator >> ( ipstream& is, TMemo& cl )
  290. { return is >> (TStreamable&)cl; }
  291. inline ipstream& operator >> ( ipstream& is, TMemo*& cl )
  292. { return is >> (void *&)cl; }
  293. inline opstream& operator << ( opstream& os, TMemo& cl )
  294. { return os << (TStreamable&)cl; }
  295. inline opstream& operator << ( opstream& os, TMemo* cl )
  296. { return os << (TStreamable *)cl; }
  297. #endif // NO_STREAM
  298. #endif // Uses_TMemo
  299. #if defined( Uses_TFileEditor ) && !defined( __TFileEditor )
  300. #define __TFileEditor
  301. //#include <dir.h>
  302. class TRect;
  303. class TScrollBar;
  304. class TIndicator;
  305. class TEvent;
  306. class TFileEditor : public TEditor
  307. {
  308. public:
  309. char fileName[PATH_MAX];
  310. TFileEditor( const TRect&,
  311. TScrollBar *,
  312. TScrollBar *,
  313. TIndicator *,
  314. const char *
  315. );
  316. virtual void doneBuffer();
  317. virtual void handleEvent( TEvent& );
  318. virtual void initBuffer();
  319. Boolean loadFile();
  320. Boolean save();
  321. Boolean saveAs();
  322. Boolean saveFile();
  323. virtual Boolean setBufSize( uint32 );
  324. virtual void shutDown();
  325. virtual void updateCommands();
  326. virtual Boolean valid( ushort );
  327. private:
  328. static const char * backupExt;
  329. #ifndef NO_STREAM
  330. virtual const char *streamableName() const
  331. { return name; }
  332. protected:
  333. TFileEditor( StreamableInit );
  334. virtual void write( opstream& );
  335. virtual void *read( ipstream& );
  336. public:
  337. static const char * const name;
  338. static TStreamable *build();
  339. #endif // NO_STREAM
  340. };
  341. #ifndef NO_STREAM
  342. inline ipstream& operator >> ( ipstream& is, TFileEditor& cl )
  343. { return is >> (TStreamable&)cl; }
  344. inline ipstream& operator >> ( ipstream& is, TFileEditor*& cl )
  345. { return is >> (void *&)cl; }
  346. inline opstream& operator << ( opstream& os, TFileEditor& cl )
  347. { return os << (TStreamable&)cl; }
  348. inline opstream& operator << ( opstream& os, TFileEditor* cl )
  349. { return os << (TStreamable *)cl; }
  350. #endif // NO_STREAM
  351. #endif // Uses_TFileEditor
  352. #if defined( Uses_TEditWindow ) && !defined( __TEditWindow )
  353. #define __TEditWindow
  354. class TFileEditor;
  355. class TEditWindow : public TWindow
  356. {
  357. public:
  358. TEditWindow( const TRect&, const char *, int );
  359. virtual void close();
  360. virtual const char *getTitle( short );
  361. virtual void handleEvent( TEvent& );
  362. virtual void sizeLimits( TPoint& min, TPoint& max );
  363. TFileEditor *editor;
  364. private:
  365. static const char * clipboardTitle;
  366. static const char * untitled;
  367. #ifndef NO_STREAM
  368. virtual const char *streamableName() const
  369. { return name; }
  370. protected:
  371. TEditWindow( StreamableInit );
  372. virtual void write( opstream& );
  373. virtual void *read( ipstream& );
  374. public:
  375. static const char * const name;
  376. static TStreamable *build();
  377. #endif // NO_STREAM
  378. };
  379. #ifndef NO_STREAM
  380. inline ipstream& operator >> ( ipstream& is, TEditWindow& cl )
  381. { return is >> (TStreamable&)cl; }
  382. inline ipstream& operator >> ( ipstream& is, TEditWindow*& cl )
  383. { return is >> (void *&)cl; }
  384. inline opstream& operator << ( opstream& os, TEditWindow& cl )
  385. { return os << (TStreamable&)cl; }
  386. inline opstream& operator << ( opstream& os, TEditWindow* cl )
  387. { return os << (TStreamable *)cl; }
  388. #endif // NO_STREAM
  389. #endif // Uses_TEditWindow
  390. #if defined( Uses_TFindDialogRec ) && !defined( __TFindDialogRec )
  391. #define __TFindDialogRec
  392. struct TFindDialogRec
  393. {
  394. TFindDialogRec( const char *str, ushort flgs )
  395. {
  396. strcpy( find, str );
  397. options = flgs;
  398. }
  399. char find[maxFindStrLen];
  400. ushort options;
  401. };
  402. #endif // Uses_TFindDialogRec
  403. #if defined( Uses_TReplaceDialogRec ) && !defined( __TReplaceDialogRec )
  404. #define __TReplaceDialogRec
  405. struct TReplaceDialogRec
  406. {
  407. TReplaceDialogRec( const char *str, const char *rep, ushort flgs )
  408. {
  409. strcpy( find, str );
  410. strcpy( replace, rep );
  411. options = flgs;
  412. }
  413. char find[maxFindStrLen];
  414. char replace[maxReplaceStrLen];
  415. ushort options;
  416. };
  417. #endif // Uses_TReplaceDialogRec