• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Kate

katedocument.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2001-2004 Christoph Cullmann <cullmann@kde.org>
00003    Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
00004    Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
00005    Copyright (C) 2006 Hamish Rodda <rodda@kde.org>
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., 51 Franklin Street, Fifth Floor,
00019    Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef _KATE_DOCUMENT_H_
00023 #define _KATE_DOCUMENT_H_
00024 
00025 #include <QtCore/QLinkedList>
00026 #include <QtCore/QMap>
00027 #include <QtCore/QDate>
00028 #include <QtGui/QClipboard>
00029 #include <QtCore/QStack>
00030 
00031 #include <kmimetype.h>
00032 #include <klocale.h>
00033 #include <kshortcut.h>
00034 #include <kencodingprober.h>
00035 
00036 #include <ktexteditor/document.h>
00037 #include <ktexteditor/sessionconfiginterface.h>
00038 #include <ktexteditor/searchinterface.h>
00039 #include <ktexteditor/markinterface.h>
00040 #include <ktexteditor/variableinterface.h>
00041 #include <ktexteditor/modificationinterface.h>
00042 #include <ktexteditor/smartinterface.h>
00043 #include <ktexteditor/rangefeedback.h>
00044 #include <ktexteditor/annotationinterface.h>
00045 
00046 #include "katetextline.h"
00047 #include "kateautoindent.h"
00048 #include "katenamespace.h"
00049 
00050 namespace KTextEditor { class Plugin; class Attribute; }
00051 
00052 namespace KIO { class TransferJob; }
00053 
00054 class KateUndoGroup;
00055 class KateCodeFoldingTree;
00056 class KateBuffer;
00057 class KateView;
00058 class KateSmartRange;
00059 class KateLineInfo;
00060 class KateBrowserExtension;
00061 class KateDocumentConfig;
00062 class KateHighlighting;
00063 class KateSmartManager;
00064 
00065 
00066 class QTimer;
00067 
00068 class KateKeyInterceptorFunctor;
00069 
00070 // needed for parsing replacement text like "\1:\2"
00071 struct ReplacementPart {
00072   enum Type {
00073     Reference, // \1..\9
00074     Text,
00075     UpperCase, // \U = Uppercase from now on
00076     LowerCase, // \L = Lowercase from now on
00077     KeepCase, // \E = back to original case
00078     Counter // \# = 1, 2, ... incremented for each replacement of <Replace All>
00079   };
00080 
00081   Type type;
00082 
00083   // Type in {Reference, Counter}
00084   int index; // [0..9] 0=full match, 1=first capture, ..
00085 
00086   // Type = Text
00087   QString text;
00088 };
00089 
00090 //
00091 // Kate KTextEditor::Document class (and even KTextEditor::Editor ;)
00092 //
00093 class KateDocument : public KTextEditor::Document,
00094                      public KTextEditor::SessionConfigInterface,
00095                      public KTextEditor::SearchInterface,
00096                      public KTextEditor::MarkInterface,
00097                      public KTextEditor::VariableInterface,
00098                      public KTextEditor::ModificationInterface,
00099                      public KTextEditor::SmartInterface,
00100                      private KTextEditor::SmartRangeWatcher,
00101                      public KTextEditor::AnnotationInterface
00102 {
00103   Q_OBJECT
00104   Q_INTERFACES(KTextEditor::SessionConfigInterface)
00105   Q_INTERFACES(KTextEditor::SearchInterface)
00106   Q_INTERFACES(KTextEditor::MarkInterface)
00107   Q_INTERFACES(KTextEditor::VariableInterface)
00108   Q_INTERFACES(KTextEditor::ModificationInterface)
00109   Q_INTERFACES(KTextEditor::SmartInterface)
00110   Q_INTERFACES(KTextEditor::AnnotationInterface)
00111 
00112   public:
00113     explicit KateDocument (bool bSingleViewMode=false, bool bBrowserView=false, bool bReadOnly=false,
00114                   QWidget *parentWidget = 0, QObject * = 0);
00115     ~KateDocument ();
00116 
00117     using ReadWritePart::closeUrl;
00118     bool closeUrl();
00119 
00120     KTextEditor::Editor *editor ();
00121 
00122   /*
00123    * Overload this to have on-demand view creation
00124    */
00125   public:
00129     virtual QWidget *widget();
00130 
00131   public:
00132     bool readOnly () const { return m_bReadOnly; }
00133     bool browserView () const { return m_bBrowserView; }
00134     bool singleViewMode () const { return m_bSingleViewMode; }
00135     KateBrowserExtension *browserExtension () { return m_extension; }
00136     static bool simpleMode ();
00137 
00138   private:
00139     // only to make part work, don't change it !
00140     bool m_bSingleViewMode;
00141     bool m_bBrowserView;
00142     bool m_bReadOnly;
00143     KateBrowserExtension *m_extension;
00144 
00145   //
00146   // KTextEditor::Document stuff
00147   //
00148   public:
00149     KTextEditor::View *createView( QWidget *parent );
00150     const QList<KTextEditor::View*> &views () const;
00151 
00152     virtual KTextEditor::View* activeView() const { return m_activeView; }
00153     // Invalid covariant returns my a$$... for some reason gcc won't let me return a KateView above!
00154     KateView* activeKateView() const;
00155 
00156   Q_SIGNALS:
00157     void activeViewSelectionChanged(KTextEditor::View* view);
00158 
00159   private:
00160     QLinkedList<KateView*> m_views;
00161     QList<KTextEditor::View*> m_textEditViews;
00162     KTextEditor::View *m_activeView;
00163 
00164   //
00165   // KTextEditor::EditInterface stuff
00166   //
00167   public Q_SLOTS:
00168     virtual bool setText(const QString &);
00169     virtual bool setText(const QStringList& text);
00170     virtual bool clear ();
00171 
00172     virtual bool insertText ( const KTextEditor::Cursor &position, const QString &s, bool block = false );
00173     virtual bool insertText ( const KTextEditor::Cursor &position, const QStringList &text, bool block = false );
00174 
00175     virtual bool insertLine ( int line, const QString &s );
00176     virtual bool insertLines ( int line, const QStringList &s );
00177 
00178     bool removeText ( const KTextEditor::Range &range, bool block = false );
00179     bool removeLine ( int line );
00180 
00181     bool replaceText ( const KTextEditor::Range &range, const QString &s, bool block = false );
00182 
00183     // unhide method...
00184     bool replaceText (const KTextEditor::Range &r, const QStringList &l, bool b)
00185     { return KTextEditor::Document::replaceText (r, l, b); }
00186 
00187   public:
00188     virtual QString text ( const KTextEditor::Range &range, bool blockwise = false ) const;
00189     virtual QStringList textLines ( const KTextEditor::Range& range, bool block = false ) const;
00190     virtual QString text() const;
00191     virtual QString line(int line) const;
00192     virtual QChar character(const KTextEditor::Cursor& position) const;
00193     int lines() const;
00194     virtual KTextEditor::Cursor documentEnd() const;
00195     int numVisLines() const;
00196     int totalCharacters() const;
00197     int lineLength(int line) const;
00198 
00199   Q_SIGNALS:
00200     void charactersSemiInteractivelyInserted(const KTextEditor::Cursor& position, const QString& text);
00201 
00202   public:
00203 //BEGIN editStart/editEnd (start, end, undo, cursor update, view update)
00209     void editStart (bool withUndo = true, Kate::EditSource editSource = Kate::NoEditSource);
00211     void editBegin (Kate::EditSource editSource = Kate::NoEditSource) { editStart(true, editSource); }
00216     void editEnd ();
00217 
00218     void pushEditState();
00219     void popEditState();
00220 
00221     bool startEditing () { editStart (true, Kate::ThirdPartyEdit); return true; }
00222     bool endEditing () { editEnd (); return true; }
00223 
00224 //END editStart/editEnd
00225 
00226 //BEGIN LINE BASED INSERT/REMOVE STUFF (editStart() and editEnd() included)
00234     bool editInsertText ( int line, int col, const QString &s, Kate::EditSource editSource = Kate::NoEditSource );
00242     bool editRemoveText ( int line, int col, int len, Kate::EditSource editSource = Kate::NoEditSource );
00243 
00252     bool editMarkLineAutoWrapped ( int line, bool autowrapped );
00253 
00264     bool editWrapLine ( int line, int col, bool newLine = true, bool *newLineAdded = 0 );
00272     bool editUnWrapLine ( int line, bool removeLine = true, int length = 0 );
00273 
00280     bool editInsertLine ( int line, const QString &s, Kate::EditSource editSource = Kate::NoEditSource );
00286     bool editRemoveLine ( int line, Kate::EditSource editSource = Kate::NoEditSource );
00287 
00294     bool wrapText (int startLine, int endLine);
00295 //END LINE BASED INSERT/REMOVE STUFF
00296 
00297   Q_SIGNALS:
00301     void editLineWrapped ( int line, int col, int len );
00302 
00306     void editLineUnWrapped ( int line, int col );
00307 
00308   private:
00309     void undoStart();
00310     void undoEnd();
00311 
00312   public:
00313     void undoSafePoint();
00314 
00315     bool undoDontMerge() const;
00316     void setUndoDontMerge(bool dontMerge);
00317 
00318     bool undoDontMergeComplex() const;
00319     void setUndoDontMergeComplex(bool dontMerge);
00320 
00321     bool isEditRunning() const;
00322     bool isWithUndo() const {return editWithUndo;}
00323 
00324     void setMergeAllEdits(bool merge) { m_mergeAllEdits = merge; m_firstMergeGroupSkipped = false; }
00325   private Q_SLOTS:
00326     void undoCancel();
00327 
00328   private:
00329     void editAddUndo (int type, uint line, uint col, uint len, const QString &text);
00330 
00331     int editSessionNumber;
00332     QStack<int> editStateStack;
00333     QStack<Kate::EditSource> m_editSources;
00334     bool editIsRunning;
00335     bool editWithUndo;
00336     bool m_undoComplexMerge;
00337     KateUndoGroup* m_editCurrentUndo;
00338 
00339   //
00340   // KTextEditor::UndoInterface stuff
00341   //
00342   public Q_SLOTS:
00343     void undo ();
00344     void redo ();
00345     void clearUndo ();
00346     void clearRedo ();
00347 
00348   public:
00349     uint undoCount () const;
00350     uint redoCount () const;
00351     class KateEditHistory* history() const { return m_editHistory; }
00352 
00353   private:
00354     KateEditHistory* m_editHistory;
00355 
00356     //
00357     // some internals for undo/redo
00358     //
00359     QList<KateUndoGroup*> undoItems;
00360     QList<KateUndoGroup*> redoItems;
00361     bool m_undoDontMerge; //create a setter later on and remove the friend declaration
00362     bool m_undoIgnoreCancel;
00363     bool m_mergeAllEdits; // if true, all undo groups are merged continually
00364     bool m_firstMergeGroupSkipped;  // used to make sure the first undo group isn't merged after
00365                                     // setting m_mergeAllEdits
00366     QTimer* m_undoMergeTimer;
00367     // these two variables are for resetting the document to
00368     // non-modified if all changes have been undone...
00369     KateUndoGroup* lastUndoGroupWhenSaved;
00370     KateUndoGroup* lastRedoGroupWhenSaved;
00371     bool docWasSavedWhenUndoWasEmpty;
00372     bool docWasSavedWhenRedoWasEmpty;
00373 
00374     // this sets
00375     void updateModified();
00376 
00377   Q_SIGNALS:
00378     void undoChanged ();
00379 
00380   //
00381   // KTextEditor::SearchInterface stuff
00382   //
00383   public Q_SLOTS:
00384     QVector<KTextEditor::Range> searchText(
00385         const KTextEditor::Range & range,
00386         const QString & pattern,
00387         const KTextEditor::Search::SearchOptions options);
00388 
00389     KTextEditor::Search::SearchOptions supportedSearchOptions() const;
00390 
00391   //
00392   // internal implementation....
00393   //
00394   private:
00409     KTextEditor::Range searchText (const KTextEditor::Range & inputRange,
00410         const QString &text, bool casesensitive = true, bool backwards = false);
00411 
00425     QVector<KTextEditor::Range> searchRegex (const KTextEditor::Range & inputRange,
00426         QRegExp & regexp, bool backwards = false);
00427 
00428   private:
00432     QWidget * dialogParent();
00433 
00434   /*
00435    * Public string processing helpers
00436    */
00437   public:
00448     static void escapePlaintext(QString & text, QList<ReplacementPart> * parts = NULL,
00449         bool replacementGoodies = false);
00450 
00461     static int repairPattern(QString & pattern, bool & stillMultiLine);
00462 
00463   /*
00464    * Private string processing helpers
00465    */
00466   private:
00480     static int fixedLastIndexIn(const QRegExp & matcher, const QString & str,
00481         int offset = -1, QRegExp::CaretMode caretMode = QRegExp::CaretAtZero);
00482 
00483   /*
00484    * Access to the mode/highlighting subsystem
00485    */
00486   public:
00492     virtual QString mode() const;
00493 
00499     virtual QString highlightingMode() const;
00500 
00505     virtual QStringList modes() const;
00506 
00511     virtual QStringList highlightingModes() const;
00512 
00518     virtual bool setMode(const QString &name);
00519 
00525     virtual bool setHighlightingMode(const QString &name);
00532     virtual QString highlightingModeSection( int index ) const;
00533 
00540     virtual QString modeSection( int index ) const;
00541 
00542   /*
00543    * SIGNALS
00544    * Following signals should be emitted by the document if the mode
00545    * or highlighting mode of the document changes
00546    */
00547   Q_SIGNALS:
00554     void modeChanged(KTextEditor::Document *document);
00555 
00562     void highlightingModeChanged(KTextEditor::Document *document);
00563 
00564   /*
00565    * Helpers....
00566    */
00567   public:
00568     void bufferHlChanged();
00569 
00570   private:
00571     void setDontChangeHlOnSave();
00572 
00573   //
00574   // KTextEditor::ConfigInterface stuff
00575   //
00576   public:
00577     void readSessionConfig (const KConfigGroup&);
00578     void writeSessionConfig (KConfigGroup&);
00579 
00580   //
00581   // KTextEditor::MarkInterface
00582   //
00583   public Q_SLOTS:
00584     void setMark( int line, uint markType );
00585     void clearMark( int line );
00586 
00587     void addMark( int line, uint markType );
00588     void removeMark( int line, uint markType );
00589 
00590     void clearMarks();
00591 
00592     void setMarkPixmap( MarkInterface::MarkTypes, const QPixmap& );
00593 
00594     void setMarkDescription( MarkInterface::MarkTypes, const QString& );
00595 
00596     void setEditableMarks( uint markMask );
00597 
00598   public:
00599     uint mark( int line );
00600     const QHash<int, KTextEditor::Mark*> &marks ();
00601     QPixmap markPixmap( MarkInterface::MarkTypes ) const;
00602     QString markDescription( MarkInterface::MarkTypes ) const;
00603     QColor markColor( MarkInterface::MarkTypes ) const;
00604     uint editableMarks() const;
00605 
00606   Q_SIGNALS:
00607     void marksChanged( KTextEditor::Document* );
00608     void markChanged( KTextEditor::Document*, KTextEditor::Mark, KTextEditor::MarkInterface::MarkChangeAction );
00609 
00610   private:
00611     QHash<int, KTextEditor::Mark*> m_marks;
00612     QHash<int,QPixmap>           m_markPixmaps;
00613     QHash<int,QString>           m_markDescriptions;
00614     uint                        m_editableMarks;
00615 
00616   //
00617   // KTextEditor::PrintInterface
00618   //
00619   public Q_SLOTS:
00620     bool printDialog ();
00621     bool print ();
00622 
00623   //
00624   // KTextEditor::DocumentInfoInterface ( ### unfinished )
00625   //
00626   public:
00634     QString mimeType();
00635 
00642     KMimeType::Ptr mimeTypeForContent();
00643 
00644   //
00645   // KTextEditor::VariableInterface
00646   //
00647   public:
00648     QString variable( const QString &name ) const;
00649 
00650   Q_SIGNALS:
00651     void variableChanged( KTextEditor::Document*, const QString &, const QString & );
00652 
00653   private:
00654     QMap<QString, QString> m_storedVariables;
00655 
00656   //
00657   // KTextEditor::SmartInterface
00658   //
00659   public:
00660     virtual void clearSmartInterface();
00661 
00662     virtual int currentRevision() const;
00663     virtual void releaseRevision(int revision) const;
00664     virtual void useRevision(int revision = -1);
00665     virtual KTextEditor::Cursor translateFromRevision(const KTextEditor::Cursor& cursor, KTextEditor::SmartCursor::InsertBehavior insertBehavior = KTextEditor::SmartCursor::StayOnInsert) const;
00666     virtual KTextEditor::Range translateFromRevision(const KTextEditor::Range& range, KTextEditor::SmartRange::InsertBehaviors insertBehavior = KTextEditor::SmartRange::ExpandLeft | KTextEditor::SmartRange::ExpandRight) const;
00667 
00668     virtual KTextEditor::SmartCursor* newSmartCursor(const KTextEditor::Cursor& position, KTextEditor::SmartCursor::InsertBehavior insertBehavior = KTextEditor::SmartCursor::MoveOnInsert);
00669     virtual void deleteCursors();
00670 
00671     virtual KTextEditor::SmartRange* newSmartRange(const KTextEditor::Range& range, KTextEditor::SmartRange* parent = 0L, KTextEditor::SmartRange::InsertBehaviors insertBehavior = KTextEditor::SmartRange::DoNotExpand);
00672     virtual KTextEditor::SmartRange* newSmartRange(KTextEditor::SmartCursor* start, KTextEditor::SmartCursor* end, KTextEditor::SmartRange* parent = 0L, KTextEditor::SmartRange::InsertBehaviors insertBehavior = KTextEditor::SmartRange::DoNotExpand);
00673     virtual void unbindSmartRange(KTextEditor::SmartRange* range);
00674     virtual void deleteRanges();
00675 
00676     // Syntax highlighting extension
00677     virtual void addHighlightToDocument(KTextEditor::SmartRange* topRange, bool supportDynamic);
00678     virtual const QList<KTextEditor::SmartRange*> documentHighlights() const;
00679     virtual void clearDocumentHighlights();
00680 
00681     virtual void addHighlightToView(KTextEditor::View* view, KTextEditor::SmartRange* topRange, bool supportDynamic);
00682     virtual void removeHighlightFromView(KTextEditor::View* view, KTextEditor::SmartRange* topRange);
00683     virtual const QList<KTextEditor::SmartRange*> viewHighlights(KTextEditor::View* view) const;
00684     virtual void clearViewHighlights(KTextEditor::View* view);
00685 
00686     // Action association extension
00687     virtual void addActionsToDocument(KTextEditor::SmartRange* topRange);
00688     virtual const QList<KTextEditor::SmartRange*> documentActions() const;
00689     virtual void clearDocumentActions();
00690 
00691     virtual void addActionsToView(KTextEditor::View* view, KTextEditor::SmartRange* topRange);
00692     virtual void removeActionsFromView(KTextEditor::View* view, KTextEditor::SmartRange* topRange);
00693     virtual const QList<KTextEditor::SmartRange*> viewActions(KTextEditor::View* view) const;
00694     virtual void clearViewActions(KTextEditor::View* view);
00695 
00696     KateSmartManager* smartManager() const { return m_smartManager; }
00697 
00698   Q_SIGNALS:
00699     void dynamicHighlightAdded(KateSmartRange* range);
00700     void dynamicHighlightRemoved(KateSmartRange* range);
00701 
00702   public Q_SLOTS:
00703     virtual void removeHighlightFromDocument(KTextEditor::SmartRange* topRange);
00704     virtual void removeActionsFromDocument(KTextEditor::SmartRange* topRange);
00705 
00706   protected:
00707     virtual void attributeDynamic(KTextEditor::Attribute::Ptr a);
00708     virtual void attributeNotDynamic(KTextEditor::Attribute::Ptr a);
00709 
00710   private:
00711     // Smart range watcher overrides
00712     virtual void rangeDeleted(KTextEditor::SmartRange* range);
00713 
00714     KateSmartManager* m_smartManager;
00715     QList<KTextEditor::SmartRange*> m_documentHighlights;
00716     QList<KTextEditor::SmartRange*> m_documentDynamicHighlights;
00717     QList<KTextEditor::SmartRange*> m_documentActions;
00718 
00719   //
00720   // Annotation Interface
00721   //
00722   public:
00723 
00724     virtual void setAnnotationModel( KTextEditor::AnnotationModel* model );
00725     virtual KTextEditor::AnnotationModel* annotationModel() const;
00726 
00727   Q_SIGNALS:
00728     void annotationModelChanged( KTextEditor::AnnotationModel*, KTextEditor::AnnotationModel* );
00729 
00730   private:
00731     KTextEditor::AnnotationModel* m_annotationModel;
00732 
00733   //
00734   // KParts::ReadWrite stuff
00735   //
00736   public:
00742     bool openFile ();
00743 
00749     bool saveFile ();
00750 
00751     void setReadWrite ( bool rw = true );
00752 
00753     void setModified( bool m );
00754 
00755   private:
00756     void activateDirWatch (const QString &useFileName = QString());
00757     void deactivateDirWatch ();
00758 
00759     QString m_dirWatchFile;
00760 
00761   public:
00765     bool typeChars ( KateView *type, const QString &chars );
00766 
00770     inline int lastLine() const { return lines()-1; }
00771 
00772     // Repaint all of all of the views
00773     void repaintViews(bool paintOnlyDirty = true);
00774 
00775     KateHighlighting *highlight () const;
00776 
00777   public Q_SLOTS:    //please keep prototypes and implementations in same order
00778     void tagLines(int start, int end);
00779     void tagLines(KTextEditor::Cursor start, KTextEditor::Cursor end);
00780 
00781   //export feature, obsolute
00782   public Q_SLOTS:
00783      void exportAs(const QString&) { }
00784 
00785   Q_SIGNALS:
00786     void preHighlightChanged(uint);
00787 
00788   private Q_SLOTS:
00789     void internalHlChanged();
00790 
00791   public:
00792     void addView(KTextEditor::View *);
00799     void removeView(KTextEditor::View *);
00800     void setActiveView(KTextEditor::View*);
00801 
00802     bool ownedView(KateView *);
00803 
00804     uint toVirtualColumn( const KTextEditor::Cursor& );
00805     void newLine( KateView*view ); // Changes input
00806     void backspace(     KateView *view, const KTextEditor::Cursor& );
00807     void del(           KateView *view, const KTextEditor::Cursor& );
00808     void transpose(     const KTextEditor::Cursor& );
00809 
00810     void paste ( KateView* view, QClipboard::Mode = QClipboard::Clipboard );
00811 
00812   public:
00813     void indent ( KateView *view, uint line, int change );
00814     void comment ( KateView *view, uint line, uint column, int change );
00815     void align ( KateView *view, const KTextEditor::Range &range );
00816 
00817     enum TextTransform { Uppercase, Lowercase, Capitalize };
00818 
00826     void transform ( KateView *view, const KTextEditor::Cursor &, TextTransform );
00830     void joinLines( uint first, uint last );
00831 
00832   private:
00833     bool removeStringFromBeginning(int line, const QString &str);
00834     bool removeStringFromEnd(int line, const QString &str);
00835 
00845     bool nextNonSpaceCharPos(int &line, int &col);
00846 
00854     bool previousNonSpaceCharPos(int &line, int &col);
00855 
00860     void addStartLineCommentToSingleLine(int line, int attrib=0);
00865     bool removeStartLineCommentFromSingleLine(int line, int attrib=0);
00866 
00870     void addStartStopCommentToSingleLine(int line, int attrib=0);
00874     bool removeStartStopCommentFromSingleLine(int line, int attrib=0);
00878     bool removeStartStopCommentFromRegion(const KTextEditor::Cursor &start, const KTextEditor::Cursor &end, int attrib=0);
00879 
00884     void addStartStopCommentToSelection( KateView *view, int attrib=0 );
00888     void addStartLineCommentToSelection( KateView *view, int attrib=0 );
00889 
00896     bool removeStartStopCommentFromSelection( KateView *view, int attrib=0 );
00900     bool removeStartLineCommentFromSelection( KateView *view, int attrib=0 );
00901 
00902   public:
00903     QString getWord( const KTextEditor::Cursor& cursor );
00904 
00905   public:
00906     void tagAll();
00907 
00908     void newBracketMark( const KTextEditor::Cursor& start, KTextEditor::Range& bm, int maxLines = -1 );
00909     bool findMatchingBracket( KTextEditor::Range& range, int maxLines = -1 );
00910 
00911   private:
00912     void guiActivateEvent( KParts::GUIActivateEvent *ev );
00913 
00914   public:
00915     const QString &documentName () const { return m_docName; }
00916 
00917     void setDocName (QString docName);
00918 
00919     void lineInfo (KateLineInfo *info, unsigned int line);
00920 
00921     KateCodeFoldingTree *foldingTree ();
00922 
00923   public:
00927     bool isModifiedOnDisc() { return m_modOnHd; }
00928 
00929     void setModifiedOnDisk( ModifiedOnDiskReason reason );
00930 
00931     void setModifiedOnDiskWarning ( bool on );
00932 
00933   public Q_SLOTS:
00938     void slotModifiedOnDisk( KTextEditor::View *v = 0 );
00939 
00943     bool documentReload ();
00944 
00945     bool documentSave ();
00946     bool documentSaveAs ();
00947 
00948     virtual bool save();
00949   public:
00950     virtual bool saveAs( const KUrl &url );
00951   private:
00952     bool m_saveAs;
00953   Q_SIGNALS:
00960     void modifiedOnDisk (KTextEditor::Document *doc, bool isModified, KTextEditor::ModificationInterface::ModifiedOnDiskReason reason);
00961 
00962   public:
00963     void ignoreModifiedOnDiskOnce();
00964 
00965   private:
00966     int m_isasking; // don't reenter slotModifiedOnDisk when this is true
00967                     // -1: ignore once, 0: false, 1: true
00968 
00969   public:
00970     bool setEncoding (const QString &e);
00971     const QString &encoding() const;
00972     void setProberTypeForEncodingAutoDetection (KEncodingProber::ProberType);
00973     KEncodingProber::ProberType proberTypeForEncodingAutoDetection() const;
00974 
00975 
00976   public Q_SLOTS:
00977     void setWordWrap (bool on);
00978     void setWordWrapAt (uint col);
00979 
00980   public:
00981     bool wordWrap() const;
00982     uint wordWrapAt() const;
00983 
00984   public Q_SLOTS:
00985     void setPageUpDownMovesCursor(bool on);
00986 
00987   public:
00988     bool pageUpDownMovesCursor() const;
00989 
00990    // code folding
00991   public:
00992     uint getRealLine(unsigned int virtualLine);
00993     uint getVirtualLine(unsigned int realLine);
00994     uint visibleLines ();
00995     KateTextLine::Ptr kateTextLine(uint i);
00996     KateTextLine::Ptr plainKateTextLine(uint i);
00997 
00998   Q_SIGNALS:
00999     void codeFoldingUpdated();
01000     void aboutToRemoveText(const KTextEditor::Range&);
01001     void textRemoved();
01002 
01003   private Q_SLOTS:
01004     void slotModOnHdDirty (const QString &path);
01005     void slotModOnHdCreated (const QString &path);
01006     void slotModOnHdDeleted (const QString &path);
01007 
01008   private:
01016     bool createDigest ( QByteArray &result );
01017 
01021     QString reasonedMOHString() const;
01022 
01029     void removeTrailingSpace(int line);
01030     inline void blockRemoveTrailingSpaces(bool block)
01031     { m_blockRemoveTrailingSpaces = block; }
01032 
01033   private:
01035     bool m_blockRemoveTrailingSpaces;
01036 
01037   public:
01038     void updateFileType (const QString &newType, bool user = false);
01039 
01040     QString fileType () const { return m_fileType; }
01041 
01042   //
01043   // REALLY internal data ;)
01044   //
01045   private:
01046     // text buffer
01047     KateBuffer *m_buffer;
01048 
01049     // indenter
01050     KateAutoIndent m_indenter;
01051 
01052     bool hlSetByUser;
01053 
01054     bool m_modOnHd;
01055     ModifiedOnDiskReason m_modOnHdReason;
01056     QByteArray m_digest; // MD5 digest, updated on load/save
01057 
01058     QString m_docName;
01059     int m_docNameNumber;
01060 
01061     // file type !!!
01062     QString m_fileType;
01063     bool m_fileTypeSetByUser;
01064 
01068     bool m_reloading;
01069 
01070   public Q_SLOTS:
01071     void slotQueryClose_save(bool *handled, bool* abortClosing);
01072 
01073   public:
01074     virtual bool queryClose();
01075 
01076     void makeAttribs (bool needInvalidate = true);
01077 
01078     static bool checkOverwrite( KUrl u, QWidget *parent );
01079 
01083   public:
01084     KateDocumentConfig *config() { return m_config; }
01085     KateDocumentConfig *config() const { return m_config; }
01086 
01087     void updateConfig ();
01088 
01089   private:
01090     KateDocumentConfig *m_config;
01091 
01096   private:
01100     void readDirConfig ();
01101 
01106     void readVariables(bool onlyViewAndRenderer = false);
01107 
01112     void readVariableLine( QString t, bool onlyViewAndRenderer = false );
01116     void setViewVariable( QString var, QString val );
01122     static bool checkBoolValue( QString value, bool *result );
01128     static bool checkIntValue( QString value, int *result );
01133     static bool checkColorValue( QString value, QColor &col );
01134 
01138     static QRegExp kvLine;
01139     static QRegExp kvLineWildcard;
01140     static QRegExp kvLineMime;
01141     static QRegExp kvVar;
01142 
01143     bool s_fileChangedDialogsActivated;
01144 
01145   // TemplateInterface
01146   public:
01147       bool setTabInterceptor(KateKeyInterceptorFunctor *interceptor); /* perhaps make it moregeneral like an eventfilter*/
01148       bool removeTabInterceptor(KateKeyInterceptorFunctor *interceptor);
01149       bool invokeTabInterceptor(int key);
01150       bool insertTemplateTextImplementation ( const KTextEditor::Cursor &c, const QString &templateString, const QMap<QString,QString> &initialValues, QWidget *); //PORT ME
01151 
01152   protected:
01153       KateKeyInterceptorFunctor *m_tabInterceptor;
01154 
01155   protected Q_SLOTS:
01156       void testTemplateCode();
01157       void dumpRegionTree();
01158   public:
01159       class LoadSaveFilterCheckPlugins;
01160 
01161   private slots:
01162       void slotCompleted();
01163       void slotCanceled();
01164   private:
01165       bool m_savingToUrl;
01166       void setPreSavePostDialogFilterChecks(QStringList plugins) {m_preSavePostDialogFilterChecks=plugins;}
01167       QStringList m_preSavePostDialogFilterChecks;
01168       void setPostSaveFilterChecks(QStringList plugins) {m_postSaveFilterChecks=plugins;}
01169       QStringList m_postSaveFilterChecks;
01170       void setPostLoadFilterChecks(QStringList plugins) {m_postLoadFilterChecks=plugins;}
01171       QStringList m_postLoadFilterChecks;
01172       static LoadSaveFilterCheckPlugins* loadSaveFilterCheckPlugins();
01173 };
01174 
01175 #endif
01176 
01177 // kate: space-indent on; indent-width 2; replace-tabs on;
01178 

Kate

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal