00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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 <kencodingprober.h>
00033
00034 #include <ktexteditor/document.h>
00035 #include <ktexteditor/sessionconfiginterface.h>
00036 #include <ktexteditor/searchinterface.h>
00037 #include <ktexteditor/markinterface.h>
00038 #include <ktexteditor/variableinterface.h>
00039 #include <ktexteditor/modificationinterface.h>
00040 #include <ktexteditor/smartinterface.h>
00041 #include <ktexteditor/rangefeedback.h>
00042 #include <ktexteditor/configinterface.h>
00043 #include <ktexteditor/annotationinterface.h>
00044 #include <ktexteditor/highlightinterface.h>
00045
00046 #include "katetextline.h"
00047 #include "katenamespace.h"
00048
00049 namespace KTextEditor { class Plugin; class Attribute; }
00050
00051 namespace KIO { class TransferJob; }
00052
00053 class KateCodeFoldingTree;
00054 class KateBuffer;
00055 class KateView;
00056 class KateSmartRange;
00057 class KateLineInfo;
00058 class KateBrowserExtension;
00059 class KateDocumentConfig;
00060 class KateHighlighting;
00061 class KateSmartManager;
00062 class KateUndoManager;
00063 class KateEditHistory;
00064 class KateOnTheFlyChecker;
00065
00066 class KateAutoIndent;
00067 class KateTemplateHandler;
00068
00069
00070
00071
00072 class KateDocument : public KTextEditor::Document,
00073 public KTextEditor::SessionConfigInterface,
00074 public KTextEditor::ParameterizedSessionConfigInterface,
00075 public KTextEditor::SearchInterface,
00076 public KTextEditor::MarkInterface,
00077 public KTextEditor::VariableInterface,
00078 public KTextEditor::ModificationInterface,
00079 public KTextEditor::ConfigInterface,
00080 public KTextEditor::SmartInterface,
00081 private KTextEditor::SmartRangeWatcher,
00082 public KTextEditor::AnnotationInterface,
00083 public KTextEditor::HighlightInterface
00084 {
00085 Q_OBJECT
00086 Q_INTERFACES(KTextEditor::SessionConfigInterface)
00087 Q_INTERFACES(KTextEditor::ParameterizedSessionConfigInterface)
00088 Q_INTERFACES(KTextEditor::SearchInterface)
00089 Q_INTERFACES(KTextEditor::MarkInterface)
00090 Q_INTERFACES(KTextEditor::VariableInterface)
00091 Q_INTERFACES(KTextEditor::ModificationInterface)
00092 Q_INTERFACES(KTextEditor::SmartInterface)
00093 Q_INTERFACES(KTextEditor::AnnotationInterface)
00094 Q_INTERFACES(KTextEditor::ConfigInterface)
00095 Q_INTERFACES(KTextEditor::HighlightInterface)
00096
00097 public:
00098 explicit KateDocument (bool bSingleViewMode=false, bool bBrowserView=false, bool bReadOnly=false,
00099 QWidget *parentWidget = 0, QObject * = 0);
00100 ~KateDocument ();
00101
00102 using ReadWritePart::closeUrl;
00103 bool closeUrl();
00104
00105 KTextEditor::Editor *editor ();
00106
00107
00108
00109
00110 public:
00114 virtual QWidget *widget();
00115
00116 public:
00117 bool readOnly () const { return m_bReadOnly; }
00118 bool browserView () const { return m_bBrowserView; }
00119 bool singleViewMode () const { return m_bSingleViewMode; }
00120 KateBrowserExtension *browserExtension () { return m_extension; }
00121 static bool simpleMode ();
00122
00123 private:
00124
00125 bool m_bSingleViewMode;
00126 bool m_bBrowserView;
00127 bool m_bReadOnly;
00128 KateBrowserExtension *m_extension;
00129
00130
00131
00132
00133 public:
00134 KTextEditor::View *createView( QWidget *parent );
00135 const QList<KTextEditor::View*> &views () const;
00136
00137 virtual KTextEditor::View* activeView() const { return m_activeView; }
00138
00139 KateView* activeKateView() const;
00140
00141 Q_SIGNALS:
00142 void activeViewSelectionChanged(KTextEditor::View* view);
00143
00144 private:
00145 QLinkedList<KateView*> m_views;
00146 QList<KTextEditor::View*> m_textEditViews;
00147 KTextEditor::View *m_activeView;
00148
00149
00150
00151
00152 public Q_SLOTS:
00153 virtual bool setText(const QString &);
00154 virtual bool setText(const QStringList& text);
00155 virtual bool clear ();
00156
00157 virtual bool insertText ( const KTextEditor::Cursor &position, const QString &s, bool block = false );
00158 virtual bool insertText ( const KTextEditor::Cursor &position, const QStringList &text, bool block = false );
00159
00160 virtual bool insertLine ( int line, const QString &s );
00161 virtual bool insertLines ( int line, const QStringList &s );
00162
00163 bool removeText ( const KTextEditor::Range &range, bool block = false );
00164 bool removeLine ( int line );
00165
00166 bool replaceText ( const KTextEditor::Range &range, const QString &s, bool block = false );
00167
00168
00169 bool replaceText (const KTextEditor::Range &r, const QStringList &l, bool b)
00170 { return KTextEditor::Document::replaceText (r, l, b); }
00171
00172 public:
00173 virtual QString text ( const KTextEditor::Range &range, bool blockwise = false ) const;
00174 virtual QStringList textLines ( const KTextEditor::Range& range, bool block = false ) const;
00175 virtual QString text() const;
00176 virtual QString line(int line) const;
00177 virtual QChar character(const KTextEditor::Cursor& position) const;
00178 int lines() const;
00179 virtual KTextEditor::Cursor documentEnd() const;
00180 int numVisLines() const;
00181 int totalCharacters() const;
00182 int lineLength(int line) const;
00183
00184 Q_SIGNALS:
00185 void charactersSemiInteractivelyInserted(const KTextEditor::Cursor& position, const QString& text);
00186
00187 public:
00188
00194 void editStart (Kate::EditSource editSource = Kate::NoEditSource);
00196 void editBegin (Kate::EditSource editSource = Kate::NoEditSource) { editStart(editSource); }
00201 void editEnd ();
00202
00203 void pushEditState();
00204 void popEditState();
00205
00206 bool startEditing () { editStart (Kate::ThirdPartyEdit); return true; }
00207 bool endEditing () { editEnd (); return true; }
00208
00209
00210
00211 void inputMethodStart();
00212 void inputMethodEnd();
00213
00214
00222 bool editInsertText ( int line, int col, const QString &s, Kate::EditSource editSource = Kate::NoEditSource );
00230 bool editRemoveText ( int line, int col, int len, Kate::EditSource editSource = Kate::NoEditSource );
00231
00240 bool editMarkLineAutoWrapped ( int line, bool autowrapped );
00241
00252 bool editWrapLine ( int line, int col, bool newLine = true, bool *newLineAdded = 0 );
00260 bool editUnWrapLine ( int line, bool removeLine = true, int length = 0 );
00261
00268 bool editInsertLine ( int line, const QString &s, Kate::EditSource editSource = Kate::NoEditSource );
00274 bool editRemoveLine ( int line, Kate::EditSource editSource = Kate::NoEditSource );
00275
00276 bool editRemoveLines ( int from, int to, Kate::EditSource editSource = Kate::NoEditSource );
00277
00284 bool wrapText (int startLine, int endLine);
00285
00286
00287 Q_SIGNALS:
00291 void editLineWrapped ( int line, int col, int len );
00292
00296 void editLineUnWrapped ( int line, int col );
00297
00298 public:
00299 void undoSafePoint();
00300
00301 bool undoDontMerge() const;
00302 void setUndoDontMerge(bool dontMerge);
00303
00304 bool undoAllowComplexMerge() const;
00305 void setUndoAllowComplexMerge(bool allow);
00306
00307 bool isEditRunning() const;
00308
00309 void setMergeAllEdits(bool merge);
00310
00311 private:
00312 int editSessionNumber;
00313 QStack<int> editStateStack;
00314 QStack<Kate::EditSource> m_editSources;
00315 bool editIsRunning;
00316
00317
00318
00319
00320 public Q_SLOTS:
00321 void undo ();
00322 void redo ();
00323
00324 public:
00325 uint undoCount () const;
00326 uint redoCount () const;
00327 KateEditHistory* history() const { return m_editHistory; }
00328
00329 private:
00330 KateUndoManager* m_undoManager;
00331 KateEditHistory* m_editHistory;
00332
00333 Q_SIGNALS:
00334 void undoChanged ();
00335
00336
00337
00338
00339 public:
00340 QVector<KTextEditor::Range> searchText(
00341 const KTextEditor::Range & range,
00342 const QString & pattern,
00343 const KTextEditor::Search::SearchOptions options);
00344
00345 KTextEditor::Search::SearchOptions supportedSearchOptions() const;
00346
00347 private:
00351 QWidget * dialogParent();
00352
00353
00354
00355
00356 public:
00362 virtual QString mode() const;
00363
00369 virtual QString highlightingMode() const;
00370
00375 virtual QStringList modes() const;
00376
00381 virtual QStringList highlightingModes() const;
00382
00388 virtual bool setMode(const QString &name);
00389
00395 virtual bool setHighlightingMode(const QString &name);
00402 virtual QString highlightingModeSection( int index ) const;
00403
00410 virtual QString modeSection( int index ) const;
00411
00412
00413
00414
00415
00416
00417 Q_SIGNALS:
00424 void modeChanged(KTextEditor::Document *document);
00425
00432 void highlightingModeChanged(KTextEditor::Document *document);
00433
00434
00435
00436
00437 public:
00438 void bufferHlChanged();
00439
00444 void setDontChangeHlOnSave();
00445
00449 void bomSetByUser();
00450
00451
00452
00453
00454 public:
00455 void readSessionConfig (const KConfigGroup&);
00456 void writeSessionConfig (KConfigGroup&);
00457 void readParameterizedSessionConfig (const KConfigGroup&, unsigned long configParameters);
00458 void writeParameterizedSessionConfig (KConfigGroup&, unsigned long configParameters);
00459
00460 Q_SIGNALS:
00461 void configChanged();
00462
00463
00464
00465
00466 public Q_SLOTS:
00467 void setMark( int line, uint markType );
00468 void clearMark( int line );
00469
00470 void addMark( int line, uint markType );
00471 void removeMark( int line, uint markType );
00472
00473 void clearMarks();
00474
00475 void requestMarkTooltip( int line, QPoint position );
00476
00478 bool handleMarkClick( int line );
00479
00481 bool handleMarkContextMenu( int line, QPoint position );
00482
00483 void setMarkPixmap( MarkInterface::MarkTypes, const QPixmap& );
00484
00485 void setMarkDescription( MarkInterface::MarkTypes, const QString& );
00486
00487 void setEditableMarks( uint markMask );
00488
00489 public:
00490 uint mark( int line );
00491 const QHash<int, KTextEditor::Mark*> &marks ();
00492 QPixmap markPixmap( MarkInterface::MarkTypes ) const;
00493 QString markDescription( MarkInterface::MarkTypes ) const;
00494 QColor markColor( MarkInterface::MarkTypes ) const;
00495 uint editableMarks() const;
00496
00497 Q_SIGNALS:
00498 void markToolTipRequested( KTextEditor::Document* document, KTextEditor::Mark mark, QPoint position, bool& handled );
00499
00500 void markContextMenuRequested( KTextEditor::Document* document, KTextEditor::Mark mark, QPoint pos, bool& handled );
00501
00502 void markClicked( KTextEditor::Document* document, KTextEditor::Mark mark, bool& handled );
00503
00504 void marksChanged( KTextEditor::Document* );
00505 void markChanged( KTextEditor::Document*, KTextEditor::Mark, KTextEditor::MarkInterface::MarkChangeAction );
00506
00507 private:
00508 QHash<int, KTextEditor::Mark*> m_marks;
00509 QHash<int,QPixmap> m_markPixmaps;
00510 QHash<int,QString> m_markDescriptions;
00511 uint m_editableMarks;
00512
00513
00514
00515
00516 public Q_SLOTS:
00517 bool printDialog ();
00518 bool print ();
00519
00520
00521
00522
00523 public:
00531 QString mimeType();
00532
00539 KMimeType::Ptr mimeTypeForContent();
00540
00541
00542
00543
00544 public:
00545 QString variable( const QString &name ) const;
00546
00547 Q_SIGNALS:
00548 void variableChanged( KTextEditor::Document*, const QString &, const QString & );
00549
00550 private:
00551 QMap<QString, QString> m_storedVariables;
00552
00553
00554
00555
00556 public:
00557 virtual void clearSmartInterface();
00558
00559 virtual int currentRevision() const;
00560 virtual void releaseRevision(int revision) const;
00561 virtual void useRevision(int revision = -1);
00562 virtual KTextEditor::Cursor translateFromRevision(const KTextEditor::Cursor& cursor, KTextEditor::SmartCursor::InsertBehavior insertBehavior = KTextEditor::SmartCursor::StayOnInsert) const;
00563 virtual KTextEditor::Range translateFromRevision(const KTextEditor::Range& range, KTextEditor::SmartRange::InsertBehaviors insertBehavior = KTextEditor::SmartRange::ExpandLeft | KTextEditor::SmartRange::ExpandRight) const;
00564
00565 virtual KTextEditor::SmartCursor* newSmartCursor(const KTextEditor::Cursor& position, KTextEditor::SmartCursor::InsertBehavior insertBehavior = KTextEditor::SmartCursor::MoveOnInsert);
00566 virtual void deleteCursors();
00567
00568 virtual KTextEditor::SmartRange* newSmartRange(const KTextEditor::Range& range, KTextEditor::SmartRange* parent = 0L, KTextEditor::SmartRange::InsertBehaviors insertBehavior = KTextEditor::SmartRange::DoNotExpand);
00569 virtual KTextEditor::SmartRange* newSmartRange(KTextEditor::SmartCursor* start, KTextEditor::SmartCursor* end, KTextEditor::SmartRange* parent = 0L, KTextEditor::SmartRange::InsertBehaviors insertBehavior = KTextEditor::SmartRange::DoNotExpand);
00570 virtual void unbindSmartRange(KTextEditor::SmartRange* range);
00571 virtual void deleteRanges();
00572
00573
00574 virtual void addHighlightToDocument(KTextEditor::SmartRange* topRange, bool supportDynamic);
00575 virtual const QList<KTextEditor::SmartRange*> documentHighlights() const;
00576 virtual void clearDocumentHighlights();
00577
00578 virtual void addHighlightToView(KTextEditor::View* view, KTextEditor::SmartRange* topRange, bool supportDynamic);
00579 virtual void removeHighlightFromView(KTextEditor::View* view, KTextEditor::SmartRange* topRange);
00580 virtual const QList<KTextEditor::SmartRange*> viewHighlights(KTextEditor::View* view) const;
00581 virtual void clearViewHighlights(KTextEditor::View* view);
00582
00583
00584 virtual void addActionsToDocument(KTextEditor::SmartRange* topRange);
00585 virtual const QList<KTextEditor::SmartRange*> documentActions() const;
00586 virtual void clearDocumentActions();
00587
00588 virtual void addActionsToView(KTextEditor::View* view, KTextEditor::SmartRange* topRange);
00589 virtual void removeActionsFromView(KTextEditor::View* view, KTextEditor::SmartRange* topRange);
00590 virtual const QList<KTextEditor::SmartRange*> viewActions(KTextEditor::View* view) const;
00591 virtual void clearViewActions(KTextEditor::View* view);
00592
00593 KateSmartManager* smartManager() const { return m_smartManager; }
00594
00595 Q_SIGNALS:
00596 void dynamicHighlightAdded(KateSmartRange* range);
00597 void dynamicHighlightRemoved(KateSmartRange* range);
00598 public Q_SLOTS:
00599 virtual void removeHighlightFromDocument(KTextEditor::SmartRange* topRange);
00600 virtual void removeActionsFromDocument(KTextEditor::SmartRange* topRange);
00601
00602 protected:
00603 virtual void attributeDynamic(KTextEditor::Attribute::Ptr a);
00604 virtual void attributeNotDynamic(KTextEditor::Attribute::Ptr a);
00605
00606 private:
00607
00608 virtual void rangeDeleted(KTextEditor::SmartRange* range);
00609
00610 KateSmartManager* m_smartManager;
00611 QList<KTextEditor::SmartRange*> m_documentHighlights;
00612 QList<KTextEditor::SmartRange*> m_documentDynamicHighlights;
00613 QList<KTextEditor::SmartRange*> m_documentActions;
00614
00615
00616
00617
00618 public:
00619
00620 virtual void setAnnotationModel( KTextEditor::AnnotationModel* model );
00621 virtual KTextEditor::AnnotationModel* annotationModel() const;
00622
00623 Q_SIGNALS:
00624 void annotationModelChanged( KTextEditor::AnnotationModel*, KTextEditor::AnnotationModel* );
00625
00626 private:
00627 KTextEditor::AnnotationModel* m_annotationModel;
00628
00629
00630
00631
00632 public:
00638 bool openFile ();
00639
00645 bool saveFile ();
00646
00647 void setReadWrite ( bool rw = true );
00648
00649 void setModified( bool m );
00650
00651 private:
00652 void activateDirWatch (const QString &useFileName = QString());
00653 void deactivateDirWatch ();
00654
00655 QString m_dirWatchFile;
00656
00657 public:
00661 bool typeChars ( KateView *type, const QString &chars );
00662
00666 inline int lastLine() const { return lines()-1; }
00667
00668
00669 void repaintViews(bool paintOnlyDirty = true);
00670
00671 KateHighlighting *highlight () const;
00672
00673 public Q_SLOTS:
00674 void tagLines(int start, int end);
00675 void tagLines(KTextEditor::Cursor start, KTextEditor::Cursor end);
00676
00677
00678 public Q_SLOTS:
00679 void exportAs(const QString&) { }
00680
00681 Q_SIGNALS:
00682 void preHighlightChanged(uint);
00683
00684 private Q_SLOTS:
00685 void internalHlChanged();
00686
00687 public:
00688 void addView(KTextEditor::View *);
00695 void removeView(KTextEditor::View *);
00696 void setActiveView(KTextEditor::View*);
00697
00698 bool ownedView(KateView *);
00699
00700 uint toVirtualColumn( const KTextEditor::Cursor& );
00701 void newLine( KateView*view );
00702 void backspace( KateView *view, const KTextEditor::Cursor& );
00703 void del( KateView *view, const KTextEditor::Cursor& );
00704 void transpose( const KTextEditor::Cursor& );
00705
00706 void paste ( KateView* view, QClipboard::Mode = QClipboard::Clipboard );
00707
00708 public:
00709 void indent ( KateView *view, uint line, int change );
00710 void comment ( KateView *view, uint line, uint column, int change );
00711 void align ( KateView *view, const KTextEditor::Range &range );
00712
00713 enum TextTransform { Uppercase, Lowercase, Capitalize };
00714
00722 void transform ( KateView *view, const KTextEditor::Cursor &, TextTransform );
00726 void joinLines( uint first, uint last );
00727
00728 private:
00729 bool removeStringFromBeginning(int line, const QString &str);
00730 bool removeStringFromEnd(int line, const QString &str);
00731
00741 bool nextNonSpaceCharPos(int &line, int &col);
00742
00750 bool previousNonSpaceCharPos(int &line, int &col);
00751
00756 void addStartLineCommentToSingleLine(int line, int attrib=0);
00761 bool removeStartLineCommentFromSingleLine(int line, int attrib=0);
00762
00766 void addStartStopCommentToSingleLine(int line, int attrib=0);
00770 bool removeStartStopCommentFromSingleLine(int line, int attrib=0);
00774 bool removeStartStopCommentFromRegion(const KTextEditor::Cursor &start, const KTextEditor::Cursor &end, int attrib=0);
00775
00780 void addStartStopCommentToSelection( KateView *view, int attrib=0 );
00784 void addStartLineCommentToSelection( KateView *view, int attrib=0 );
00785
00792 bool removeStartStopCommentFromSelection( KateView *view, int attrib=0 );
00796 bool removeStartLineCommentFromSelection( KateView *view, int attrib=0 );
00797
00798 public:
00799 QString getWord( const KTextEditor::Cursor& cursor );
00800
00801 public:
00802 void newBracketMark( const KTextEditor::Cursor& start, KTextEditor::Range& bm, int maxLines = -1 );
00803 bool findMatchingBracket( KTextEditor::Range& range, int maxLines = -1 );
00804
00805 private:
00806 void guiActivateEvent( KParts::GUIActivateEvent *ev );
00807
00808 public:
00809 const QString &documentName () const { return m_docName; }
00810
00811 void setDocName (QString docName);
00812
00813 void lineInfo (KateLineInfo *info, unsigned int line);
00814
00815 KateCodeFoldingTree *foldingTree ();
00816
00817 public:
00821 bool isModifiedOnDisc() { return m_modOnHd; }
00822
00823 void setModifiedOnDisk( ModifiedOnDiskReason reason );
00824
00825 void setModifiedOnDiskWarning ( bool on );
00826
00827 public Q_SLOTS:
00832 void slotModifiedOnDisk( KTextEditor::View *v = 0 );
00833
00837 bool documentReload ();
00838
00839 bool documentSave ();
00840 bool documentSaveAs ();
00841
00842 virtual bool save();
00843 public:
00844 virtual bool saveAs( const KUrl &url );
00845 private:
00846 bool m_saveAs;
00847 Q_SIGNALS:
00854 void modifiedOnDisk (KTextEditor::Document *doc, bool isModified, KTextEditor::ModificationInterface::ModifiedOnDiskReason reason);
00855
00856 public:
00857 void ignoreModifiedOnDiskOnce();
00858
00859 private:
00860 int m_isasking;
00861
00862
00863 public:
00864 bool setEncoding (const QString &e);
00865 const QString &encoding() const;
00866 void setProberTypeForEncodingAutoDetection (KEncodingProber::ProberType);
00867 KEncodingProber::ProberType proberTypeForEncodingAutoDetection() const;
00868
00869
00870 public Q_SLOTS:
00871 void setWordWrap (bool on);
00872 void setWordWrapAt (uint col);
00873
00874 public:
00875 bool wordWrap() const;
00876 uint wordWrapAt() const;
00877
00878 public Q_SLOTS:
00879 void setPageUpDownMovesCursor(bool on);
00880
00881 public:
00882 bool pageUpDownMovesCursor() const;
00883
00884
00885 public:
00886 uint getRealLine(unsigned int virtualLine);
00887 uint getVirtualLine(unsigned int realLine);
00888 uint visibleLines ();
00889 KateTextLine::Ptr kateTextLine(uint i);
00890 KateTextLine::Ptr plainKateTextLine(uint i);
00891
00892 Q_SIGNALS:
00893 void codeFoldingUpdated();
00894 void aboutToRemoveText(const KTextEditor::Range&);
00895 void textRemoved();
00896
00897 private Q_SLOTS:
00898 void slotModOnHdDirty (const QString &path);
00899 void slotModOnHdCreated (const QString &path);
00900 void slotModOnHdDeleted (const QString &path);
00901
00902 private:
00910 bool createDigest ( QByteArray &result );
00911
00915 QString reasonedMOHString() const;
00916
00923 void removeTrailingSpace(int line);
00924 inline void blockRemoveTrailingSpaces(bool block)
00925 { m_blockRemoveTrailingSpaces = block; }
00926
00927 private:
00929 bool m_blockRemoveTrailingSpaces;
00930
00931 public:
00932 void updateFileType (const QString &newType, bool user = false);
00933
00934 QString fileType () const { return m_fileType; }
00935
00936
00937
00938
00939 private:
00940
00941 KateBuffer *m_buffer;
00942
00943
00944 KateAutoIndent *const m_indenter;
00945
00946 bool hlSetByUser;
00947 bool m_bomSetByUser;
00948
00949 bool m_modOnHd;
00950 ModifiedOnDiskReason m_modOnHdReason;
00951 QByteArray m_digest;
00952
00953 QString m_docName;
00954 int m_docNameNumber;
00955
00956
00957 QString m_fileType;
00958 bool m_fileTypeSetByUser;
00959
00963 bool m_reloading;
00964
00965 public Q_SLOTS:
00966 void slotQueryClose_save(bool *handled, bool* abortClosing);
00967
00968 public:
00969 virtual bool queryClose();
00970
00971 void makeAttribs (bool needInvalidate = true);
00972
00973 static bool checkOverwrite( KUrl u, QWidget *parent );
00974
00978 public:
00979 KateDocumentConfig *config() { return m_config; }
00980 KateDocumentConfig *config() const { return m_config; }
00981
00982 void updateConfig ();
00983
00984 private:
00985 KateDocumentConfig *m_config;
00986
00991 private:
00995 void readDirConfig ();
00996
01001 void readVariables(bool onlyViewAndRenderer = false);
01002
01007 void readVariableLine( QString t, bool onlyViewAndRenderer = false );
01011 void setViewVariable( QString var, QString val );
01017 static bool checkBoolValue( QString value, bool *result );
01023 static bool checkIntValue( QString value, int *result );
01028 static bool checkColorValue( QString value, QColor &col );
01029
01033 static QRegExp kvLine;
01034 static QRegExp kvLineWildcard;
01035 static QRegExp kvLineMime;
01036 static QRegExp kvVar;
01037
01038 bool s_fileChangedDialogsActivated;
01039
01040
01041
01042
01043 public:
01044 QStringList configKeys() const;
01045 QVariant configValue(const QString &key);
01046 void setConfigValue(const QString &key, const QVariant &value);
01047
01048
01049 public:
01057 virtual bool insertTemplateTextImplementation ( const KTextEditor::Cursor &c, const QString &templateString,
01058 const QMap<QString,QString> &initialValues, QWidget *);
01059
01060
01061
01062
01063 public:
01064 virtual KTextEditor::Attribute::Ptr defaultStyle(const KTextEditor::HighlightInterface::DefaultStyle ds) const;
01065 virtual QList< KTextEditor::HighlightInterface::AttributeBlock > lineAttributes(const unsigned int line);
01066 virtual QStringList embeddedModes() const;
01067 virtual QString modeAt(const KTextEditor::Cursor& position);
01068
01069 protected Q_SLOTS:
01070 void dumpRegionTree();
01071
01072 private slots:
01073 void slotCompleted();
01074 void slotCanceled();
01075
01076 private:
01077 class LoadSaveFilterCheckPlugins;
01078
01079 private:
01080 bool m_savingToUrl;
01081 void setPreSavePostDialogFilterChecks(QStringList plugins) {m_preSavePostDialogFilterChecks=plugins;}
01082 QStringList m_preSavePostDialogFilterChecks;
01083 void setPostSaveFilterChecks(QStringList plugins) {m_postSaveFilterChecks=plugins;}
01084 QStringList m_postSaveFilterChecks;
01085 void setPostLoadFilterChecks(QStringList plugins) {m_postLoadFilterChecks=plugins;}
01086 QStringList m_postLoadFilterChecks;
01087 static LoadSaveFilterCheckPlugins* loadSaveFilterCheckPlugins();
01088
01089 public:
01090 QString defaultDictionary() const;
01091 QList<QPair<KTextEditor::SmartRange*, QString> > dictionaryRanges() const;
01092 bool isOnTheFlySpellCheckingEnabled() const;
01093
01094 QPair<KTextEditor::Range, QString> onTheFlyMisspelledItem(const KTextEditor::Cursor &cursor) const;
01095 QString dictionaryForMisspelledRange(const KTextEditor::Range& range) const;
01096 void clearMisspellingForWord(const QString& word);
01097
01098 public Q_SLOTS:
01099 void clearDictionaryRanges();
01100 void setDictionary(const QString& dict, const KTextEditor::Range &range);
01101 void revertToDefaultDictionary(const KTextEditor::Range &range);
01102 void setDefaultDictionary(const QString& dict);
01103 void onTheFlySpellCheckingEnabled(bool enable);
01104 void respellCheckBlock(int start, int end) {respellCheckBlock(this,start,end);}
01105 void refreshOnTheFlyCheck(const KTextEditor::Range &range = KTextEditor::Range::invalid());
01106
01107 protected Q_SLOTS:
01108 void dictionaryRangeEliminated(KTextEditor::SmartRange *smartRange);
01109 void deleteDiscardedSmartRanges();
01110
01111 Q_SIGNALS:
01112 void respellCheckBlock(KateDocument *document,int start, int end);
01113 void dictionaryRangesPresent(bool yesNo);
01114 void defaultDictionaryChanged(KateDocument *document);
01115
01116 public:
01117 bool containsCharacterEncoding(const KTextEditor::Range& range);
01118
01119 typedef QList<QPair<int, int> > OffsetList;
01120
01121 int computePositionWrtOffsets(const OffsetList& offsetList, int pos);
01122
01127 QString decodeCharacters(const KTextEditor::Range& range,
01128 KateDocument::OffsetList& decToEncOffsetList,
01129 KateDocument::OffsetList& encToDecOffsetList);
01130 void replaceCharactersByEncoding(const KTextEditor::Range& range);
01131
01132 enum EncodedCharaterInsertionPolicy {EncodeAlways, EncodeWhenPresent, EncodeNever};
01133
01134 protected:
01135 KateOnTheFlyChecker *m_onTheFlyChecker;
01136 QString m_defaultDictionary;
01137 QList<QPair<KTextEditor::SmartRange*, QString> > m_dictionaryRanges;
01138 QList<KTextEditor::SmartRange*> m_discardedSmartRanges;
01139 KTextEditor::SmartRangeNotifier *m_dictionaryRangeNotifier;
01140
01141 KTextEditor::SmartRangeNotifier* dictionaryRangeNotifier();
01142 };
01143
01144 #endif
01145
01146
01147