• Skip to content
  • Skip to link menu
KDE 4.3 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 KateCodeFoldingTree;
00055 class KateBuffer;
00056 class KateView;
00057 class KateSmartRange;
00058 class KateLineInfo;
00059 class KateBrowserExtension;
00060 class KateDocumentConfig;
00061 class KateHighlighting;
00062 class KateSmartManager;
00063 class KateUndoManager;
00064 
00065 
00066 class KateTemplateHandler;
00067 
00068 // needed for parsing replacement text like "\1:\2"
00069 struct ReplacementPart {
00070   enum Type {
00071     Reference, // \1..\9
00072     Text,
00073     UpperCase, // \U = Uppercase from now on
00074     LowerCase, // \L = Lowercase from now on
00075     KeepCase, // \E = back to original case
00076     Counter // \# = 1, 2, ... incremented for each replacement of <Replace All>
00077   };
00078 
00079   Type type;
00080 
00081   // Type in {Reference, Counter}
00082   int index; // [0..9] 0=full match, 1=first capture, ..
00083 
00084   // Type = Text
00085   QString text;
00086 };
00087 
00088 //
00089 // Kate KTextEditor::Document class (and even KTextEditor::Editor ;)
00090 //
00091 class KateDocument : public KTextEditor::Document,
00092                      public KTextEditor::SessionConfigInterface,
00093                      public KTextEditor::SearchInterface,
00094                      public KTextEditor::MarkInterface,
00095                      public KTextEditor::VariableInterface,
00096                      public KTextEditor::ModificationInterface,
00097                      public KTextEditor::SmartInterface,
00098                      private KTextEditor::SmartRangeWatcher,
00099                      public KTextEditor::AnnotationInterface
00100 {
00101   Q_OBJECT
00102   Q_INTERFACES(KTextEditor::SessionConfigInterface)
00103   Q_INTERFACES(KTextEditor::SearchInterface)
00104   Q_INTERFACES(KTextEditor::MarkInterface)
00105   Q_INTERFACES(KTextEditor::VariableInterface)
00106   Q_INTERFACES(KTextEditor::ModificationInterface)
00107   Q_INTERFACES(KTextEditor::SmartInterface)
00108   Q_INTERFACES(KTextEditor::AnnotationInterface)
00109 
00110   public:
00111     explicit KateDocument (bool bSingleViewMode=false, bool bBrowserView=false, bool bReadOnly=false,
00112                   QWidget *parentWidget = 0, QObject * = 0);
00113     ~KateDocument ();
00114 
00115     using ReadWritePart::closeUrl;
00116     bool closeUrl();
00117 
00118     KTextEditor::Editor *editor ();
00119 
00120   /*
00121    * Overload this to have on-demand view creation
00122    */
00123   public:
00127     virtual QWidget *widget();
00128 
00129   public:
00130     bool readOnly () const { return m_bReadOnly; }
00131     bool browserView () const { return m_bBrowserView; }
00132     bool singleViewMode () const { return m_bSingleViewMode; }
00133     KateBrowserExtension *browserExtension () { return m_extension; }
00134     static bool simpleMode ();
00135 
00136   private:
00137     // only to make part work, don't change it !
00138     bool m_bSingleViewMode;
00139     bool m_bBrowserView;
00140     bool m_bReadOnly;
00141     KateBrowserExtension *m_extension;
00142 
00143   //
00144   // KTextEditor::Document stuff
00145   //
00146   public:
00147     KTextEditor::View *createView( QWidget *parent );
00148     const QList<KTextEditor::View*> &views () const;
00149 
00150     virtual KTextEditor::View* activeView() const { return m_activeView; }
00151     // Invalid covariant returns my a$$... for some reason gcc won't let me return a KateView above!
00152     KateView* activeKateView() const;
00153 
00154   Q_SIGNALS:
00155     void activeViewSelectionChanged(KTextEditor::View* view);
00156 
00157   private:
00158     QLinkedList<KateView*> m_views;
00159     QList<KTextEditor::View*> m_textEditViews;
00160     KTextEditor::View *m_activeView;
00161 
00162   //
00163   // KTextEditor::EditInterface stuff
00164   //
00165   public Q_SLOTS:
00166     virtual bool setText(const QString &);
00167     virtual bool setText(const QStringList& text);
00168     virtual bool clear ();
00169 
00170     virtual bool insertText ( const KTextEditor::Cursor &position, const QString &s, bool block = false );
00171     virtual bool insertText ( const KTextEditor::Cursor &position, const QStringList &text, bool block = false );
00172 
00173     virtual bool insertLine ( int line, const QString &s );
00174     virtual bool insertLines ( int line, const QStringList &s );
00175 
00176     bool removeText ( const KTextEditor::Range &range, bool block = false );
00177     bool removeLine ( int line );
00178 
00179     bool replaceText ( const KTextEditor::Range &range, const QString &s, bool block = false );
00180 
00181     // unhide method...
00182     bool replaceText (const KTextEditor::Range &r, const QStringList &l, bool b)
00183     { return KTextEditor::Document::replaceText (r, l, b); }
00184 
00185   public:
00186     virtual QString text ( const KTextEditor::Range &range, bool blockwise = false ) const;
00187     virtual QStringList textLines ( const KTextEditor::Range& range, bool block = false ) const;
00188     virtual QString text() const;
00189     virtual QString line(int line) const;
00190     virtual QChar character(const KTextEditor::Cursor& position) const;
00191     int lines() const;
00192     virtual KTextEditor::Cursor documentEnd() const;
00193     int numVisLines() const;
00194     int totalCharacters() const;
00195     int lineLength(int line) const;
00196 
00197   Q_SIGNALS:
00198     void charactersSemiInteractivelyInserted(const KTextEditor::Cursor& position, const QString& text);
00199 
00200   public:
00201 //BEGIN editStart/editEnd (start, end, undo, cursor update, view update)
00207     void editStart (bool withUndo = true, Kate::EditSource editSource = Kate::NoEditSource);
00209     void editBegin (Kate::EditSource editSource = Kate::NoEditSource) { editStart(true, editSource); }
00214     void editEnd ();
00215 
00216     void pushEditState();
00217     void popEditState();
00218 
00219     bool startEditing () { editStart (true, Kate::ThirdPartyEdit); return true; }
00220     bool endEditing () { editEnd (); return true; }
00221 
00222 //END editStart/editEnd
00223 
00224     void inputMethodStart();
00225     void inputMethodEnd();
00226 
00227 //BEGIN LINE BASED INSERT/REMOVE STUFF (editStart() and editEnd() included)
00235     bool editInsertText ( int line, int col, const QString &s, Kate::EditSource editSource = Kate::NoEditSource );
00243     bool editRemoveText ( int line, int col, int len, Kate::EditSource editSource = Kate::NoEditSource );
00244 
00253     bool editMarkLineAutoWrapped ( int line, bool autowrapped );
00254 
00265     bool editWrapLine ( int line, int col, bool newLine = true, bool *newLineAdded = 0 );
00273     bool editUnWrapLine ( int line, bool removeLine = true, int length = 0 );
00274 
00281     bool editInsertLine ( int line, const QString &s, Kate::EditSource editSource = Kate::NoEditSource );
00287     bool editRemoveLine ( int line, Kate::EditSource editSource = Kate::NoEditSource );
00288 
00295     bool wrapText (int startLine, int endLine);
00296 //END LINE BASED INSERT/REMOVE STUFF
00297 
00298   Q_SIGNALS:
00302     void editLineWrapped ( int line, int col, int len );
00303 
00307     void editLineUnWrapped ( int line, int col );
00308 
00309   public:
00310     void undoSafePoint();
00311 
00312     bool undoDontMerge() const;
00313     void setUndoDontMerge(bool dontMerge);
00314 
00315     bool undoAllowComplexMerge() const;
00316     void setUndoAllowComplexMerge(bool allow);
00317 
00318     bool isEditRunning() const;
00319 
00325     bool isWithUndo() const;
00326 
00327     void setMergeAllEdits(bool merge);
00328 
00329   private:
00330     int editSessionNumber;
00331     QStack<int> editStateStack;
00332     QStack<Kate::EditSource> m_editSources;
00333     bool editIsRunning;
00334     bool editWithUndo;
00335 
00336   //
00337   // KTextEditor::UndoInterface stuff
00338   //
00339   public Q_SLOTS:
00340     void undo ();
00341     void redo ();
00342 
00343   public:
00344     uint undoCount () const;
00345     uint redoCount () const;
00346     class KateEditHistory* history() const { return m_editHistory; }
00347 
00348   private:
00349     KateUndoManager* m_undoManager;
00350     KateEditHistory* m_editHistory;
00351 
00352   Q_SIGNALS:
00353     void undoChanged ();
00354 
00355   //
00356   // KTextEditor::SearchInterface stuff
00357   //
00358   public Q_SLOTS:
00359     QVector<KTextEditor::Range> searchText(
00360         const KTextEditor::Range & range,
00361         const QString & pattern,
00362         const KTextEditor::Search::SearchOptions options);
00363 
00364     KTextEditor::Search::SearchOptions supportedSearchOptions() const;
00365 
00366   //
00367   // internal implementation....
00368   //
00369   private:
00384     KTextEditor::Range searchText (const KTextEditor::Range & inputRange,
00385         const QString &text, bool casesensitive = true, bool backwards = false);
00386 
00400     QVector<KTextEditor::Range> searchRegex (const KTextEditor::Range & inputRange,
00401         QRegExp & regexp, bool backwards = false);
00402 
00403   private:
00407     QWidget * dialogParent();
00408 
00409   /*
00410    * Public string processing helpers
00411    */
00412   public:
00423     static void escapePlaintext(QString & text, QList<ReplacementPart> * parts = NULL,
00424         bool replacementGoodies = false);
00425 
00436     static int repairPattern(QString & pattern, bool & stillMultiLine);
00437 
00438   /*
00439    * Private string processing helpers
00440    */
00441   private:
00455     static int fixedLastIndexIn(const QRegExp & matcher, const QString & str,
00456         int offset = -1, QRegExp::CaretMode caretMode = QRegExp::CaretAtZero);
00457 
00458   /*
00459    * Access to the mode/highlighting subsystem
00460    */
00461   public:
00467     virtual QString mode() const;
00468 
00474     virtual QString highlightingMode() const;
00475 
00480     virtual QStringList modes() const;
00481 
00486     virtual QStringList highlightingModes() const;
00487 
00493     virtual bool setMode(const QString &name);
00494 
00500     virtual bool setHighlightingMode(const QString &name);
00507     virtual QString highlightingModeSection( int index ) const;
00508 
00515     virtual QString modeSection( int index ) const;
00516 
00517   /*
00518    * SIGNALS
00519    * Following signals should be emitted by the document if the mode
00520    * or highlighting mode of the document changes
00521    */
00522   Q_SIGNALS:
00529     void modeChanged(KTextEditor::Document *document);
00530 
00537     void highlightingModeChanged(KTextEditor::Document *document);
00538 
00539   /*
00540    * Helpers....
00541    */
00542   public:
00543     void bufferHlChanged();
00544 
00549     void setDontChangeHlOnSave();
00550 
00551   //
00552   // KTextEditor::ConfigInterface stuff
00553   //
00554   public:
00555     void readSessionConfig (const KConfigGroup&);
00556     void writeSessionConfig (KConfigGroup&);
00557 
00558   //
00559   // KTextEditor::MarkInterface
00560   //
00561   public Q_SLOTS:
00562     void setMark( int line, uint markType );
00563     void clearMark( int line );
00564 
00565     void addMark( int line, uint markType );
00566     void removeMark( int line, uint markType );
00567 
00568     void clearMarks();
00569 
00570     void setMarkPixmap( MarkInterface::MarkTypes, const QPixmap& );
00571 
00572     void setMarkDescription( MarkInterface::MarkTypes, const QString& );
00573 
00574     void setEditableMarks( uint markMask );
00575 
00576   public:
00577     uint mark( int line );
00578     const QHash<int, KTextEditor::Mark*> &marks ();
00579     QPixmap markPixmap( MarkInterface::MarkTypes ) const;
00580     QString markDescription( MarkInterface::MarkTypes ) const;
00581     QColor markColor( MarkInterface::MarkTypes ) const;
00582     uint editableMarks() const;
00583 
00584   Q_SIGNALS:
00585     void marksChanged( KTextEditor::Document* );
00586     void markChanged( KTextEditor::Document*, KTextEditor::Mark, KTextEditor::MarkInterface::MarkChangeAction );
00587 
00588   private:
00589     QHash<int, KTextEditor::Mark*> m_marks;
00590     QHash<int,QPixmap>           m_markPixmaps;
00591     QHash<int,QString>           m_markDescriptions;
00592     uint                        m_editableMarks;
00593 
00594   //
00595   // KTextEditor::PrintInterface
00596   //
00597   public Q_SLOTS:
00598     bool printDialog ();
00599     bool print ();
00600 
00601   //
00602   // KTextEditor::DocumentInfoInterface ( ### unfinished )
00603   //
00604   public:
00612     QString mimeType();
00613 
00620     KMimeType::Ptr mimeTypeForContent();
00621 
00622   //
00623   // KTextEditor::VariableInterface
00624   //
00625   public:
00626     QString variable( const QString &name ) const;
00627 
00628   Q_SIGNALS:
00629     void variableChanged( KTextEditor::Document*, const QString &, const QString & );
00630 
00631   private:
00632     QMap<QString, QString> m_storedVariables;
00633 
00634   //
00635   // KTextEditor::SmartInterface
00636   //
00637   public:
00638     virtual void clearSmartInterface();
00639 
00640     virtual int currentRevision() const;
00641     virtual void releaseRevision(int revision) const;
00642     virtual void useRevision(int revision = -1);
00643     virtual KTextEditor::Cursor translateFromRevision(const KTextEditor::Cursor& cursor, KTextEditor::SmartCursor::InsertBehavior insertBehavior = KTextEditor::SmartCursor::StayOnInsert) const;
00644     virtual KTextEditor::Range translateFromRevision(const KTextEditor::Range& range, KTextEditor::SmartRange::InsertBehaviors insertBehavior = KTextEditor::SmartRange::ExpandLeft | KTextEditor::SmartRange::ExpandRight) const;
00645 
00646     virtual KTextEditor::SmartCursor* newSmartCursor(const KTextEditor::Cursor& position, KTextEditor::SmartCursor::InsertBehavior insertBehavior = KTextEditor::SmartCursor::MoveOnInsert);
00647     virtual void deleteCursors();
00648 
00649     virtual KTextEditor::SmartRange* newSmartRange(const KTextEditor::Range& range, KTextEditor::SmartRange* parent = 0L, KTextEditor::SmartRange::InsertBehaviors insertBehavior = KTextEditor::SmartRange::DoNotExpand);
00650     virtual KTextEditor::SmartRange* newSmartRange(KTextEditor::SmartCursor* start, KTextEditor::SmartCursor* end, KTextEditor::SmartRange* parent = 0L, KTextEditor::SmartRange::InsertBehaviors insertBehavior = KTextEditor::SmartRange::DoNotExpand);
00651     virtual void unbindSmartRange(KTextEditor::SmartRange* range);
00652     virtual void deleteRanges();
00653 
00654     // Syntax highlighting extension
00655     virtual void addHighlightToDocument(KTextEditor::SmartRange* topRange, bool supportDynamic);
00656     virtual const QList<KTextEditor::SmartRange*> documentHighlights() const;
00657     virtual void clearDocumentHighlights();
00658 
00659     virtual void addHighlightToView(KTextEditor::View* view, KTextEditor::SmartRange* topRange, bool supportDynamic);
00660     virtual void removeHighlightFromView(KTextEditor::View* view, KTextEditor::SmartRange* topRange);
00661     virtual const QList<KTextEditor::SmartRange*> viewHighlights(KTextEditor::View* view) const;
00662     virtual void clearViewHighlights(KTextEditor::View* view);
00663 
00664     // Action association extension
00665     virtual void addActionsToDocument(KTextEditor::SmartRange* topRange);
00666     virtual const QList<KTextEditor::SmartRange*> documentActions() const;
00667     virtual void clearDocumentActions();
00668 
00669     virtual void addActionsToView(KTextEditor::View* view, KTextEditor::SmartRange* topRange);
00670     virtual void removeActionsFromView(KTextEditor::View* view, KTextEditor::SmartRange* topRange);
00671     virtual const QList<KTextEditor::SmartRange*> viewActions(KTextEditor::View* view) const;
00672     virtual void clearViewActions(KTextEditor::View* view);
00673 
00674     KateSmartManager* smartManager() const { return m_smartManager; }
00675 
00676   Q_SIGNALS:
00677     void dynamicHighlightAdded(KateSmartRange* range);
00678     void dynamicHighlightRemoved(KateSmartRange* range);
00679 
00680   public Q_SLOTS:
00681     virtual void removeHighlightFromDocument(KTextEditor::SmartRange* topRange);
00682     virtual void removeActionsFromDocument(KTextEditor::SmartRange* topRange);
00683 
00684   protected:
00685     virtual void attributeDynamic(KTextEditor::Attribute::Ptr a);
00686     virtual void attributeNotDynamic(KTextEditor::Attribute::Ptr a);
00687 
00688   private:
00689     // Smart range watcher overrides
00690     virtual void rangeDeleted(KTextEditor::SmartRange* range);
00691 
00692     KateSmartManager* m_smartManager;
00693     QList<KTextEditor::SmartRange*> m_documentHighlights;
00694     QList<KTextEditor::SmartRange*> m_documentDynamicHighlights;
00695     QList<KTextEditor::SmartRange*> m_documentActions;
00696 
00697   //
00698   // Annotation Interface
00699   //
00700   public:
00701 
00702     virtual void setAnnotationModel( KTextEditor::AnnotationModel* model );
00703     virtual KTextEditor::AnnotationModel* annotationModel() const;
00704 
00705   Q_SIGNALS:
00706     void annotationModelChanged( KTextEditor::AnnotationModel*, KTextEditor::AnnotationModel* );
00707 
00708   private:
00709     KTextEditor::AnnotationModel* m_annotationModel;
00710 
00711   //
00712   // KParts::ReadWrite stuff
00713   //
00714   public:
00720     bool openFile ();
00721 
00727     bool saveFile ();
00728 
00729     void setReadWrite ( bool rw = true );
00730 
00731     void setModified( bool m );
00732 
00733   private:
00734     void activateDirWatch (const QString &useFileName = QString());
00735     void deactivateDirWatch ();
00736 
00737     QString m_dirWatchFile;
00738 
00739   public:
00743     bool typeChars ( KateView *type, const QString &chars );
00744 
00748     inline int lastLine() const { return lines()-1; }
00749 
00750     // Repaint all of all of the views
00751     void repaintViews(bool paintOnlyDirty = true);
00752 
00753     KateHighlighting *highlight () const;
00754 
00755   public Q_SLOTS:    //please keep prototypes and implementations in same order
00756     void tagLines(int start, int end);
00757     void tagLines(KTextEditor::Cursor start, KTextEditor::Cursor end);
00758 
00759   //export feature, obsolute
00760   public Q_SLOTS:
00761      void exportAs(const QString&) { }
00762 
00763   Q_SIGNALS:
00764     void preHighlightChanged(uint);
00765 
00766   private Q_SLOTS:
00767     void internalHlChanged();
00768 
00769   public:
00770     void addView(KTextEditor::View *);
00777     void removeView(KTextEditor::View *);
00778     void setActiveView(KTextEditor::View*);
00779 
00780     bool ownedView(KateView *);
00781 
00782     uint toVirtualColumn( const KTextEditor::Cursor& );
00783     void newLine( KateView*view ); // Changes input
00784     void backspace(     KateView *view, const KTextEditor::Cursor& );
00785     void del(           KateView *view, const KTextEditor::Cursor& );
00786     void transpose(     const KTextEditor::Cursor& );
00787 
00788     void paste ( KateView* view, QClipboard::Mode = QClipboard::Clipboard );
00789 
00790   public:
00791     void indent ( KateView *view, uint line, int change );
00792     void comment ( KateView *view, uint line, uint column, int change );
00793     void align ( KateView *view, const KTextEditor::Range &range );
00794 
00795     enum TextTransform { Uppercase, Lowercase, Capitalize };
00796 
00804     void transform ( KateView *view, const KTextEditor::Cursor &, TextTransform );
00808     void joinLines( uint first, uint last );
00809 
00810   private:
00811     bool removeStringFromBeginning(int line, const QString &str);
00812     bool removeStringFromEnd(int line, const QString &str);
00813 
00823     bool nextNonSpaceCharPos(int &line, int &col);
00824 
00832     bool previousNonSpaceCharPos(int &line, int &col);
00833 
00838     void addStartLineCommentToSingleLine(int line, int attrib=0);
00843     bool removeStartLineCommentFromSingleLine(int line, int attrib=0);
00844 
00848     void addStartStopCommentToSingleLine(int line, int attrib=0);
00852     bool removeStartStopCommentFromSingleLine(int line, int attrib=0);
00856     bool removeStartStopCommentFromRegion(const KTextEditor::Cursor &start, const KTextEditor::Cursor &end, int attrib=0);
00857 
00862     void addStartStopCommentToSelection( KateView *view, int attrib=0 );
00866     void addStartLineCommentToSelection( KateView *view, int attrib=0 );
00867 
00874     bool removeStartStopCommentFromSelection( KateView *view, int attrib=0 );
00878     bool removeStartLineCommentFromSelection( KateView *view, int attrib=0 );
00879 
00880   public:
00881     QString getWord( const KTextEditor::Cursor& cursor );
00882 
00883   public:
00884     void newBracketMark( const KTextEditor::Cursor& start, KTextEditor::Range& bm, int maxLines = -1 );
00885     bool findMatchingBracket( KTextEditor::Range& range, int maxLines = -1 );
00886 
00887   private:
00888     void guiActivateEvent( KParts::GUIActivateEvent *ev );
00889 
00890   public:
00891     const QString &documentName () const { return m_docName; }
00892 
00893     void setDocName (QString docName);
00894 
00895     void lineInfo (KateLineInfo *info, unsigned int line);
00896 
00897     KateCodeFoldingTree *foldingTree ();
00898 
00899   public:
00903     bool isModifiedOnDisc() { return m_modOnHd; }
00904 
00905     void setModifiedOnDisk( ModifiedOnDiskReason reason );
00906 
00907     void setModifiedOnDiskWarning ( bool on );
00908 
00909   public Q_SLOTS:
00914     void slotModifiedOnDisk( KTextEditor::View *v = 0 );
00915 
00919     bool documentReload ();
00920 
00921     bool documentSave ();
00922     bool documentSaveAs ();
00923 
00924     virtual bool save();
00925   public:
00926     virtual bool saveAs( const KUrl &url );
00927   private:
00928     bool m_saveAs;
00929   Q_SIGNALS:
00936     void modifiedOnDisk (KTextEditor::Document *doc, bool isModified, KTextEditor::ModificationInterface::ModifiedOnDiskReason reason);
00937 
00938   public:
00939     void ignoreModifiedOnDiskOnce();
00940 
00941   private:
00942     int m_isasking; // don't reenter slotModifiedOnDisk when this is true
00943                     // -1: ignore once, 0: false, 1: true
00944 
00945   public:
00946     bool setEncoding (const QString &e);
00947     const QString &encoding() const;
00948     void setProberTypeForEncodingAutoDetection (KEncodingProber::ProberType);
00949     KEncodingProber::ProberType proberTypeForEncodingAutoDetection() const;
00950 
00951 
00952   public Q_SLOTS:
00953     void setWordWrap (bool on);
00954     void setWordWrapAt (uint col);
00955 
00956   public:
00957     bool wordWrap() const;
00958     uint wordWrapAt() const;
00959 
00960   public Q_SLOTS:
00961     void setPageUpDownMovesCursor(bool on);
00962 
00963   public:
00964     bool pageUpDownMovesCursor() const;
00965 
00966    // code folding
00967   public:
00968     uint getRealLine(unsigned int virtualLine);
00969     uint getVirtualLine(unsigned int realLine);
00970     uint visibleLines ();
00971     KateTextLine::Ptr kateTextLine(uint i);
00972     KateTextLine::Ptr plainKateTextLine(uint i);
00973 
00974   Q_SIGNALS:
00975     void codeFoldingUpdated();
00976     void aboutToRemoveText(const KTextEditor::Range&);
00977     void textRemoved();
00978 
00979   private Q_SLOTS:
00980     void slotModOnHdDirty (const QString &path);
00981     void slotModOnHdCreated (const QString &path);
00982     void slotModOnHdDeleted (const QString &path);
00983 
00984   private:
00992     bool createDigest ( QByteArray &result );
00993 
00997     QString reasonedMOHString() const;
00998 
01005     void removeTrailingSpace(int line);
01006     inline void blockRemoveTrailingSpaces(bool block)
01007     { m_blockRemoveTrailingSpaces = block; }
01008 
01009   private:
01011     bool m_blockRemoveTrailingSpaces;
01012 
01013   public:
01014     void updateFileType (const QString &newType, bool user = false);
01015 
01016     QString fileType () const { return m_fileType; }
01017 
01018   //
01019   // REALLY internal data ;)
01020   //
01021   private:
01022     // text buffer
01023     KateBuffer *m_buffer;
01024 
01025     // indenter
01026     KateAutoIndent m_indenter;
01027 
01028     bool hlSetByUser;
01029 
01030     bool m_modOnHd;
01031     ModifiedOnDiskReason m_modOnHdReason;
01032     QByteArray m_digest; // MD5 digest, updated on load/save
01033 
01034     QString m_docName;
01035     int m_docNameNumber;
01036 
01037     // file type !!!
01038     QString m_fileType;
01039     bool m_fileTypeSetByUser;
01040 
01044     bool m_reloading;
01045 
01046   public Q_SLOTS:
01047     void slotQueryClose_save(bool *handled, bool* abortClosing);
01048 
01049   public:
01050     virtual bool queryClose();
01051 
01052     void makeAttribs (bool needInvalidate = true);
01053 
01054     static bool checkOverwrite( KUrl u, QWidget *parent );
01055 
01059   public:
01060     KateDocumentConfig *config() { return m_config; }
01061     KateDocumentConfig *config() const { return m_config; }
01062 
01063     void updateConfig ();
01064 
01065   private:
01066     KateDocumentConfig *m_config;
01067 
01072   private:
01076     void readDirConfig ();
01077 
01082     void readVariables(bool onlyViewAndRenderer = false);
01083 
01088     void readVariableLine( QString t, bool onlyViewAndRenderer = false );
01092     void setViewVariable( QString var, QString val );
01098     static bool checkBoolValue( QString value, bool *result );
01104     static bool checkIntValue( QString value, int *result );
01109     static bool checkColorValue( QString value, QColor &col );
01110 
01114     static QRegExp kvLine;
01115     static QRegExp kvLineWildcard;
01116     static QRegExp kvLineMime;
01117     static QRegExp kvVar;
01118 
01119     bool s_fileChangedDialogsActivated;
01120 
01121   // TemplateInterface
01122   public:
01123       bool invokeTemplateHandler(int key);
01124       virtual bool insertTemplateTextImplementation ( const KTextEditor::Cursor &c, const QString &templateString, const QMap<QString,QString> &initialValues, QWidget *); //PORT ME
01125 
01126   private Q_SLOTS:
01127     void templateHandlerDestroyed();
01128 
01129   protected:
01130       KateTemplateHandler *m_templateHandler;
01131 
01132   protected Q_SLOTS:
01133       void testTemplateCode();
01134       void dumpRegionTree();
01135   public:
01136       class LoadSaveFilterCheckPlugins;
01137 
01138   private slots:
01139       void slotCompleted();
01140       void slotCanceled();
01141   private:
01142       bool m_savingToUrl;
01143       void setPreSavePostDialogFilterChecks(QStringList plugins) {m_preSavePostDialogFilterChecks=plugins;}
01144       QStringList m_preSavePostDialogFilterChecks;
01145       void setPostSaveFilterChecks(QStringList plugins) {m_postSaveFilterChecks=plugins;}
01146       QStringList m_postSaveFilterChecks;
01147       void setPostLoadFilterChecks(QStringList plugins) {m_postLoadFilterChecks=plugins;}
01148       QStringList m_postLoadFilterChecks;
01149       static LoadSaveFilterCheckPlugins* loadSaveFilterCheckPlugins();
01150 };
01151 
01152 #endif
01153 
01154 // kate: space-indent on; indent-width 2; replace-tabs on;
01155 

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
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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