00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef kate_view_h
00041 #define kate_view_h
00042
00043 #include "../interfaces/view.h"
00044 #include "../interfaces/document.h"
00045
00046 #include <qlist.h>
00047 #include <qstring.h>
00048 #include <qdialog.h>
00049
00050
00051 class KateDocument;
00052 class KateConfig;
00053 class Highlight;
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 enum Select_flags {
00066 selectFlag = 0x100000,
00067 multiSelectFlag = 0x200000
00068 };
00069
00070 enum State_commands {
00071 cmToggleInsert = 1,
00072 cmToggleVertical = 2
00073 };
00074
00075 class KateViewInternal;
00076 class KateView;
00077
00078 struct PointStruc {
00079 int x;
00080 int y;
00081 };
00082
00083 struct VConfig {
00084 KateView *view;
00085 PointStruc cursor;
00086 int cXPos;
00087 int flags;
00088 };
00089
00090 struct SConfig {
00091 PointStruc cursor;
00092 PointStruc startCursor;
00093 int flags;
00094
00095
00096 void setPattern(QString &newPattern);
00097
00098
00099 int search(QString &text, int index);
00100
00101
00102 int matchedLength;
00103
00104 private:
00105 QString m_pattern;
00106
00107
00108
00109 QRegExp m_regExp;
00110 };
00111
00112 struct LineRange {
00113 int start;
00114 int end;
00115 };
00116
00117 struct BracketMark {
00118 PointStruc cursor;
00119 int sXPos;
00120 int eXPos;
00121 };
00122
00123
00124 class KateIconBorder : public QWidget
00125 {
00126 public:
00127 KateIconBorder(KateView *view, class KateViewInternal *internalView);
00128 ~KateIconBorder();
00129
00130 void paintLine(int i);
00131
00132 protected:
00133 void paintEvent(QPaintEvent* e);
00134 void mousePressEvent(QMouseEvent* e);
00135
00136 private:
00137
00138 KateView *myView;
00139 class KateViewInternal *myInternalView;
00140 bool lmbSetsBreakpoints;
00141 };
00142
00143 class KateViewInternal : public QWidget {
00144 Q_OBJECT
00145 friend class KateDocument;
00146 friend class KateView;
00147 friend class KateIconBorder;
00148
00149 private:
00150 long waitForPreHighlight;
00151 int iconBorderWidth;
00152 int iconBorderHeight;
00153
00154 protected slots:
00155 void slotPreHighlightUpdate(long line);
00156
00157 public:
00158 KateViewInternal(KateView *view, KateDocument *doc);
00159 ~KateViewInternal();
00160
00161 virtual void doCursorCommand(VConfig &, int cmdNum);
00162 virtual void doEditCommand(VConfig &, int cmdNum);
00163
00164 void cursorLeft(VConfig &);
00165 void cursorRight(VConfig &);
00166 void wordLeft(VConfig &);
00167 void wordRight(VConfig &);
00168 void home(VConfig &);
00169 void end(VConfig &);
00170 void cursorUp(VConfig &);
00171 void cursorDown(VConfig &);
00172 void scrollUp(VConfig &);
00173 void scrollDown(VConfig &);
00174 void topOfView(VConfig &);
00175 void bottomOfView(VConfig &);
00176 void pageUp(VConfig &);
00177 void pageDown(VConfig &);
00178 void cursorPageUp(VConfig &);
00179 void cursorPageDown(VConfig &);
00180 void top(VConfig &);
00181 void bottom(VConfig &);
00182 void top_home(VConfig &c);
00183 void bottom_end(VConfig &c);
00184
00185 protected slots:
00186 void changeXPos(int);
00187 void changeYPos(int);
00188
00189 protected:
00190 void getVConfig(VConfig &);
00191 void changeState(VConfig &);
00192 void insLine(int line);
00193 void delLine(int line);
00194 void updateCursor();
00195 void updateCursor(PointStruc &newCursor);
00196 void updateCursor(PointStruc &newCursor, int flags);
00197 void clearDirtyCache(int height);
00198 void tagLines(int start, int end, int x1, int x2);
00199 void tagAll();
00200 void setPos(int x, int y);
00201 void center();
00202
00203 void updateView(int flags);
00204
00205 void paintTextLines(int xPos, int yPos);
00206 void paintCursor();
00207 void paintBracketMark();
00208
00209 void placeCursor(int x, int y, int flags = 0);
00210 bool isTargetSelected(int x, int y);
00211
00212
00213
00214 virtual void focusInEvent(QFocusEvent *);
00215 virtual void focusOutEvent(QFocusEvent *);
00216 virtual void keyPressEvent(QKeyEvent *e);
00217 virtual void mousePressEvent(QMouseEvent *);
00218 virtual void mouseDoubleClickEvent(QMouseEvent *);
00219 virtual void mouseReleaseEvent(QMouseEvent *);
00220 virtual void mouseMoveEvent(QMouseEvent *);
00221 virtual void wheelEvent( QWheelEvent *e );
00222 virtual void paintEvent(QPaintEvent *);
00223 virtual void resizeEvent(QResizeEvent *);
00224 virtual void timerEvent(QTimerEvent *);
00225
00226
00227 KateView *myView;
00228 KateDocument *myDoc;
00229 QScrollBar *xScroll;
00230 QScrollBar *yScroll;
00231 KateIconBorder *leftBorder;
00232
00233 int xPos;
00234 int yPos;
00235
00236 int mouseX;
00237 int mouseY;
00238 int scrollX;
00239 int scrollY;
00240 int scrollTimer;
00241
00242 PointStruc cursor;
00243 bool cursorOn;
00244 int cursorTimer;
00245 int cXPos;
00246 int cOldXPos;
00247
00248 int startLine;
00249 int endLine;
00250
00251 bool exposeCursor;
00252 int updateState;
00253 int numLines;
00254 LineRange *lineRanges;
00255 int newXPos;
00256 int newYPos;
00257
00258 QPixmap *drawBuffer;
00259
00260 BracketMark bm;
00261
00262 };
00263
00270 class KateView : public Kate::View
00271 {
00272 Q_OBJECT
00273 friend class KateViewInternal;
00274 friend class KateDocument;
00275 friend class KateIconBorder;
00276
00277 public:
00278 KateView(KateDocument *doc=0L, QWidget *parent = 0L, const char * name = 0);
00279 ~KateView();
00280
00281 virtual void setCursorPosition( int line, int col, bool mark = false );
00282 virtual void getCursorPosition( int *line, int *col );
00283
00284 virtual bool isOverwriteMode() const;
00285 virtual void setOverwriteMode( bool b );
00286
00287
00293 int currentLine();
00298 int currentColumn();
00302 int currentCharNum();
00306 void setCursorPositionInternal(int line, int col);
00310 int config();
00314 void setConfig(int);
00315
00316 int tabWidth();
00317 void setTabWidth(int);
00318 void setEncoding (QString e);
00319 int undoSteps();
00320 void setUndoSteps(int);
00321
00322
00326 bool isReadOnly();
00330 bool isModified();
00334 void setReadOnly(bool);
00338 void setModified(bool m = true);
00342 bool isLastView();
00346 KateDocument *doc();
00347
00348
00349
00350
00351
00352 int undoState();
00356 int nextUndoType();
00360 int nextRedoType();
00364 void undoTypeList(QValueList<int> &lst);
00368 void redoTypeList(QValueList<int> &lst);
00375 const char * undoTypeName(int undoType);
00376
00377 QColor* getColors();
00378 void applyColors();
00379
00380
00381 public slots:
00382 void slotUpdate();
00383 void slotFileStatusChanged();
00384 void slotNewUndo();
00385 void slotHighlightChanged();
00386
00387 public slots:
00391 void toggleInsert();
00395 void toggleVertical();
00396 signals:
00401 void newCurPos();
00405 void newStatus();
00409 void newUndo();
00414 void newMarkStatus();
00415
00416
00417 void enableUI( bool enable );
00418
00419 protected:
00420 virtual void keyPressEvent( QKeyEvent *ev );
00421
00422 int configFlags;
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432 public:
00436 int numLines();
00440 QString text();
00444 QString currentTextLine();
00448 QString textLine(int num);
00452 QString currentWord();
00457 QString word(int x, int y);
00461 void setText(const QString &);
00466 virtual void insertText(const QString &, bool mark = false);
00470 bool hasMarkedText();
00474 QString markedText();
00475
00476 public:
00477 enum fileResult { OK, CANCEL, RETRY, ERROR };
00478
00484 bool canDiscard();
00485
00486 public slots:
00492 void flush ();
00498 fileResult save();
00503 fileResult saveAs();
00507 void cut() {doEditCommand(KateView::cmCut);}
00511 void copy() {doEditCommand(KateView::cmCopy);}
00515 void paste() {doEditCommand(KateView::cmPaste);}
00519 void undo() {doEditCommand(KateView::cmUndo);}
00523 void redo() {doEditCommand(KateView::cmRedo);}
00528 void undoMultiple(int count);
00533 void redoMultiple(int count);
00537 void undoHistory();
00541 void indent() {doEditCommand(KateView::cmIndent);};
00545 void unIndent() {doEditCommand(KateView::cmUnindent);};
00549 void cleanIndent() {doEditCommand(KateView::cmCleanIndent);};
00553 void selectAll() {doEditCommand(KateView::cmSelectAll);}
00557 void deselectAll() {doEditCommand(KateView::cmDeselectAll);}
00561 void invertSelection() {doEditCommand(KateView::cmInvertSelection);}
00565 void comment() {doEditCommand(KateView::cmComment);};
00569 void uncomment() {doEditCommand(KateView::cmUncomment);};
00570
00571 void keyReturn() {doEditCommand(KateView::cmReturn);};
00572 void keyDelete() {doEditCommand(KateView::cmDelete);};
00573 void backspace() {doEditCommand(KateView::cmBackspace);};
00574 void killLine() {doEditCommand(KateView::cmKillLine);};
00575
00576
00577
00578 void cursorLeft() {doCursorCommand(KateView::cmLeft);};
00579 void shiftCursorLeft() {doCursorCommand(KateView::cmLeft | selectFlag);};
00580 void cursorRight() {doCursorCommand(KateView::cmRight);}
00581 void shiftCursorRight() {doCursorCommand(KateView::cmRight | selectFlag);}
00582 void wordLeft() {doCursorCommand(KateView::cmWordLeft);};
00583 void shiftWordLeft() {doCursorCommand(KateView::cmWordLeft | selectFlag);};
00584 void wordRight() {doCursorCommand(KateView::cmWordRight);};
00585 void shiftWordRight() {doCursorCommand(KateView::cmWordRight | selectFlag);};
00586 void home() {doCursorCommand(KateView::cmHome);};
00587 void shiftHome() {doCursorCommand(KateView::cmHome | selectFlag);};
00588 void end() {doCursorCommand(KateView::cmEnd);};
00589 void shiftEnd() {doCursorCommand(KateView::cmEnd | selectFlag);};
00590 void up() {doCursorCommand(KateView::cmUp);};
00591 void shiftUp() {doCursorCommand(KateView::cmUp | selectFlag);};
00592 void down() {doCursorCommand(KateView::cmDown);};
00593 void shiftDown() {doCursorCommand(KateView::cmDown | selectFlag);};
00594 void scrollUp() {doCursorCommand(KateView::cmScrollUp);};
00595 void scrollDown() {doCursorCommand(KateView::cmScrollDown);};
00596 void topOfView() {doCursorCommand(KateView::cmTopOfView);};
00597 void bottomOfView() {doCursorCommand(KateView::cmBottomOfView);};
00598 void pageUp() {doCursorCommand(KateView::cmPageUp);};
00599 void shiftPageUp() {doCursorCommand(KateView::cmPageUp | selectFlag);};
00600 void pageDown() {doCursorCommand(KateView::cmPageDown);};
00601 void shiftPageDown() {doCursorCommand(KateView::cmPageDown | selectFlag);};
00602 void top() {doCursorCommand(KateView::cmTop);};
00603 void shiftTop() {doCursorCommand(KateView::cmTop | selectFlag);};
00604 void bottom() {doCursorCommand(KateView::cmBottom);};
00605 void shiftBottom() {doCursorCommand(KateView::cmBottom | selectFlag);};
00606
00607
00608 public slots:
00612 void find();
00616 void replace();
00617
00621 void gotoLine();
00622 protected:
00623 void initSearch(SConfig &, int flags);
00624 void continueSearch(SConfig &);
00625 void findAgain(SConfig &);
00626 void replaceAgain();
00627 void doReplaceAction(int result, bool found = false);
00628 void exposeFound(PointStruc &cursor, int slen, int flags, bool replace);
00629 void deleteReplacePrompt();
00630 bool askReplaceEnd();
00631 protected slots:
00632 void replaceSlot();
00633 protected:
00634 int searchFlags;
00635 int replaces;
00636 SConfig s;
00637 QDialog *replacePrompt;
00638
00639
00640 public:
00645 void installPopup(QPopupMenu *rmb_Menu);
00646
00647 protected:
00648 QPopupMenu *rmbMenu;
00649
00650 signals:
00651 void bookAddChanged(bool enabled);
00652 void bookClearChanged(bool enabled);
00653
00654
00655 public:
00659 void readConfig();
00663 void writeConfig();
00668 void readSessionConfig(KateConfig *);
00672 void writeSessionConfig(KateConfig *);
00673
00674
00675 public:
00676 void setDontChangeHlOnSave();
00677
00678
00679
00680 public slots:
00684 void configDialog ();
00688 int getHl();
00692 void setHl(int n);
00696 int getEol();
00700 void setEol(int);
00701
00702
00703 protected:
00704 virtual void paintEvent(QPaintEvent *);
00705 virtual void resizeEvent(QResizeEvent *);
00706
00707 void doCursorCommand(int cmdNum);
00708 void doEditCommand(int cmdNum);
00709
00710 KateViewInternal *myViewInternal;
00711 KateDocument *myDoc;
00712
00713
00714
00715 protected:
00716 void insLine(int line) { myViewInternal->insLine(line); };
00717 void delLine(int line) { myViewInternal->delLine(line); };
00718 void updateCursor() { myViewInternal->updateCursor(); };
00719 void updateCursor(PointStruc &newCursor) { myViewInternal->updateCursor(newCursor); };
00720 void updateCursor(PointStruc &newCursor, int flags) { myViewInternal->updateCursor(newCursor, flags); };
00721
00722 void clearDirtyCache(int height) { myViewInternal->clearDirtyCache(height); };
00723 void tagLines(int start, int end, int x1, int x2) { myViewInternal->tagLines(start, end, x1, x2); };
00724 void tagAll() { myViewInternal->tagAll(); };
00725 void setPos(int x, int y) { myViewInternal->setPos(x, y); };
00726 void center() { myViewInternal->center(); };
00727
00728 void updateView(int flags) { myViewInternal->updateView(flags); };
00729
00730
00731
00732 public:
00733 enum Config_flags {
00734 cfAutoIndent= 0x1,
00735 cfBackspaceIndents= 0x2,
00736 cfWordWrap= 0x4,
00737 cfReplaceTabs= 0x8,
00738 cfRemoveSpaces = 0x10,
00739 cfWrapCursor= 0x20,
00740 cfAutoBrackets= 0x40,
00741 cfPersistent= 0x80,
00742 cfKeepSelection= 0x100,
00743 cfVerticalSelect= 0x200,
00744 cfDelOnInput= 0x400,
00745 cfXorSelect= 0x800,
00746 cfOvr= 0x1000,
00747 cfMark= 0x2000,
00748 cfGroupUndo= 0x4000,
00749 cfKeepIndentProfile= 0x8000,
00750 cfKeepExtraSpaces= 0x10000,
00751 cfMouseAutoCopy= 0x20000,
00752 cfSingleSelection= 0x40000,
00753 cfTabIndents= 0x80000,
00754 cfPageUDMovesCursor= 0x100000,
00755 cfShowTabs= 0x200000,
00756 cfSpaceIndent= 0x400000,
00757 cfSmartHome = 0x800000};
00758
00759 enum Dialog_results {
00760 srYes=QDialog::Accepted,
00761 srNo=10,
00762 srAll,
00763 srCancel=QDialog::Rejected};
00764
00765
00766 enum Search_flags {
00767 sfCaseSensitive=1,
00768 sfWholeWords=2,
00769 sfFromBeginning=4,
00770 sfBackward=8,
00771 sfSelected=16,
00772 sfPrompt=32,
00773 sfReplace=64,
00774 sfAgain=128,
00775 sfWrapped=256,
00776 sfFinished=512,
00777 sfRegularExpression=1024};
00778
00779
00780 enum Update_flags {
00781 ufDocGeometry=1,
00782 ufUpdateOnScroll=2,
00783 ufPos=4};
00784
00785
00786 enum Load_flags {
00787 lfInsert=1,
00788 lfNewFile=2,
00789 lfNoAutoHl=4};
00790
00791
00792 enum Cursor_commands
00793 { cmLeft,cmRight,cmWordLeft,cmWordRight,
00794 cmHome,cmEnd,cmUp,cmDown,
00795 cmScrollUp,cmScrollDown,cmTopOfView,cmBottomOfView,
00796 cmPageUp,cmPageDown,cmCursorPageUp,cmCursorPageDown,
00797 cmTop,cmBottom};
00798
00799 enum Edit_commands {
00800 cmReturn=1,cmDelete,cmBackspace,cmKillLine,cmUndo,
00801 cmRedo,cmCut,cmCopy,cmPaste,cmIndent,cmUnindent,cmCleanIndent,
00802 cmSelectAll,cmDeselectAll,cmInvertSelection,cmComment,
00803 cmUncomment};
00804
00805 enum Find_commands { cmFind=1,cmReplace,cmFindAgain,cmGotoLine};
00806
00807 public:
00808 void setActive (bool b);
00809 bool isActive ();
00810
00811 private:
00812 bool active;
00813 bool myIconBorder;
00814 QList<Kate::Mark> list;
00815
00816 public slots:
00817 virtual void setFocus ();
00818 void findAgain(bool back=false);
00819 void findAgain () { findAgain(false); };
00820 void findPrev () { findAgain(true); };
00821
00822 protected:
00823 bool eventFilter(QObject* o, QEvent* e);
00824
00825 signals:
00826 void gotFocus (KateView *);
00827
00828 public slots:
00829 void slotEditCommand ();
00830 void setIconBorder (bool enable);
00831 void toggleIconBorder ();
00832 void gotoMark (Kate::Mark *mark);
00833 void toggleBookmark ();
00834 void clearBookmarks ();
00835
00836 public:
00837 bool iconBorder() { return myIconBorder; } ;
00838
00839 private slots:
00840 void bookmarkMenuAboutToShow();
00841 void gotoBookmark (int n);
00842
00843 public:
00844 Kate::Document *getDoc ()
00845 { return (Kate::Document*) myDoc; };
00846
00847 public slots:
00848 int getHlCount ();
00849 QString getHlName (int);
00850 QString getHlSection (int);
00851
00852 void slotIncFontSizes ();
00853 void slotDecFontSizes ();
00854
00855 protected:
00856 uint myViewID;
00857 static uint uniqueID;
00858 };
00859
00860 #endif
00861
00862
00863
00864
00865
00866