• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kate
 

kate

  • kate
  • part
kateviewinternal.h
1/* This file is part of the KDE libraries
2 Copyright (C) 2002 John Firebaugh <jfirebaugh@kde.org>
3 Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
4 Copyright (C) 2002 Christoph Cullmann <cullmann@kde.org>
5
6 Based on:
7 KWriteView : Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public
11 License version 2 as published by the Free Software Foundation.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
17
18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA.
22*/
23
24#ifndef _KATE_VIEW_INTERNAL_
25#define _KATE_VIEW_INTERNAL_
26
27#include "katecursor.h"
28#include "katesupercursor.h"
29#include "katelinerange.h"
30#include "katetextline.h"
31#include "katedocument.h"
32
33#include <tqpoint.h>
34#include <tqtimer.h>
35#include <tqintdict.h>
36#include <tqdragobject.h>
37
38class KateView;
39class KateIconBorder;
40class KateScrollBar;
41
42class TQHBoxLayout;
43class TQVBoxLayout;
44class TQScrollBar;
45
46enum Bias
47{
48 left_b = -1,
49 none = 0,
50 right_b = 1
51};
52
53class KateViewInternal : public TQWidget
54{
55 TQ_OBJECT
56
57 friend class KateView;
58 friend class KateIconBorder;
59 friend class KateScrollBar;
60 friend class CalculatingCursor;
61 friend class BoundedCursor;
62 friend class WrappingCursor;
63
64 public:
65 KateViewInternal ( KateView *view, KateDocument *doc );
66 ~KateViewInternal ();
67
68 //BEGIN EDIT STUFF
69 public:
70 void editStart ();
71 void editEnd (int editTagLineStart, int editTagLineEnd, bool tagFrom);
72
73 void editSetCursor (const KateTextCursor &cursor);
74
75 private:
76 uint editSessionNumber;
77 bool editIsRunning;
78 KateTextCursor editOldCursor;
79 //END
80
81 //BEGIN TAG & CLEAR & UPDATE STUFF
82 public:
83 bool tagLine (const KateTextCursor& virtualCursor);
84
85 bool tagLines (int start, int end, bool realLines = false);
86 bool tagLines (KateTextCursor start, KateTextCursor end, bool realCursors = false);
87
88 void tagAll ();
89
90 void clear ();
91 //END
92
93 private:
94 void updateView (bool changed = false, int viewLinesScrolled = 0);
95 void makeVisible (const KateTextCursor& c, uint endCol, bool force = false, bool center = false, bool calledExternally = false);
96
97 public:
98 inline const KateTextCursor& startPos() const { return m_startPos; }
99 inline uint startLine () const { return m_startPos.line(); }
100 inline uint startX () const { return m_startX; }
101
102 KateTextCursor endPos () const;
103 uint endLine () const;
104
105 KateLineRange yToKateLineRange(uint y) const;
106
107 void prepareForDynWrapChange();
108 void dynWrapChanged();
109
110 KateView *view () { return m_view; }
111
112 public slots:
113 void slotIncFontSizes();
114 void slotDecFontSizes();
115
116 private slots:
117 void scrollLines(int line); // connected to the sliderMoved of the m_lineScroll
118 void scrollViewLines(int offset);
119 void scrollNextPage();
120 void scrollPrevPage();
121 void scrollPrevLine();
122 void scrollNextLine();
123 void scrollColumns (int x); // connected to the valueChanged of the m_columnScroll
124 void viewSelectionChanged ();
125
126 public:
127 void doReturn();
128 void doDelete();
129 void doBackspace();
130 void doTranspose();
131 void doDeleteWordLeft();
132 void doDeleteWordRight();
133
134 void cursorLeft(bool sel=false);
135 void cursorRight(bool sel=false);
136 void wordLeft(bool sel=false);
137 void wordRight(bool sel=false);
138 void home(bool sel=false);
139 void end(bool sel=false);
140 void cursorUp(bool sel=false);
141 void cursorDown(bool sel=false);
142 void cursorToMatchingBracket(bool sel=false);
143 void scrollUp();
144 void scrollDown();
145 void topOfView(bool sel=false);
146 void bottomOfView(bool sel=false);
147 void pageUp(bool sel=false);
148 void pageDown(bool sel=false);
149 void top(bool sel=false);
150 void bottom(bool sel=false);
151 void top_home(bool sel=false);
152 void bottom_end(bool sel=false);
153
154 inline const KateTextCursor& getCursor() { return cursor; }
155 TQPoint cursorCoordinates();
156
157 void paintText (int x, int y, int width, int height, bool paintOnlyDirty = false);
158
159 // EVENT HANDLING STUFF - IMPORTANT
160 protected:
161 void paintEvent(TQPaintEvent *e);
162 bool eventFilter( TQObject *obj, TQEvent *e );
163 void keyPressEvent( TQKeyEvent* );
164 void keyReleaseEvent( TQKeyEvent* );
165 void resizeEvent( TQResizeEvent* );
166 void mousePressEvent( TQMouseEvent* );
167 void mouseDoubleClickEvent( TQMouseEvent* );
168 void mouseReleaseEvent( TQMouseEvent* );
169 void mouseMoveEvent( TQMouseEvent* );
170 void dragEnterEvent( TQDragEnterEvent* );
171 void dragMoveEvent( TQDragMoveEvent* );
172 void dropEvent( TQDropEvent* );
173 void showEvent ( TQShowEvent *);
174 void wheelEvent(TQWheelEvent* e);
175 void focusInEvent (TQFocusEvent *);
176 void focusOutEvent (TQFocusEvent *);
177
178 void contextMenuEvent ( TQContextMenuEvent * e );
179
180 private slots:
181 void tripleClickTimeout();
182
183 signals:
184 // emitted when KateViewInternal is not handling its own URI drops
185 void dropEventPass(TQDropEvent*);
186
187 private slots:
188 void slotRegionVisibilityChangedAt(unsigned int);
189 void slotRegionBeginEndAddedRemoved(unsigned int);
190 void slotCodeFoldingChanged();
191
192 private:
193 void moveChar( Bias bias, bool sel );
194 void moveEdge( Bias bias, bool sel );
195 KateTextCursor maxStartPos(bool changed = false);
196 void scrollPos(KateTextCursor& c, bool force = false, bool calledExternally = false);
197 void scrollLines( int lines, bool sel );
198
199 uint linesDisplayed() const;
200
201 int lineToY(uint viewLine) const;
202
203 void updateSelection( const KateTextCursor&, bool keepSel );
204 void updateCursor( const KateTextCursor& newCursor, bool force = false, bool center = false, bool calledExternally = false );
205 void updateBracketMarks();
206
207 void paintCursor();
208
209 void updateMicroFocusHint();
210
211 void placeCursor( const TQPoint& p, bool keepSelection = false, bool updateSelection = true );
212 bool isTargetSelected( const TQPoint& p );
213
214 void doDrag();
215
216 KateView *m_view;
217 KateDocument* m_doc;
218 class KateIconBorder *leftBorder;
219
220 int mouseX;
221 int mouseY;
222 int scrollX;
223 int scrollY;
224
225 TQt::CursorShape m_mouseCursor;
226
227 KateSuperCursor cursor;
228 KateTextCursor displayCursor;
229 int cXPos;
230
231 bool possibleTripleClick;
232
233 // Bracket mark
234 KateBracketRange bm;
235
236 enum DragState { diNone, diPending, diDragging };
237
238 struct _dragInfo {
239 DragState state;
240 TQPoint start;
241 TQTextDrag* dragObject;
242 } dragInfo;
243
244 uint iconBorderHeight;
245
246 //
247 // line scrollbar + first visible (virtual) line in the current view
248 //
249 KateScrollBar *m_lineScroll;
250 TQWidget* m_dummy;
251 TQVBoxLayout* m_lineLayout;
252 TQHBoxLayout* m_colLayout;
253
254 // These are now cursors to account for word-wrap.
255 KateSuperCursor m_startPos;
256
257 // This is set to false on resize or scroll (other than that called by makeVisible),
258 // so that makeVisible is again called when a key is pressed and the cursor is in the same spot
259 bool m_madeVisible;
260 bool m_shiftKeyPressed;
261
262 // How many lines to should be kept visible above/below the cursor when possible
263 void setAutoCenterLines(int viewLines, bool updateView = true);
264 int m_autoCenterLines;
265 int m_minLinesVisible;
266
267 //
268 // column scrollbar + x position
269 //
270 TQScrollBar *m_columnScroll;
271 int m_startX;
272
273 // has selection changed while your mouse or shift key is pressed
274 bool m_selChangedByUser;
275 KateTextCursor selectAnchor;
276
277 enum SelectionMode { Default=0, Word, Line, Mouse };
278 uint m_selectionMode;
279 // when drag selecting after double/triple click, keep the initial selected
280 // word/line independant of direction.
281 // They get set in the event of a double click, and is used with mouse move + leftbutton
282 KateTextCursor selStartCached;
283 KateTextCursor selEndCached;
284
285 //
286 // lines Ranges, mostly useful to speedup + dyn. word wrap
287 //
288 TQMemArray<KateLineRange> lineRanges;
289
290 // maximal length of textlines visible from given startLine
291 int maxLen(uint startLine);
292
293 // are we allowed to scroll columns?
294 bool columnScrollingPossible ();
295
296 // returns the maximum X value / col value a cursor can take for a specific line range
297 int lineMaxCursorX(const KateLineRange& range);
298 int lineMaxCol(const KateLineRange& range);
299
300 // get the values for a specific range.
301 // specify lastLine to get the next line of a range.
302 KateLineRange range(int realLine, const KateLineRange* previous = 0L);
303
304 KateLineRange currentRange();
305 KateLineRange previousRange();
306 KateLineRange nextRange();
307
308 // Finds the lineRange currently occupied by the cursor.
309 KateLineRange range(const KateTextCursor& realCursor);
310
311 // Returns the lineRange of the specified realLine + viewLine.
312 KateLineRange range(uint realLine, int viewLine);
313
314 // find the view line of cursor c (0 = same line, 1 = down one, etc.)
315 uint viewLine(const KateTextCursor& realCursor);
316
317 // find the view line of the cursor, relative to the display (0 = top line of view, 1 = second line, etc.)
318 // if limitToVisible is true, only lines which are currently visible will be searched for, and -1 returned if the line is not visible.
319 int displayViewLine(const KateTextCursor& virtualCursor, bool limitToVisible = false);
320
321 // find the index of the last view line for a specific line
322 uint lastViewLine(uint realLine);
323
324 // count the number of view lines for a real line
325 uint viewLineCount(uint realLine);
326
327 // find the cursor offset by (offset) view lines from a cursor.
328 // when keepX is true, the column position will be calculated based on the x
329 // position of the specified cursor.
330 KateTextCursor viewLineOffset(const KateTextCursor& virtualCursor, int offset, bool keepX = false);
331
332 // These variable holds the most recent maximum real & visible column number
333 bool m_preserveMaxX;
334 int m_currentMaxX;
335
336 bool m_usePlainLines; // accept non-highlighted lines if this is set
337
338 inline KateTextLine::Ptr textLine( int realLine )
339 {
340 if (m_usePlainLines)
341 return m_doc->plainKateTextLine(realLine);
342 else
343 return m_doc->kateTextLine(realLine);
344 }
345
346 bool m_updatingView;
347 int m_wrapChangeViewLine;
348 KateTextCursor m_cachedMaxStartPos;
349
350 private slots:
351 void doDragScroll();
352 void startDragScroll();
353 void stopDragScroll();
354
355 private:
356 // Timers
357 TQTimer m_dragScrollTimer;
358 TQTimer m_scrollTimer;
359 TQTimer m_cursorTimer;
360 TQTimer m_textHintTimer;
361
362 static const int scrollTime = 30;
363 static const int scrollMargin = 16;
364
365 private slots:
366 void scrollTimeout ();
367 void cursorTimeout ();
368 void textHintTimeout ();
369
370 //TextHint
371 public:
372 void enableTextHints(int timeout);
373 void disableTextHints();
374
375 private:
376 bool m_textHintEnabled;
377 int m_textHintTimeout;
378 int m_textHintMouseX;
379 int m_textHintMouseY;
380
384 protected:
385 void imStartEvent( TQIMEvent *e );
386 void imComposeEvent( TQIMEvent *e );
387 void imEndEvent( TQIMEvent *e );
388
389 private:
390 int m_imPreeditStartLine;
391 int m_imPreeditStart;
392 int m_imPreeditLength;
393 int m_imPreeditSelStart;
394};
395
396#endif
KateScrollBar
This class is required because QScrollBar's sliderMoved() signal is really supposed to be a sliderDra...
Definition: kateviewhelpers.h:49
KateSuperCursor
Possible additional features:
Definition: katesupercursor.h:46
KateTextCursor
Simple cursor class with no document pointer.
Definition: katecursor.h:34
TDESharedPtr
KStdAction::clear
TDEAction * clear(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEStdAccel::end
const TDEShortcut & end()
TDEStdAccel::home
const TDEShortcut & home()

kate

Skip menu "kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kate

Skip menu "kate"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kate by doxygen 1.9.4
This website is maintained by Timothy Pearson.