# kate Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# katesearch.h

    00001 /* This file is part of the KDE libraries
    00002    Copyright (C) 2002 John Firebaugh <jfirebaugh@kde.org>
    00003    Copyright (C) 2001-2004 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_SEARCH_H__
    00023 #define __KATE_SEARCH_H__
    00024
    00025 #include "katecursor.h"
    00026 #include "../interfaces/document.h"
    00027
    00028 #include <kdialogbase.h>
    00029
    00030 #include <qstring.h>
    00031 #include <qregexp.h>
    00032 #include <qstringlist.h>
    00033 #include <qvaluelist.h>
    00034
    00035 class KateView;
    00036 class KateDocument;
    00037 class KateSuperRangeList;
    00038
    00039 class KActionCollection;
    00040
    00041 class KateSearch : public QObject
    00042 {
    00043   Q_OBJECT
    00044
    00045   friend class KateDocument;
    00046
    00047   private:
    00048     class SearchFlags
    00049     {
    00050       public:
    00051         bool caseSensitive     :1;
    00052         bool wholeWords        :1;
    00053         bool fromBeginning     :1;
    00054         bool backward          :1;
    00055         bool selected          :1;
    00056         bool prompt            :1;
    00057         bool replace           :1;
    00058         bool finished          :1;
    00059         bool regExp            :1;
    00060         bool useBackRefs       :1;
    00061     };
    00062
    00063     class SConfig
    00064     {
    00065       public:
    00066         SearchFlags flags;
    00067         KateTextCursor cursor;
    00068         KateTextCursor wrappedEnd; // after wraping around, search/replace until here
    00069         bool wrapped; // have we allready wrapped around ?
    00070         bool showNotFound; // pop up annoying dialogs?
    00071         uint matchedLength;
    00072         KateTextCursor selBegin;
    00073         KateTextCursor selEnd;
    00074     };
    00075
    00076   public:
    00077     enum Dialog_results {
    00078       srCancel = KDialogBase::Cancel,
    00079       srAll = KDialogBase::User1,
    00080       srLast = KDialogBase::User2,
    00081       srNo = KDialogBase::User3,
    00082       srYes = KDialogBase::Ok
    00083     };
    00084
    00085   public:
    00086     KateSearch( KateView* );
    00087     ~KateSearch();
    00088
    00089     void createActions( KActionCollection* );
    00090
    00091   public slots:
    00092     void find();
    00104     void find( const QString &pattern, long flags, bool add=true, bool shownotfound=false );
    00105     void replace();
    00114     void replace( const QString &pattern, const QString &replacement, long flags );
    00115     void findAgain( bool back );
    00116
    00117   private slots:
    00118     void replaceSlot();
    00119     void slotFindNext() { findAgain( false ); }
    00120     void slotFindPrev() { findAgain( true );  }
    00121
    00122   private:
    00123     static void addToList( QStringList&, const QString& );
    00124     static void addToSearchList( const QString& s )  { addToList( s_searchList, s ); }
    00125     static void addToReplaceList( const QString& s ) { addToList( s_replaceList, s ); }
    00126     static QStringList s_searchList;
    00127     static QStringList s_replaceList;
    00128     static QString s_pattern;
    00129
    00130     void search( SearchFlags flags );
    00131     void wrapSearch();
    00132     bool askContinue();
    00133
    00134     void findAgain();
    00135     void promptReplace();
    00136     void replaceAll();
    00137     void replaceOne();
    00138     void skipOne();
    00139
    00140     QString getSearchText();
    00141     KateTextCursor getCursor();
    00142     bool doSearch( const QString& text );
    00143     void exposeFound( KateTextCursor &cursor, int slen );
    00144
    00145     inline KateView* view()    { return m_view; }
    00146     inline KateDocument* doc() { return m_doc;  }
    00147
    00148     KateView*     m_view;
    00149     KateDocument* m_doc;
    00150
    00151     KateSuperRangeList* m_arbitraryHLList;
    00152
    00153     SConfig s;
    00154
    00155     QValueList<SConfig> m_searchResults;
    00156     int                 m_resultIndex;
    00157
    00158     int           replaces;
    00159     QDialog*      replacePrompt;
    00160     QString m_replacement;
    00161     QRegExp m_re;
    00162 };
    00163
    00167 class KateReplacePrompt : public KDialogBase
    00168 {
    00169   Q_OBJECT
    00170
    00171   public:
    00176     KateReplacePrompt(QWidget *parent);
    00177
    00178   signals:
    00182     void clicked();
    00183
    00184   protected slots:
    00188     void slotOk ();
    00189
    00193     void slotClose ();
    00194
    00198     void slotUser1 ();
    00199
    00203     void slotUser2 ();
    00204
    00208     void slotUser3 ();
    00209
    00214     void done (int result);
    00215 };
    00216
    00217 class SearchCommand : public Kate::Command, public Kate::CommandExtension
    00218 {
    00219   public:
    00220     SearchCommand() : m_ifindFlags(0) {;}
    00221     bool exec(class Kate::View *view, const QString &cmd, QString &errorMsg);
    00222     bool help(class Kate::View *, const QString &, QString &);
    00223     QStringList cmds();
    00224     bool wantsToProcessText( const QString &/*cmdname*/ );
    00225     void processText( Kate::View *, const QString& );
    00226
    00227   private:
    00231     void ifindInit( const QString &cmd );
    00235     void ifindClear();
    00236
    00237     long m_ifindFlags;
    00238 };
    00239
    00240 #endif
    00241
    00242 // kate: space-indent on; indent-width 2; replace-tabs on;

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:38 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003