• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kate
 

kate

  • kate
  • part
katesearch.h
1 /* This file is part of the KDE libraries
2  Copyright (C) 2004-2005 Anders Lund <anders@alweb.dk>
3  Copyright (C) 2002 John Firebaugh <jfirebaugh@kde.org>
4  Copyright (C) 2001-2004 Christoph Cullmann <cullmann@kde.org>
5  Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
6  Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License version 2 as published by the Free Software Foundation.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 
23 #ifndef __KATE_SEARCH_H__
24 #define __KATE_SEARCH_H__
25 
26 #include "katecursor.h"
27 #include "../interfaces/document.h"
28 
29 #include <kdialogbase.h>
30 
31 #include <tqstring.h>
32 #include <tqregexp.h>
33 #include <tqstringlist.h>
34 #include <tqvaluelist.h>
35 
36 class KateView;
37 class KateDocument;
38 class KateSuperRangeList;
39 
40 class KActionCollection;
41 
42 class KateSearch : public TQObject
43 {
44  Q_OBJECT
45 
46  friend class KateDocument;
47 
48  private:
49  class SearchFlags
50  {
51  public:
52  bool caseSensitive :1;
53  bool wholeWords :1;
54  bool fromBeginning :1;
55  bool backward :1;
56  bool selected :1;
57  bool prompt :1;
58  bool replace :1;
59  bool finished :1;
60  bool regExp :1;
61  bool useBackRefs :1;
62  };
63 
64  class SConfig
65  {
66  public:
67  SearchFlags flags;
68  KateTextCursor cursor;
69  KateTextCursor wrappedEnd; // after wraping around, search/replace until here
70  bool wrapped; // have we allready wrapped around ?
71  bool showNotFound; // pop up annoying dialogs?
72  uint matchedLength;
73  KateTextCursor selBegin;
74  KateTextCursor selEnd;
75  };
76 
77  public:
78  enum Dialog_results {
79  srCancel = KDialogBase::Cancel,
80  srAll = KDialogBase::User1,
81  srLast = KDialogBase::User2,
82  srNo = KDialogBase::User3,
83  srYes = KDialogBase::Ok
84  };
85 
86  public:
87  KateSearch( KateView* );
88  ~KateSearch();
89 
90  void createActions( KActionCollection* );
91 
92  public slots:
93  void find();
105  void find( const TQString &pattern, long flags, bool add=true, bool shownotfound=false );
106  void replace();
115  void replace( const TQString &pattern, const TQString &replacement, long flags );
116  void findAgain( bool reverseDirection );
117 
118  private slots:
119  void replaceSlot();
120  void slotFindNext() { findAgain( false ); }
121  void slotFindPrev() { findAgain( true ); }
122 
123  private:
124  static void addToList( TQStringList&, const TQString& );
125  static void addToSearchList( const TQString& s ) { addToList( s_searchList, s ); }
126  static void addToReplaceList( const TQString& s ) { addToList( s_replaceList, s ); }
127  static TQStringList s_searchList;
128  static TQStringList s_replaceList;
129  static TQString s_pattern;
130 
131  void search( SearchFlags flags );
132  void wrapSearch();
133  bool askContinue();
134 
135  void findAgain();
136  void promptReplace();
137  void replaceAll();
138  void replaceOne();
139  void skipOne();
140 
141  TQString getSearchText();
142  KateTextCursor getCursor( SearchFlags flags );
143  bool doSearch( const TQString& text );
144  void exposeFound( KateTextCursor &cursor, int slen );
145 
146  inline KateView* view() { return m_view; }
147  inline KateDocument* doc() { return m_doc; }
148 
149  KateView* m_view;
150  KateDocument* m_doc;
151 
152  KateSuperRangeList* m_arbitraryHLList;
153 
154  SConfig s;
155 
156  TQValueList<SConfig> m_searchResults;
157  int m_resultIndex;
158 
159  int replaces;
160  TQDialog* replacePrompt;
161  TQString m_replacement;
162  TQRegExp m_re;
163 };
164 
168 class KateReplacePrompt : public KDialogBase
169 {
170  Q_OBJECT
171 
172  public:
177  KateReplacePrompt(TQWidget *parent);
178 
179  signals:
183  void clicked();
184 
185  protected slots:
189  void slotOk ();
190 
194  void slotClose ();
195 
199  void slotUser1 ();
200 
204  void slotUser2 ();
205 
209  void slotUser3 ();
210 
215  void done (int result);
216 };
217 
218 class SearchCommand : public Kate::Command, public Kate::CommandExtension
219 {
220  public:
221  SearchCommand() : m_ifindFlags(0) {;}
222  bool exec(class Kate::View *view, const TQString &cmd, TQString &errorMsg);
223  bool help(class Kate::View *, const TQString &, TQString &);
224  TQStringList cmds();
225  bool wantsToProcessText( const TQString &/*cmdname*/ );
226  void processText( Kate::View *view, const TQString& text );
227 
228  private:
232  void ifindInit( const TQString &cmd );
236  void ifindClear();
237 
238  long m_ifindFlags;
239 };
240 
241 #endif
242 
243 // kate: space-indent on; indent-width 2; replace-tabs on;
KateTextCursor
Simple cursor class with no document pointer.
Definition: katecursor.h:33
KActionCollection
KDialogBase::Ok
Ok
Kate::CommandExtension
Extension to the Command interface, allowing to interact with commands during typing.
Definition: document.h:129
Kate::View
The Kate::View text editor interface.
Definition: view.h:42
KDialogBase::Cancel
Cancel
KDialogBase
KDialogBase::User1
User1
KateReplacePrompt
simple replace prompt dialog
Definition: katesearch.h:168
KStdAccel::replace
const KShortcut & replace()
KDialogBase::User2
User2
Kate::Command
Kate Commands.
Definition: document.h:96
KStdAccel::find
const KShortcut & find()
KDialogBase::User3
User3

kate

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

kate

Skip menu "kate"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kate by doxygen 1.8.13
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |