kate Library: kateview.h Source File (kate Library)

| # kate Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kateview.h

    00001 /* This file is part of the KDE libraries
    00002    Copyright (C) 2002 John Firebaugh <jfirebaugh@kde.org>
    00003    Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
    00004    Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
    00005    Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
    00006
    00007    This library is free software; you can redistribute it and/or
    00008    modify it under the terms of the GNU Library General Public
    00009    License version 2 as published by the Free Software Foundation.
    00010
    00011    This library is distributed in the hope that it will be useful,
    00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014    Library General Public License for more details.
    00015
    00016    You should have received a copy of the GNU Library General Public License
    00017    along with this library; see the file COPYING.LIB.  If not, write to
    00018    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00019    Boston, MA 02111-1307, USA.
    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
    00046 class KToggleAction;
    00047 class KAction;
    00048 class KRecentFilesAction;
    00049 class KSelectAction;
    00050
    00051 class QGridLayout;
    00052
    00053 //
    00054 // Kate KTextEditor::View class ;)
    00055 //
    00056 class KateView : public Kate::View,
    00057                  public KTextEditor::SessionConfigInterface,
    00058                  public KTextEditor::ViewStatusMsgInterface,
    00059                  public KTextEditor::TextHintInterface
    00060 {
    00061     Q_OBJECT
    00062
    00063     friend class KateViewInternal;
    00064     friend class KateIconBorder;
    00065     friend class KateCodeCompletion;
    00066
    00067   public:
    00068     KateView( KateDocument* doc, QWidget* parent = 0L, const char* name = 0 );
    00069     ~KateView ();
    00070
    00071   //
    00072   // KTextEditor::View
    00073   //
    00074   public:
    00075     KTextEditor::Document* document() const       { return m_doc; }
    00076
    00077   //
    00078   // KTextEditor::ClipboardInterface
    00079   //
    00080   public slots:
    00081     void cut()           { m_doc->cut(); m_viewInternal->repaint(); }
    00082     void copy() const    { m_doc->copy();   }
    00083     // TODO: Factor out of m_viewInternal
    00084     void paste()         { m_viewInternal->doPaste(); m_viewInternal->repaint(); }
    00085
    00086   //
    00087   // KTextEditor::PopupMenuInterface
    00088   //
    00089   public:
    00090     void installPopup( QPopupMenu* menu ) { m_rmbMenu = menu; }
    00091     QPopupMenu* popup() const             { return m_rmbMenu; }
    00092
    00093   //
    00094   // KTextEditor::ViewCursorInterface
    00095   //
    00096   public slots:
    00097     QPoint cursorCoordinates()
    00098         { return m_viewInternal->cursorCoordinates();                 }
    00099     void cursorPosition( uint* l, uint* c )
    00100         { if( l ) *l = cursorLine(); if( c ) *c = cursorColumn();     }
    00101     void cursorPositionReal( uint* l, uint* c )
    00102         { if( l ) *l = cursorLine(); if( c ) *c = cursorColumnReal(); }
    00103     bool setCursorPosition( uint line, uint col )
    00104         { return setCursorPositionInternal( line, col, tabWidth(), true );  }
    00105     bool setCursorPositionReal( uint line, uint col)
    00106         { return setCursorPositionInternal( line, col, 1, true );           }
    00107     uint cursorLine()
    00108         { return m_viewInternal->getCursor().line();                    }
    00109     uint cursorColumn();
    00110     uint cursorColumnReal()
    00111         { return m_viewInternal->getCursor().col();                     }
    00112
    00113   signals:
    00114     void cursorPositionChanged();
    00115
    00116   //
    00117   // KTextEditor::CodeCompletionInterface
    00118   //
    00119   public slots:
    00120     void showArgHint( QStringList arg1, const QString& arg2, const QString& arg3 );
    00121     void showCompletionBox( QValueList<KTextEditor::CompletionEntry> arg1, int offset = 0, bool cs = true );
    00122
    00123   signals:
    00124     void completionAborted();
    00125     void completionDone();
    00126     void argHintHidden();
    00127     void completionDone(KTextEditor::CompletionEntry);
    00128     void filterInsertString(KTextEditor::CompletionEntry*,QString *);
    00129     void aboutToShowCompletionBox();
    00130
    00131   //
    00132   // KTextEditor::TextHintInterface
    00133   //
    00134   public:
    00135     void enableTextHints(int timeout);
    00136     void disableTextHints();
    00137
    00138   signals:
    00139     void needTextHint(int line, int col, QString &text);
    00140
    00141   //
    00142   // KTextEditor::DynWordWrapInterface
    00143   //
    00144   public:
    00145     void setDynWordWrap( bool b );
    00146     bool dynWordWrap() const      { return m_hasWrap; }
    00147
    00148   //BEGIN EDIT STUFF
    00149   public:
    00150     void editStart ();
    00151     void editEnd (int editTagLineStart, int editTagLineEnd, bool tagFrom);
    00152
    00153     void editSetCursor (const KateTextCursor &cursor);
    00154   //END
    00155
    00156   //BEGIN TAG & CLEAR
    00157   public:
    00158     bool tagLine (const KateTextCursor& virtualCursor);
    00159
    00160     bool tagLines (int start, int end, bool realLines = false );
    00161     bool tagLines (KateTextCursor start, KateTextCursor end, bool realCursors = false);
    00162
    00163     void tagAll ();
    00164
    00165     void clear ();
    00166
    00167     void repaintText (bool paintOnlyDirty = false);
    00168
    00169     void updateView (bool changed = false);
    00170   //END
    00171
    00172   //
    00173   // Kate::View
    00174   //
    00175   public:
    00176     bool isOverwriteMode() const;
    00177     void setOverwriteMode( bool b );
    00178
    00179     QString currentTextLine()
    00180         { return getDoc()->textLine( cursorLine() ); }
    00181     QString currentWord()
    00182         { return m_doc->getWord( m_viewInternal->getCursor() ); }
    00183     void insertText( const QString& text )
    00184         { getDoc()->insertText( cursorLine(), cursorColumnReal(), text ); }
    00185     bool canDiscard();
    00186     int tabWidth()                { return m_doc->config()->tabWidth(); }
    00187     void setTabWidth( int w )     { m_doc->config()->setTabWidth(w);  }
    00188     void setEncoding( QString e ) { m_doc->setEncoding(e);       }
    00189     bool isLastView()             { return m_doc->isLastView(1); }
    00190
    00191   public slots:
    00192     void flush();
    00193     saveResult save();
    00194     saveResult saveAs();
    00195
    00196     void indent()             { m_doc->indent( this, cursorLine(), 1 );  }
    00197     void unIndent()           { m_doc->indent( this, cursorLine(), -1 ); }
    00198     void cleanIndent()        { m_doc->indent( this, cursorLine(), 0 );  }
    00199     void align()              { m_doc->align( cursorLine() ); }
    00200     void comment()            { m_doc->comment( this, cursorLine(), cursorColumnReal(), 1 );  }
    00201     void uncomment()          { m_doc->comment( this, cursorLine(), cursorColumnReal(),-1 ); }
    00202     void killLine()           { m_doc->removeLine( cursorLine() ); }
    00203
    00207     void uppercase() { m_doc->transform( this, m_viewInternal->cursor, KateDocument::Uppercase ); }
    00211     void lowercase() { m_doc->transform( this, m_viewInternal->cursor, KateDocument::Lowercase ); }
    00216     void capitalize() { m_doc->transform( this, m_viewInternal->cursor, KateDocument::Capitalize ); }
    00220     void joinLines();
    00221
    00222
    00223     void keyReturn()          { m_viewInternal->doReturn();          }
    00224     void backspace()          { m_viewInternal->doBackspace();       }
    00225     void deleteWordLeft()     { m_viewInternal->doDeleteWordLeft();  }
    00226     void keyDelete()          { m_viewInternal->doDelete();          }
    00227     void deleteWordRight()    { m_viewInternal->doDeleteWordRight(); }
    00228     void transpose()          { m_viewInternal->doTranspose();       }
    00229     void cursorLeft()         { m_viewInternal->cursorLeft();        }
    00230     void shiftCursorLeft()    { m_viewInternal->cursorLeft(true);    }
    00231     void cursorRight()        { m_viewInternal->cursorRight();       }
    00232     void shiftCursorRight()   { m_viewInternal->cursorRight(true);   }
    00233     void wordLeft()           { m_viewInternal->wordLeft();          }
    00234     void shiftWordLeft()      { m_viewInternal->wordLeft(true);      }
    00235     void wordRight()          { m_viewInternal->wordRight();         }
    00236     void shiftWordRight()     { m_viewInternal->wordRight(true);     }
    00237     void home()               { m_viewInternal->home();              }
    00238     void shiftHome()          { m_viewInternal->home(true);          }
    00239     void end()                { m_viewInternal->end();               }
    00240     void shiftEnd()           { m_viewInternal->end(true);           }
    00241     void up()                 { m_viewInternal->cursorUp();          }
    00242     void shiftUp()            { m_viewInternal->cursorUp(true);      }
    00243     void down()               { m_viewInternal->cursorDown();        }
    00244     void shiftDown()          { m_viewInternal->cursorDown(true);    }
    00245     void scrollUp()           { m_viewInternal->scrollUp();          }
    00246     void scrollDown()         { m_viewInternal->scrollDown();        }
    00247     void topOfView()          { m_viewInternal->topOfView();         }
    00248     void shiftTopOfView()     { m_viewInternal->topOfView(true);     }
    00249     void bottomOfView()       { m_viewInternal->bottomOfView();      }
    00250     void shiftBottomOfView()  { m_viewInternal->bottomOfView(true);  }
    00251     void pageUp()             { m_viewInternal->pageUp();            }
    00252     void shiftPageUp()        { m_viewInternal->pageUp(true);        }
    00253     void pageDown()           { m_viewInternal->pageDown();          }
    00254     void shiftPageDown()      { m_viewInternal->pageDown(true);      }
    00255     void top()                { m_viewInternal->top_home();          }
    00256     void shiftTop()           { m_viewInternal->top_home(true);      }
    00257     void bottom()             { m_viewInternal->bottom_end();        }
    00258     void shiftBottom()        { m_viewInternal->bottom_end(true);    }
    00259     void toMatchingBracket()  { m_viewInternal->cursorToMatchingBracket();}
    00260     void shiftToMatchingBracket()  { m_viewInternal->cursorToMatchingBracket(true);}
    00261
    00262     void gotoLine();
    00263     void gotoLineNumber( int linenumber );
    00264
    00265   // config file / session management functions
    00266   public:
    00267     void readSessionConfig(KConfig *);
    00268     void writeSessionConfig(KConfig *);
    00269
    00270   public slots:
    00271     int getEol();
    00272     void setEol( int eol );
    00273     void find();
    00274     void find( const QString&, long, bool add=true );
    00275     void replace();
    00276     void replace( const QString&, const QString &, long );
    00277     void findAgain( bool back );
    00278     void findAgain()              { findAgain( false );          }
    00279     void findPrev()               { findAgain( true );           }
    00280
    00281     void setFoldingMarkersOn( bool enable ); // Not in Kate::View, but should be
    00282     void setIconBorder( bool enable );
    00283     void setLineNumbersOn( bool enable );
    00284     void setScrollBarMarks( bool enable );
    00285     void showCmdLine ( bool enable );
    00286     void toggleFoldingMarkers();
    00287     void toggleIconBorder();
    00288     void toggleLineNumbersOn();
    00289     void toggleScrollBarMarks();
    00290     void toggleDynWordWrap ();
    00291     void toggleCmdLine ();
    00292     void setDynWrapIndicators(int mode);
    00293
    00294   public:
    00295     KateRenderer *renderer ();
    00296
    00297     bool iconBorder();
    00298     bool lineNumbersOn();
    00299     bool scrollBarMarks();
    00300     int dynWrapIndicators();
    00301     bool foldingMarkersOn();
    00302     Kate::Document* getDoc()    { return m_doc; }
    00303
    00304     void setActive( bool b )    { m_active = b; }
    00305     bool isActive()             { return m_active; }
    00306
    00307   public slots:
    00308     void gotoMark( KTextEditor::Mark* mark ) { setCursorPositionInternal ( mark->line, 0, 1 ); }
    00309     void selectionChanged ();
    00310
    00311   signals:
    00312     void gotFocus( Kate::View* );
    00313     void lostFocus( Kate::View* );
    00314     void newStatus(); // Not in Kate::View, but should be (Kate app connects to it)
    00315
    00316   //
    00317   // Extras
    00318   //
    00319   public:
    00320     // Is it really necessary to have 3 methods for this?! :)
    00321     KateDocument*  doc() const       { return m_doc; }
    00322
    00323     KActionCollection* editActionCollection() const { return m_editActions; }
    00324
    00325   public slots:
    00326     void slotNewUndo();
    00327     void slotUpdate();
    00328     void toggleInsert();
    00329     void reloadFile();
    00330     void toggleWWMarker();
    00331     void toggleWriteLock();
    00332     void switchToCmdLine ();
    00333     void slotReadWriteChanged ();
    00334
    00335   signals:
    00336     void dropEventPass(QDropEvent*);
    00337     void viewStatusMsg (const QString &msg);
    00338
    00339   public:
    00340     bool setCursorPositionInternal( uint line, uint col, uint tabwidth = 1, bool calledExternally = false );
    00341
    00342   protected:
    00343     void contextMenuEvent( QContextMenuEvent* );
    00344     bool checkOverwrite( KURL );
    00345
    00346   public slots:
    00347     void slotSelectionTypeChanged();
    00348
    00349   private slots:
    00350     void slotGotFocus();
    00351     void slotLostFocus();
    00352     void slotDropEventPass( QDropEvent* ev );
    00353     void slotStatusMsg();
    00354     void slotSaveCanceled( const QString& error );
    00355     void slotExpandToplevel();
    00356     void slotCollapseLocal();
    00357     void slotExpandLocal();
    00358
    00359   private:
    00360     void setupConnections();
    00361     void setupActions();
    00362     void setupEditActions();
    00363     void setupCodeFolding();
    00364     void setupCodeCompletion();
    00365
    00366     KActionCollection*     m_editActions;
    00367     KAction*               m_editUndo;
    00368     KAction*               m_editRedo;
    00369     KRecentFilesAction*    m_fileRecent;
    00370     KToggleAction*         m_toggleFoldingMarkers;
    00371     KToggleAction*         m_toggleIconBar;
    00372     KToggleAction*         m_toggleLineNumbers;
    00373     KToggleAction*         m_toggleScrollBarMarks;
    00374     KToggleAction*         m_toggleDynWrap;
    00375     KSelectAction*         m_setDynWrapIndicators;
    00376     KToggleAction*         m_toggleWWMarker;
    00377     KAction*               m_switchCmdLine;
    00378     KAction*               m_spellcheckSelection;
    00379
    00380     KSelectAction*         m_setEndOfLine;
    00381
    00382     Kate::ActionMenu*      m_setHighlight;
    00383     Kate::ActionMenu*      m_setFileType;
    00384     KToggleAction*         m_toggleWriteLock;
    00385     KateViewSchemaAction*  m_schemaMenu;
    00386
    00387     KAction *m_cut;
    00388     KAction *m_copy;
    00389     KAction *m_paste;
    00390     KAction *m_selectAll;
    00391     KAction *m_deSelect;
    00392
    00393     KToggleAction *m_toggleBlockSelection;
    00394     KToggleAction *m_toggleInsert;
    00395
    00396     KateDocument*          m_doc;
    00397     KateViewInternal*      m_viewInternal;
    00398     KateRenderer*          m_renderer;
    00399     KateSearch*            m_search;
    00400     KateBookmarks*         m_bookmarks;
    00401     QGuardedPtr<QPopupMenu>  m_rmbMenu;
    00402     KateCodeCompletion*    m_codeCompletion;
    00403
    00404     KateCmdLine *m_cmdLine;
    00405     bool m_cmdLineOn;
    00406
    00407     QGridLayout *m_grid;
    00408
    00409     bool       m_active;
    00410     bool       m_hasWrap;
    00411
    00412   private slots:
    00413     void slotNeedTextHint(int line, int col, QString &text);
    00414     void slotHlChanged();
    00415
    00416   // spellcheck from cursor, selection
    00417   public slots:
    00418     void spellcheckFromCursor();
    00419     // defined here in anticipation of pr view selections ;)
    00420     void spellcheckSelection();
    00421
    00422
    00426   public:
    00427     inline KateViewConfig *config () { return m_config; };
    00428
    00429     void updateConfig ();
    00430
    00431     void updateDocumentConfig();
    00432
    00433     void updateRendererConfig();
    00434
    00435   private slots:
    00436     void updateFoldingConfig ();
    00437     void toggleBlockSelectionMode ();
    00438
    00439   private:
    00440     KateViewConfig *m_config;
    00441     bool m_startingUp;
    00442     bool m_updatingDocumentConfig;
    00443 };
    00444
    00445 #endif

This file is part of the documentation for kate Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:36:39 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003