00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _QDOCUMENT_CURSOR_H_
00017 #define _QDOCUMENT_CURSOR_H_
00018
00019 #include "qce-config.h"
00020
00026 class QPoint;
00027 class QString;
00028 class QPolygon;
00029
00030 class QDocument;
00031 class QDocumentLine;
00032 struct QDocumentSelection;
00033 class QDocumentCursorHandle;
00034
00035 class QCE_EXPORT QDocumentCursor
00036 {
00037 public:
00038 enum MoveFlag
00039 {
00040 MoveAnchor = 0,
00041 KeepAnchor = 1,
00042 ThroughWrap = 2
00043 };
00044
00045 Q_DECLARE_FLAGS(MoveMode, MoveFlag);
00046
00047 enum MoveOperation
00048 {
00049 NoMove,
00050 Up,
00051 Down,
00052 Left,
00053 PreviousCharacter = Left,
00054 Right,
00055 NextCharacter = Right,
00056 Start,
00057 StartOfLine,
00058 StartOfBlock = StartOfLine,
00059 StartOfWord,
00060 PreviousBlock,
00061 PreviousLine = PreviousBlock,
00062 PreviousWord,
00063 WordLeft,
00064 WordRight,
00065 End,
00066 EndOfLine,
00067 EndOfBlock = EndOfLine,
00068 EndOfWord,
00069 NextWord,
00070 NextBlock,
00071 NextLine = NextBlock
00072 };
00073
00074 enum SelectionType
00075 {
00076 WordUnderCursor,
00077 LineUnderCursor
00078 };
00079
00080 explicit QDocumentCursor(QDocument *doc);
00081 QDocumentCursor(const QDocumentCursor& cursor);
00082 QDocumentCursor(QDocument *doc, int line, int column = 0);
00083
00084 QDocumentCursor(QDocumentCursorHandle* handle = 0);
00085
00086 ~QDocumentCursor();
00087
00088 QDocumentCursor clone() const;
00089
00090 QDocumentCursor& operator = (const QDocumentCursor& c);
00091
00092 bool operator == (const QDocumentCursor& c) const;
00093 bool operator != (const QDocumentCursor& c) const;
00094
00095 bool operator < (const QDocumentCursor& c) const;
00096 bool operator > (const QDocumentCursor& c) const;
00097
00098 bool operator <= (const QDocumentCursor& c) const;
00099 bool operator >= (const QDocumentCursor& c) const;
00100
00101 bool isNull() const;
00102 bool isValid() const;
00103
00104 bool atEnd() const;
00105 bool atStart() const;
00106
00107 bool atBlockEnd() const;
00108 bool atBlockStart() const;
00109
00110 bool atLineEnd() const;
00111 bool atLineStart() const;
00112
00113 bool hasSelection() const;
00114
00115 bool isSilent() const;
00116 void setSilent(bool y);
00117
00118 bool isAutoUpdated() const;
00119 void setAutoUpdated(bool y);
00120
00121 int position() const;
00122
00123 int lineNumber() const;
00124 int columnNumber() const;
00125
00126 int anchorLineNumber() const;
00127 int anchorColumnNumber() const;
00128
00129 int visualColumnNumber() const;
00130
00131 void setColumnNumber(int c, MoveMode m = MoveAnchor);
00132
00133 int wrappedLineOffset() const;
00134 int anchorWrappedLineOffset() const;
00135
00136 QPoint documentPosition() const;
00137 QPoint anchorDocumentPosition() const;
00138
00139 QPolygon documentRegion() const;
00140
00141 QDocumentLine line() const;
00142 QDocumentLine anchorLine() const;
00143
00144 void shift(int offset);
00145 void setPosition(int pos, MoveMode m = MoveAnchor);
00146 bool movePosition(int offset, MoveOperation op = NextCharacter, MoveMode m = MoveAnchor);
00147
00148 void moveTo(int line, int column);
00149 void moveTo(const QDocumentCursor &c);
00150 void moveTo(const QDocumentLine &l, int column);
00151
00152 void eraseLine();
00153 void insertLine();
00154 void insertText(const QString& s);
00155
00156 QDocumentCursor selectionStart() const;
00157 QDocumentCursor selectionEnd() const;
00158
00159 QString selectedText() const;
00160
00161 void clearSelection();
00162 void removeSelectedText();
00163
00164 void select(SelectionType t);
00165 void setSelectionBoundary(const QDocumentCursor& c);
00166
00167 bool isWithinSelection(const QDocumentCursor& c) const;
00168
00169 void deleteChar();
00170 void deletePreviousChar();
00171
00172 void beginEditBlock();
00173 void endEditBlock();
00174
00175 void refreshColumnMemory();
00176 bool hasColumnMemory() const;
00177 void setColumnMemory(bool y);
00178
00179 QDocumentSelection selection() const;
00180
00181 QDocument* document() const;
00182
00183 inline QDocumentCursorHandle* handle() const
00184 { return m_handle; }
00185
00186 private:
00187 QDocumentCursorHandle *m_handle;
00188 };
00189
00190 #endif