editor.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #ifndef EDITOR_H
  2. #define EDITOR_H
  3. #include "tabber.h"
  4. #include "funclist.h"
  5. class Editor;
  6. class EditorListener{
  7. public:
  8. virtual void cursorMoved( Editor *e ){}
  9. };
  10. class Editor : public CWnd,FuncListListener,TabberListener{
  11. public:
  12. Editor( EditorListener *l );
  13. ~Editor();
  14. void setName( const string &f );
  15. void setModified( bool n );
  16. bool setText( istream &in );
  17. void setCursor( int pos );
  18. void cut();
  19. void copy();
  20. void paste();
  21. void find();
  22. void replace();
  23. bool canFind();
  24. bool findNext( bool wrap );
  25. void print();
  26. void hilight( int pos );
  27. void selectAll();
  28. static void lock();
  29. static void unlock();
  30. int getCursor();
  31. string getName()const;
  32. string getKeyword();
  33. bool getModified();
  34. bool getText( ostream &out );
  35. void getCursor( int *row,int *col );
  36. bool canCutCopy();
  37. bool canPaste();
  38. static void addKeyword( const string &s );
  39. DECLARE_DYNAMIC( Editor )
  40. DECLARE_MESSAGE_MAP()
  41. afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
  42. afx_msg void OnSize( UINT type,int w,int h );
  43. afx_msg void OnSetFocus( CWnd *wnd );
  44. afx_msg void OnKillFocus( CWnd *wnd );
  45. afx_msg void OnPaint();
  46. afx_msg void OnMouseMove( UINT flags,CPoint p );
  47. afx_msg void OnLButtonDown( UINT flags,CPoint p );
  48. afx_msg void OnLButtonUp( UINT flags,CPoint p );
  49. afx_msg void en_change();
  50. afx_msg void en_update();
  51. afx_msg void en_selchange( NMHDR *nmhdr,LRESULT *result );
  52. afx_msg void en_protected( NMHDR *nmhdr,LRESULT *result );
  53. afx_msg void en_msgfilter( NMHDR *nmhdr,LRESULT *result );
  54. afx_msg LRESULT onFind( WPARAM w,LPARAM l );
  55. private:
  56. EditorListener *listener;
  57. string name;
  58. bool findOnly,found;
  59. CFindReplaceDialog *finder;
  60. char findBuff[256],replaceBuff[256];
  61. long selStart,selEnd;
  62. int findFlags,d_c;
  63. //formatting
  64. bool fmtBusy;
  65. int lineToFmt,fmtLineCount;
  66. //streaming
  67. string is_line;
  68. istream *is_stream;
  69. int is_curs,is_linenum;
  70. //sizing
  71. bool sizing;
  72. CPoint point;
  73. int tabber_width;
  74. //tabber
  75. Tabber tabber;
  76. FuncList funcList,typeList,labsList;
  77. CRichEditCtrl editCtrl;
  78. void funcSelected( int line );
  79. void currentSet( Tabber *tabber,int index );
  80. void resized();
  81. void fixFmt( bool fmt );
  82. void getSel(){ editCtrl.GetSel( selStart,selEnd ); }
  83. void setSel(){ editCtrl.SetSel( selStart,selEnd ); }
  84. void endFind();
  85. void setFormat( int from,int to,int color,const string &s="" );
  86. void formatLine( int line );
  87. void caret();
  88. void cursorMoved();
  89. string getLine( int line );
  90. void formatStreamLine();
  91. DWORD streamIn( LPBYTE buff,LONG cnt,LONG *done );
  92. static DWORD CALLBACK streamIn( DWORD cookie,LPBYTE buff,LONG cnt,LONG *done );
  93. static DWORD CALLBACK streamOut( DWORD cookie,LPBYTE buff,LONG cnt,LONG *done );
  94. };
  95. #endif