00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef kate_view_h
00023 #define kate_view_h
00024
00025 #include "katedocument.h"
00026 #include "kateviewinternal.h"
00027 #include "kateconfig.h"
00028
00029 #include "../interfaces/view.h"
00030
00031 #include <ktexteditor/sessionconfiginterface.h>
00032 #include <ktexteditor/viewstatusmsginterface.h>
00033 #include <ktexteditor/texthintinterface.h>
00034
00035 #include <qguardedptr.h>
00036
00037 class KateDocument;
00038 class KateBookmarks;
00039 class KateSearch;
00040 class KateCmdLine;
00041 class KateCodeCompletion;
00042 class KateViewConfig;
00043 class KateViewSchemaAction;
00044 class KateRenderer;
00045 class KateSpell;
00046
00047 class KToggleAction;
00048 class KAction;
00049 class KRecentFilesAction;
00050 class KSelectAction;
00051
00052 class QGridLayout;
00053
00054
00055
00056
00057 class KateView : public Kate::View,
00058 public KTextEditor::SessionConfigInterface,
00059 public KTextEditor::ViewStatusMsgInterface,
00060 public KTextEditor::TextHintInterface,
00061 public KTextEditor::SelectionInterface,
00062 public KTextEditor::SelectionInterfaceExt,
00063 public KTextEditor::BlockSelectionInterface
00064 {
00065 Q_OBJECT
00066
00067 friend class KateViewInternal;
00068 friend class KateIconBorder;
00069 friend class KateCodeCompletion;
00070
00071 public:
00072 KateView( KateDocument* doc, QWidget* parent = 0L, const char* name = 0 );
00073 ~KateView ();
00074
00075
00076
00077
00078 public:
00079 KTextEditor::Document* document() const { return m_doc; }
00080
00081
00082
00083
00084 public slots:
00085
00086 void paste();
00087 void cut();
00088 void copy() const;
00089
00093 void copyHTML();
00094
00095
00096 private:
00097 QString selectionAsHtml ();
00098 QString textAsHtml ( uint startLine, uint startCol, uint endLine, uint endCol, bool blockwise);
00099 void textAsHtmlStream ( uint startLine, uint startCol, uint endLine, uint endCol, bool blockwise, QTextStream *ts);
00100
00113 void lineAsHTML (KateTextLine::Ptr line, uint startCol, uint length, QTextStream *outputStream);
00114
00115 public slots:
00116 void exportAsHTML ();
00117
00118
00119
00120
00121 public:
00122 void installPopup( QPopupMenu* menu ) { m_rmbMenu = menu; }
00123 QPopupMenu* popup() const { return m_rmbMenu; }
00124
00125
00126
00127
00128 public slots:
00129 QPoint cursorCoordinates()
00130 { return m_viewInternal->cursorCoordinates(); }
00131 void cursorPosition( uint* l, uint* c )
00132 { if( l ) *l = cursorLine(); if( c ) *c = cursorColumn(); }
00133 void cursorPositionReal( uint* l, uint* c )
00134 { if( l ) *l = cursorLine(); if( c ) *c = cursorColumnReal(); }
00135 bool setCursorPosition( uint line, uint col )
00136 { return setCursorPositionInternal( line, col, tabWidth(), true ); }
00137 bool setCursorPositionReal( uint line, uint col)
00138 { return setCursorPositionInternal( line, col, 1, true ); }
00139 uint cursorLine()
00140 { return m_viewInternal->getCursor().line(); }
00141 uint cursorColumn();
00142 uint cursorColumnReal()
00143 { return m_viewInternal->getCursor().col(); }
00144
00145 signals:
00146 void cursorPositionChanged();
00147
00148
00149
00150
00151 public slots:
00152 void showArgHint( QStringList arg1, const QString& arg2, const QString& arg3 );
00153 void showCompletionBox( QValueList<KTextEditor::CompletionEntry> arg1, int offset = 0, bool cs = true );
00154
00155 signals:
00156 void completionAborted();
00157 void completionDone();
00158 void argHintHidden();
00159 void completionDone(KTextEditor::CompletionEntry);
00160 void filterInsertString(KTextEditor::CompletionEntry*,QString *);
00161 void aboutToShowCompletionBox();
00162
00163
00164
00165
00166 public:
00167 void enableTextHints(int timeout);
00168 void disableTextHints();
00169
00170 signals:
00171 void needTextHint(int line, int col, QString &text);
00172
00173
00174
00175
00176 public:
00177 void setDynWordWrap( bool b );
00178 bool dynWordWrap() const { return m_hasWrap; }
00179
00180
00181
00182
00183 public slots:
00184 bool setSelection ( const KateTextCursor & start,
00185 const KateTextCursor & end );
00186 bool setSelection ( uint startLine, uint startCol,
00187 uint endLine, uint endCol );
00188 bool clearSelection ();
00189 bool clearSelection (bool redraw, bool finishedChangingSelection = true);
00190
00191 bool hasSelection () const;
00192 QString selection () const ;
00193
00194 bool removeSelectedText ();
00195
00196 bool selectAll();
00197
00198
00199
00200
00201 int selStartLine() { return selectStart.line(); };
00202 int selStartCol() { return selectStart.col(); };
00203 int selEndLine() { return selectEnd.line(); };
00204 int selEndCol() { return selectEnd.col(); };
00205
00206 signals:
00207 void selectionChanged ();
00208
00209
00210
00211
00212 public:
00217 inline const KateSuperCursor &selStart () const { return selectStart; }
00218
00223 inline const KateSuperCursor &selEnd () const { return selectEnd; }
00224
00225
00226 bool wrapCursor ();
00227
00228
00229 bool lineColSelected (int line, int col);
00230 bool lineSelected (int line);
00231 bool lineEndSelected (int line, int endCol);
00232 bool lineHasSelected (int line);
00233 bool lineIsSelection (int line);
00234
00235 void tagSelection (const KateTextCursor &oldSelectStart, const KateTextCursor &oldSelectEnd);
00236
00237 void selectWord( const KateTextCursor& cursor );
00238 void selectLine( const KateTextCursor& cursor );
00239 void selectLength( const KateTextCursor& cursor, int length );
00240
00241
00242
00243 void syncSelectionCache();
00244
00245
00246
00247
00248 public slots:
00249 bool blockSelectionMode ();
00250 bool setBlockSelectionMode (bool on);
00251 bool toggleBlockSelectionMode ();
00252
00253
00254
00255 public:
00256 void editStart ();
00257 void editEnd (int editTagLineStart, int editTagLineEnd, bool tagFrom);
00258
00259 void editSetCursor (const KateTextCursor &cursor);
00260
00261
00262
00263 public:
00264 bool tagLine (const KateTextCursor& virtualCursor);
00265
00266 bool tagLines (int start, int end, bool realLines = false );
00267 bool tagLines (KateTextCursor start, KateTextCursor end, bool realCursors = false);
00268
00269 void tagAll ();
00270
00271 void clear ();
00272
00273 void repaintText (bool paintOnlyDirty = false);
00274
00275 void updateView (bool changed = false);
00276
00277
00278
00279
00280
00281 public:
00282 bool isOverwriteMode() const;
00283 void setOverwriteMode( bool b );
00284
00285 QString currentTextLine()
00286 { return getDoc()->textLine( cursorLine() ); }
00287 QString currentWord()
00288 { return m_doc->getWord( m_viewInternal->getCursor() ); }
00289 void insertText( const QString& mark )
00290 { getDoc()->insertText( cursorLine(), cursorColumnReal(), mark ); }
00291 bool canDiscard();
00292 int tabWidth() { return m_doc->config()->tabWidth(); }
00293 void setTabWidth( int w ) { m_doc->config()->setTabWidth(w); }
00294 void setEncoding( QString e ) { m_doc->setEncoding(e); }
00295 bool isLastView() { return m_doc->isLastView(1); }
00296
00297 public slots:
00298 void flush();
00299 saveResult save();
00300 saveResult saveAs();
00301
00302 void indent() { m_doc->indent( this, cursorLine(), 1 ); }
00303 void unIndent() { m_doc->indent( this, cursorLine(), -1 ); }
00304 void cleanIndent() { m_doc->indent( this, cursorLine(), 0 ); }
00305 void align() { m_doc->align( this, cursorLine() ); }
00306 void comment() { m_doc->comment( this, cursorLine(), cursorColumnReal(), 1 ); }
00307 void uncomment() { m_doc->comment( this, cursorLine(), cursorColumnReal(),-1 ); }
00308 void killLine() { m_doc->removeLine( cursorLine() ); }
00309
00313 void uppercase() { m_doc->transform( this, m_viewInternal->cursor, KateDocument::Uppercase ); }
00317 void lowercase() { m_doc->transform( this, m_viewInternal->cursor, KateDocument::Lowercase ); }
00322 void capitalize() { m_doc->transform( this, m_viewInternal->cursor, KateDocument::Capitalize ); }
00326 void joinLines();
00327
00328
00329 void keyReturn() { m_viewInternal->doReturn(); }
00330 void backspace() { m_viewInternal->doBackspace(); }
00331 void deleteWordLeft() { m_viewInternal->doDeleteWordLeft(); }
00332 void keyDelete() { m_viewInternal->doDelete(); }
00333 void deleteWordRight() { m_viewInternal->doDeleteWordRight(); }
00334 void transpose() { m_viewInternal->doTranspose(); }
00335 void cursorLeft() { m_viewInternal->cursorLeft(); }
00336 void shiftCursorLeft() { m_viewInternal->cursorLeft(true); }
00337 void cursorRight() { m_viewInternal->cursorRight(); }
00338 void shiftCursorRight() { m_viewInternal->cursorRight(true); }
00339 void wordLeft() { m_viewInternal->wordLeft(); }
00340 void shiftWordLeft() { m_viewInternal->wordLeft(true); }
00341 void wordRight() { m_viewInternal->wordRight(); }
00342 void shiftWordRight() { m_viewInternal->wordRight(true); }
00343 void home() { m_viewInternal->home(); }
00344 void shiftHome() { m_viewInternal->home(true); }
00345 void end() { m_viewInternal->end(); }
00346 void shiftEnd() { m_viewInternal->end(true); }
00347 void up() { m_viewInternal->cursorUp(); }
00348 void shiftUp() { m_viewInternal->cursorUp(true); }
00349 void down() { m_viewInternal->cursorDown(); }
00350 void shiftDown() { m_viewInternal->cursorDown(true); }
00351 void scrollUp() { m_viewInternal->scrollUp(); }
00352 void scrollDown() { m_viewInternal->scrollDown(); }
00353 void topOfView() { m_viewInternal->topOfView(); }
00354 void shiftTopOfView() { m_viewInternal->topOfView(true); }
00355 void bottomOfView() { m_viewInternal->bottomOfView(); }
00356 void shiftBottomOfView() { m_viewInternal->bottomOfView(true); }
00357 void pageUp() { m_viewInternal->pageUp(); }
00358 void shiftPageUp() { m_viewInternal->pageUp(true); }
00359 void pageDown() { m_viewInternal->pageDown(); }
00360 void shiftPageDown() { m_viewInternal->pageDown(true); }
00361 void top() { m_viewInternal->top_home(); }
00362 void shiftTop() { m_viewInternal->top_home(true); }
00363 void bottom() { m_viewInternal->bottom_end(); }
00364 void shiftBottom() { m_viewInternal->bottom_end(true); }
00365 void toMatchingBracket() { m_viewInternal->cursorToMatchingBracket();}
00366 void shiftToMatchingBracket() { m_viewInternal->cursorToMatchingBracket(true);}
00367
00368 void gotoLine();
00369 void gotoLineNumber( int linenumber );
00370
00371
00372 public:
00373 void readSessionConfig(KConfig *);
00374 void writeSessionConfig(KConfig *);
00375
00376 public slots:
00377 int getEol();
00378 void setEol( int eol );
00379 void find();
00380 void find( const QString&, long, bool add=true );
00381 void replace();
00382 void replace( const QString&, const QString &, long );
00383
00384 void findAgain( bool back );
00385 void findAgain() { findAgain( false ); }
00386 void findPrev() { findAgain( true ); }
00387
00388 void setFoldingMarkersOn( bool enable );
00389 void setIconBorder( bool enable );
00390 void setLineNumbersOn( bool enable );
00391 void setScrollBarMarks( bool enable );
00392 void showCmdLine ( bool enable );
00393 void toggleFoldingMarkers();
00394 void toggleIconBorder();
00395 void toggleLineNumbersOn();
00396 void toggleScrollBarMarks();
00397 void toggleDynWordWrap ();
00398 void toggleCmdLine ();
00399 void setDynWrapIndicators(int mode);
00400
00401 void applyWordWrap ();
00402
00403 public:
00404 KateRenderer *renderer ();
00405
00406 bool iconBorder();
00407 bool lineNumbersOn();
00408 bool scrollBarMarks();
00409 int dynWrapIndicators();
00410 bool foldingMarkersOn();
00411 Kate::Document* getDoc() { return m_doc; }
00412
00413 void setActive( bool b ) { m_active = b; }
00414 bool isActive() { return m_active; }
00415
00416 public slots:
00417 void gotoMark( KTextEditor::Mark* mark ) { setCursorPositionInternal ( mark->line, 0, 1 ); }
00418 void slotSelectionChanged ();
00419
00420 signals:
00421 void gotFocus( Kate::View* );
00422 void lostFocus( Kate::View* );
00423 void newStatus();
00424
00425
00426
00427
00428 public:
00429
00430 KateDocument* doc() const { return m_doc; }
00431
00432 KActionCollection* editActionCollection() const { return m_editActions; }
00433
00434 public slots:
00435 void slotNewUndo();
00436 void slotUpdate();
00437 void toggleInsert();
00438 void reloadFile();
00439 void toggleWWMarker();
00440 void toggleWriteLock();
00441 void switchToCmdLine ();
00442 void slotReadWriteChanged ();
00443
00444 signals:
00445 void dropEventPass(QDropEvent*);
00446 void viewStatusMsg (const QString &msg);
00447
00448 public:
00449 bool setCursorPositionInternal( uint line, uint col, uint tabwidth = 1, bool calledExternally = false );
00450
00451 protected:
00452 void contextMenuEvent( QContextMenuEvent* );
00453 bool checkOverwrite( KURL );
00454
00455 public slots:
00456 void slotSelectionTypeChanged();
00457
00458 private slots:
00459 void slotGotFocus();
00460 void slotLostFocus();
00461 void slotDropEventPass( QDropEvent* ev );
00462 void slotStatusMsg();
00463 void slotSaveCanceled( const QString& error );
00464 void slotExpandToplevel();
00465 void slotCollapseLocal();
00466 void slotExpandLocal();
00467
00468 private:
00469 void setupConnections();
00470 void setupActions();
00471 void setupEditActions();
00472 void setupCodeFolding();
00473 void setupCodeCompletion();
00474
00475 KActionCollection* m_editActions;
00476 KAction* m_editUndo;
00477 KAction* m_editRedo;
00478 KRecentFilesAction* m_fileRecent;
00479 KToggleAction* m_toggleFoldingMarkers;
00480 KToggleAction* m_toggleIconBar;
00481 KToggleAction* m_toggleLineNumbers;
00482 KToggleAction* m_toggleScrollBarMarks;
00483 KToggleAction* m_toggleDynWrap;
00484 KSelectAction* m_setDynWrapIndicators;
00485 KToggleAction* m_toggleWWMarker;
00486 KAction* m_switchCmdLine;
00487
00488 KSelectAction* m_setEndOfLine;
00489
00490 KAction *m_cut;
00491 KAction *m_copy;
00492 KAction *m_copyHTML;
00493 KAction *m_paste;
00494 KAction *m_selectAll;
00495 KAction *m_deSelect;
00496
00497 KToggleAction *m_toggleBlockSelection;
00498 KToggleAction *m_toggleInsert;
00499 KToggleAction *m_toggleWriteLock;
00500
00501 KateDocument* m_doc;
00502 KateViewInternal* m_viewInternal;
00503 KateRenderer* m_renderer;
00504 KateSearch* m_search;
00505 KateSpell *m_spell;
00506 KateBookmarks* m_bookmarks;
00507 QGuardedPtr<QPopupMenu> m_rmbMenu;
00508 KateCodeCompletion* m_codeCompletion;
00509
00510 KateCmdLine *m_cmdLine;
00511 bool m_cmdLineOn;
00512
00513 QGridLayout *m_grid;
00514
00515 bool m_active;
00516 bool m_hasWrap;
00517
00518 private slots:
00519 void slotNeedTextHint(int line, int col, QString &text);
00520 void slotHlChanged();
00521
00525 public:
00526 inline KateViewConfig *config () { return m_config; };
00527
00528 void updateConfig ();
00529
00530 void updateDocumentConfig();
00531
00532 void updateRendererConfig();
00533
00534 private slots:
00535 void updateFoldingConfig ();
00536
00537 private:
00538 KateViewConfig *m_config;
00539 bool m_startingUp;
00540 bool m_updatingDocumentConfig;
00541
00542 private:
00543
00544 KateSuperCursor selectStart;
00545 KateSuperCursor selectEnd;
00546
00547
00548 bool blockSelect;
00549
00553 public:
00554 void setIMSelectionValue( uint imStartLine, uint imStart, uint imEnd,
00555 uint imSelStart, uint imSelEnd, bool m_imComposeEvent );
00556 void getIMSelectionValue( uint *imStartLine, uint *imStart, uint *imEnd,
00557 uint *imSelStart, uint *imSelEnd );
00558 bool isIMSelection( int _line, int _column );
00559 bool isIMEdit( int _line, int _column );
00560 bool imComposeEvent () const { return m_imComposeEvent; }
00561
00562 private:
00563 uint m_imStartLine;
00564 uint m_imStart;
00565 uint m_imEnd;
00566 uint m_imSelStart;
00567 uint m_imSelEnd;
00568 bool m_imComposeEvent;
00569 };
00570
00571 #endif