[Monodevelop-patches-list] r2607 - in trunk/MonoDevelop/Core/src/MonoDevelop.Base: . Commands Gui Gui/ContentInterfaces Gui/Dialogs Gui/Search Gui/Search/DocumentIterator Gui/Search/SearchResult Gui/Search/SearchStrategy Gui/Search/TextIterator Services/ParserService
Lluis Sanchez <lluis@ximian.com>
lluis at mono-cvs.ximian.com
Mon Jun 27 17:13:48 EDT 2005
Author: lluis
Date: 2005-06-27 17:13:48 -0400 (Mon, 27 Jun 2005)
New Revision: 2607
Added:
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/SearchCommands.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/IBookmarkBuffer.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/ITextBuffer.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReplaceDialog.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReplaceInFilesDialog.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DefaultFind.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/AllOpenDocumentIterator.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/CurrentDocumentIterator.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/DirectoryDocumentIterator.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/FileDocumentInformation.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/IDocumentInformation.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/IDocumentIterator.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/ReverseDocumentIterator.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/WholeProjectDocumentIterator.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/IFind.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/ISearchableDocument.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/ITextBufferStrategy.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchOptions.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchReplaceInFilesManager.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchReplaceManager.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchReplaceUtilities.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchResult/
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchResult/DefaultSearchResult.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchResult/ISearchResult.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/BruteForceSearchStrategy.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/ISearchStrategy.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/KMPSearchStrategy.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/RegExSearchStrategy.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/WildcardSearchStrategy.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/TextIterator/
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/TextIterator/ExtendedStreamReader.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/TextIterator/ForwardTextFileIterator.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/TextIterator/ForwardTextIterator.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/TextIterator/ITextIterator.cs
Removed:
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/IBookmarkOperations.cs
Modified:
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Base.glade
trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/IEditable.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Makefile.am
trunk/MonoDevelop/Core/src/MonoDevelop.Base/MonoDevelopCore.addin.xml
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/DefaultParserService.cs
Log:
2005-06-27 Lluis Sanchez Gual <lluis at novell.com>
* Services/ParserService/DefaultParserService.cs: Don't get the current
file text if we are not going to be able to parse it.
* Gui/Search/*.cs: Moved here search/replace stuff from the editor addin.
* Gui/ContentInterfaces.cs:
* Base.glade: Added search/replace dialogs.
* Makefile.am: Added new files.
* MonoDevelopCore.addin.xml: Registered search/replace commands.
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Base.glade
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Base.glade 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Base.glade 2005-06-27 21:13:48 UTC (rev 2607)
@@ -5453,4 +5453,1917 @@
</child>
</widget>
+<widget class="GtkDialog" id="ReplaceDialogWidget">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Replace Dialog</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="has_separator">True</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area2">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="closeButton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-close</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-7</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="replaceAllButton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">0</property>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment4">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox12">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image4">
+ <property name="visible">True</property>
+ <property name="stock">gtk-find-and-replace</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">R_eplace All</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="replaceButton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">0</property>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox11">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image3">
+ <property name="visible">True</property>
+ <property name="stock">gtk-find-and-replace</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Replace</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="findButton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-find</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox15">
+ <property name="border_width">6</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox13">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Find:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="searchPatternEntry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="findHelpButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">></property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox14">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Replace:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="replacePatternEntry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="replaceHelpButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">></property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="ignoreCaseCheckBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Case sensitive</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="searchWholeWordOnlyCheckBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Whole words only</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox16">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkCheckButton" id="useSpecialSearchStrategyCheckBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Use special search strategy:</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="specialSearchStrategyComboBox">
+ <property name="visible">True</property>
+ <property name="add_tearoffs">False</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox17">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="searchLocationLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Search in:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="searchLocationComboBox">
+ <property name="visible">True</property>
+ <property name="add_tearoffs">False</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+<widget class="GtkDialog" id="FindInFilesDialogWidget">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Find Dialog</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="has_separator">True</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area2">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="stopButton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-stop</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="closeButton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-close</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-7</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="findButton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-find</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox15">
+ <property name="border_width">6</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox13">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Find:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="searchPatternEntry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="findHelpButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">></property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox18">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Filemask:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="fileMaskTextBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">False</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox19">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Directory:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="directoryTextBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">False</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="browseButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">...</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="includeSubdirectoriesCheckBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Recurse subdirectories</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="ignoreCaseCheckBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Case sensitive</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="searchWholeWordOnlyCheckBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Whole word only</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox16">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkCheckButton" id="useSpecialSearchStrategyCheckBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Use special search strategy:</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="specialSearchStrategyComboBox">
+ <property name="visible">True</property>
+ <property name="add_tearoffs">False</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox17">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="searchLocationLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Search in:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="searchLocationComboBox">
+ <property name="visible">True</property>
+ <property name="add_tearoffs">False</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+<widget class="GtkDialog" id="ReplaceInFilesDialogWidget">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Replace Dialog</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="has_separator">True</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area2">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="stopButton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-stop</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="closeButton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-close</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-7</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="replaceAllButton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">0</property>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment4">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox12">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image4">
+ <property name="visible">True</property>
+ <property name="stock">gtk-find-and-replace</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">R_eplace All</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="findButton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-find</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox15">
+ <property name="border_width">6</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox13">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Find:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="searchPatternEntry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="findHelpButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">></property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox14">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Replace:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="replacePatternEntry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="replaceHelpButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">></property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox18">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Filemask:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="fileMaskTextBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">False</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox19">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Directory:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="directoryTextBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">False</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="browseButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">...</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="includeSubdirectoriesCheckBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Recurse subdirectories</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="ignoreCaseCheckBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Case sensitive</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="searchWholeWordOnlyCheckBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Whole word only</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox16">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkCheckButton" id="useSpecialSearchStrategyCheckBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Use special search strategy:</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="specialSearchStrategyComboBox">
+ <property name="visible">True</property>
+ <property name="add_tearoffs">False</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox17">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="searchLocationLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Search in:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="searchLocationComboBox">
+ <property name="visible">True</property>
+ <property name="add_tearoffs">False</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+<widget class="GtkDialog" id="FindDialogWidget">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Find Dialog</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="has_separator">True</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area2">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="closeButton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-close</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-7</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="markAllButton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">0</property>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox10">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="stock">gtk-find</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Mark All</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="findButton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-find</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox15">
+ <property name="border_width">6</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox13">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Find:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="searchPatternEntry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="findHelpButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">></property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="ignoreCaseCheckBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Case sensitive</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="searchWholeWordOnlyCheckBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Whole word only</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox16">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkCheckButton" id="useSpecialSearchStrategyCheckBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Use special search strategy:</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="specialSearchStrategyComboBox">
+ <property name="visible">True</property>
+ <property name="add_tearoffs">False</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox17">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="searchLocationLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Search in:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="searchLocationComboBox">
+ <property name="visible">True</property>
+ <property name="add_tearoffs">False</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
</glade-interface>
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-06-27 21:13:48 UTC (rev 2607)
@@ -1,3 +1,14 @@
+2005-06-27 Lluis Sanchez Gual <lluis at novell.com>
+
+ * Services/ParserService/DefaultParserService.cs: Don't get the current
+ file text if we are not going to be able to parse it.
+ * Gui/Search/*.cs: Moved here search/replace stuff from the editor addin.
+ * Gui/ContentInterfaces.cs:
+ * Base.glade: Added search/replace dialogs.
+ * Makefile.am: Added new files.
+ * MonoDevelopCore.addin.xml: Registered search/replace commands.
+
+
2005-06-15 John Luke <john.luke at gmail.com>
* Services/File/RecentFiles.cs: catch exception when writing to
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/SearchCommands.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/SearchCommands.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/SearchCommands.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,82 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+
+using MonoDevelop.Gui;
+using MonoDevelop.Gui.Dialogs;
+using MonoDevelop.Gui.Search;
+
+namespace MonoDevelop.Commands
+{
+ public enum SearchCommands
+ {
+ Find,
+ FindNext,
+ FindPrevious,
+ Replace,
+ FindInFiles,
+ FindSelection,
+ FindBox,
+ ReplaceInFiles
+ }
+
+ public class FindInFilesHandler : CommandHandler
+ {
+ public static void SetSearchPattern ()
+ {
+ IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
+ if (window != null && window.ViewContent is ITextBuffer)
+ {
+ string selectedText = ((ITextBuffer)window.ViewContent).SelectedText;
+ if (selectedText != null && selectedText.Length > 0)
+ SearchReplaceInFilesManager.SearchOptions.SearchPattern = selectedText.Split ('\n')[0];
+ }
+ }
+
+ protected override void Run ()
+ {
+ SetSearchPattern ();
+ if (SearchReplaceInFilesManager.ReplaceDialog != null) {
+ if (SearchReplaceInFilesManager.ReplaceDialog.replaceMode == false) {
+ SearchReplaceInFilesManager.ReplaceDialog.SetSearchPattern(SearchReplaceInFilesManager.SearchOptions.SearchPattern);
+ SearchReplaceInFilesManager.ReplaceDialog.Present ();
+ } else {
+ SearchReplaceInFilesManager.ReplaceDialog.Destroy ();
+ ReplaceInFilesDialog rd = new ReplaceInFilesDialog (false);
+ rd.ShowAll ();
+ }
+ } else {
+ ReplaceInFilesDialog rd = new ReplaceInFilesDialog(false);
+ rd.ShowAll();
+ }
+ }
+ }
+
+ public class ReplaceInFilesHandler : CommandHandler
+ {
+ protected override void Run()
+ {
+ FindInFilesHandler.SetSearchPattern ();
+
+ if (SearchReplaceInFilesManager.ReplaceDialog != null) {
+ if (SearchReplaceInFilesManager.ReplaceDialog.replaceMode == true) {
+ SearchReplaceInFilesManager.ReplaceDialog.SetSearchPattern(SearchReplaceInFilesManager.SearchOptions.SearchPattern);
+ SearchReplaceInFilesManager.ReplaceDialog.Present ();
+ } else {
+ SearchReplaceInFilesManager.ReplaceDialog.Destroy ();
+ ReplaceInFilesDialog rd = new ReplaceInFilesDialog (true);
+ rd.ShowAll ();
+ }
+ } else {
+ ReplaceInFilesDialog rd = new ReplaceInFilesDialog (true);
+ rd.ShowAll ();
+ }
+ }
+ }
+
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/IBookmarkBuffer.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/IBookmarkBuffer.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/IBookmarkBuffer.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,39 @@
+//
+// IBookmarkBuffer.cs
+//
+// Author:
+// Lluis Sanchez Gual
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace MonoDevelop.Gui
+{
+ public interface IBookmarkBuffer: ITextBuffer
+ {
+ void SetBookmarked (object position, bool mark);
+ bool IsBookmarked (object position);
+ void PrevBookmark ();
+ void NextBookmark ();
+ void ClearBookmarks ();
+ }
+}
Deleted: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/IBookmarkOperations.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/IBookmarkOperations.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/IBookmarkOperations.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -1,8 +0,0 @@
-namespace MonoDevelop.Gui {
- public interface IBookmarkOperations {
- void ToggleBookmark ();
- void PrevBookmark ();
- void NextBookmark ();
- void ClearBookmarks ();
- }
-}
\ No newline at end of file
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/IEditable.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/IEditable.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/IEditable.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -7,13 +7,13 @@
namespace MonoDevelop.Gui
{
- public interface IEditable
+ public interface IEditable: ITextBuffer
{
IClipboardHandler ClipboardHandler {
get;
}
- string Text {
+ new string Text {
get;
set;
}
@@ -21,5 +21,6 @@
void Undo();
void Redo();
+ new string SelectedText { get; set; }
}
}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/ITextBuffer.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/ITextBuffer.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/ITextBuffer.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,43 @@
+//
+// ITextBuffer.cs
+//
+// Author:
+// Lluis Sanchez Gual
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace MonoDevelop.Gui
+{
+ public interface ITextBuffer
+ {
+ string Text { get; }
+ string SelectedText { get; }
+
+ object CursorPosition { get; set; }
+ object GetPositionFromOffset (int offset);
+ int GetOffsetFromPosition (object position);
+
+ void Select (object startPosition, object endPosition);
+ void ShowPosition (object position);
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReplaceDialog.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReplaceDialog.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReplaceDialog.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,440 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Drawing;
+using System.ComponentModel;
+using System.Collections.Specialized;
+
+using MonoDevelop.Gui;
+using MonoDevelop.Core.Properties;
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+using MonoDevelop.Gui.Search;
+
+using Gtk;
+using Glade;
+
+namespace MonoDevelop.Gui.Dialogs
+{
+ public class ReplaceDialog
+ {
+ private const int historyLimit = 20;
+ private const char historySeparator = (char) 10;
+ // regular members
+ public bool replaceMode;
+ StringCollection findHistory = new StringCollection();
+ StringCollection replaceHistory = new StringCollection();
+
+ // services
+ static PropertyService propertyService = (PropertyService)ServiceManager.GetService(typeof(PropertyService));
+ static FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.GetService(typeof(FileUtilityService));
+ StringParserService stringParserService = (StringParserService)ServiceManager.GetService (typeof (StringParserService));
+
+ // gtk widgets
+ [Glade.Widget] Gtk.Entry searchPatternEntry;
+ [Glade.Widget] Gtk.Entry replacePatternEntry;
+ [Glade.Widget] Gtk.Button findHelpButton;
+ [Glade.Widget] Gtk.Button findButton;
+ [Glade.Widget] Gtk.Button markAllButton;
+ [Glade.Widget] Gtk.Button closeButton;
+ [Glade.Widget] Gtk.Button replaceButton;
+ [Glade.Widget] Gtk.Button replaceAllButton;
+ [Glade.Widget] Gtk.Button replaceHelpButton;
+ [Glade.Widget] Gtk.CheckButton ignoreCaseCheckBox;
+ [Glade.Widget] Gtk.CheckButton searchWholeWordOnlyCheckBox;
+ [Glade.Widget] Gtk.CheckButton useSpecialSearchStrategyCheckBox;
+ [Glade.Widget] Gtk.ComboBox specialSearchStrategyComboBox;
+ [Glade.Widget] Gtk.ComboBox searchLocationComboBox;
+ [Glade.Widget] Gtk.Label label1;
+ [Glade.Widget] Gtk.Label label2;
+ [Glade.Widget] Gtk.Label searchLocationLabel;
+ [Glade.Widget] Gtk.Dialog FindDialogWidget;
+ [Glade.Widget] Gtk.Dialog ReplaceDialogWidget;
+ Gtk.Dialog ReplaceDialogPointer;
+
+ void InitDialog ()
+ {
+ findButton.UseUnderline = true;
+ closeButton.UseUnderline = true;
+
+ //set up the size groups
+ SizeGroup labels = new SizeGroup(SizeGroupMode.Horizontal);
+ SizeGroup combos = new SizeGroup(SizeGroupMode.Horizontal);
+ SizeGroup options = new SizeGroup(SizeGroupMode.Horizontal);
+ SizeGroup helpButtons = new SizeGroup(SizeGroupMode.Horizontal);
+ SizeGroup checkButtons = new SizeGroup(SizeGroupMode.Horizontal);
+ labels.AddWidget(label1);
+ combos.AddWidget(searchPatternEntry);
+ helpButtons.AddWidget(findHelpButton);
+ checkButtons.AddWidget(ignoreCaseCheckBox);
+ checkButtons.AddWidget(searchWholeWordOnlyCheckBox);
+ checkButtons.AddWidget(useSpecialSearchStrategyCheckBox);
+ checkButtons.AddWidget(searchLocationLabel);
+ options.AddWidget(specialSearchStrategyComboBox);
+ options.AddWidget(searchLocationComboBox);
+
+ searchPatternEntry.Completion = new EntryCompletion ();
+ searchPatternEntry.Completion.Model = new ListStore (typeof (string));
+ searchPatternEntry.Completion.TextColumn = 0;
+
+ // set button sensitivity
+ findHelpButton.Sensitive = false;
+
+ // set replace dialog properties
+ if (replaceMode)
+ {
+ replacePatternEntry.Completion = new EntryCompletion ();
+ replacePatternEntry.Completion.Model = new ListStore (typeof (string));
+ replacePatternEntry.Completion.TextColumn = 0;
+
+ ReplaceDialogPointer = this.ReplaceDialogWidget;
+ // set the label properties
+ replaceButton.UseUnderline = true;
+ replaceAllButton.UseUnderline = true;
+
+ // set te size groups to include the replace dialog
+ labels.AddWidget(label2);
+ combos.AddWidget(replacePatternEntry);
+ helpButtons.AddWidget(replaceHelpButton);
+
+ replaceHelpButton.Sensitive = false;
+ }
+ else
+ {
+ ReplaceDialogPointer = this.FindDialogWidget;
+ markAllButton.UseUnderline = true;
+ }
+ ReplaceDialogPointer.TransientFor = (Gtk.Window)WorkbenchSingleton.Workbench;
+ }
+
+ public ReplaceDialog(bool replaceMode)
+ {
+ // some members needed to initialise this dialog based on replace mode
+ this.replaceMode = replaceMode;
+ string dialogName = (replaceMode) ? "ReplaceDialogWidget" : "FindDialogWidget";
+
+ // we must do it from *here* otherwise, we get this assembly, not the caller
+ Glade.XML glade = new XML (null, "Base.glade", dialogName, null);
+ glade.Autoconnect (this);
+ InitDialog ();
+
+ LoadHistoryValues();
+
+ ignoreCaseCheckBox.Active = !SearchReplaceManager.SearchOptions.IgnoreCase;
+ searchWholeWordOnlyCheckBox.Active = SearchReplaceManager.SearchOptions.SearchWholeWordOnly;
+
+ useSpecialSearchStrategyCheckBox.Active = SearchReplaceManager.SearchOptions.SearchStrategyType != SearchStrategyType.Normal;
+ useSpecialSearchStrategyCheckBox.Toggled += new EventHandler(SpecialSearchStrategyCheckBoxChangedEvent);
+
+ ListStore store = new ListStore (typeof (string));
+ store.AppendValues (GettextCatalog.GetString ("Wildcards"));
+ store.AppendValues (GettextCatalog.GetString ("Regular Expressions"));
+ specialSearchStrategyComboBox.Model = store;
+
+ CellRendererText cr = new CellRendererText ();
+ specialSearchStrategyComboBox.PackStart (cr, true);
+ specialSearchStrategyComboBox.AddAttribute (cr, "text", 0);
+
+ int index = 0;
+ switch (SearchReplaceManager.SearchOptions.SearchStrategyType) {
+ case SearchStrategyType.Normal:
+ case SearchStrategyType.Wildcard:
+ searchWholeWordOnlyCheckBox.Sensitive = true;
+ break;
+ case SearchStrategyType.RegEx:
+ searchWholeWordOnlyCheckBox.Sensitive = false;
+ index = 1;
+ break;
+ }
+ specialSearchStrategyComboBox.Active = index;
+ specialSearchStrategyComboBox.Changed += new EventHandler (OnSpecialSearchStrategyChanged);
+
+ store = new ListStore (typeof (string));
+ store.AppendValues (GettextCatalog.GetString ("Current File"));
+ store.AppendValues (GettextCatalog.GetString ("All Open Files"));
+ store.AppendValues (GettextCatalog.GetString ("Entire Project"));
+
+ searchLocationComboBox.Model = store;
+ searchLocationComboBox.PackStart (cr, true);
+ searchLocationComboBox.AddAttribute (cr, "text", 0);
+
+ index = 0;
+ switch (SearchReplaceManager.SearchOptions.DocumentIteratorType) {
+ case DocumentIteratorType.AllOpenFiles:
+ index = 1;
+ break;
+ case DocumentIteratorType.WholeCombine:
+ SearchReplaceManager.SearchOptions.DocumentIteratorType = DocumentIteratorType.CurrentDocument;
+ break;
+ }
+ searchLocationComboBox.Active = index;
+
+ searchPatternEntry.Text = SearchReplaceManager.SearchOptions.SearchPattern;
+
+ // insert event handlers
+ findButton.Clicked += new EventHandler(FindNextEvent);
+ closeButton.Clicked += new EventHandler(CloseDialogEvent);
+ ReplaceDialogPointer.Close += new EventHandler(CloseDialogEvent);
+ ReplaceDialogPointer.DeleteEvent += new DeleteEventHandler (OnDeleted);
+
+ if (replaceMode) {
+ ReplaceDialogPointer.Title = GettextCatalog.GetString ("Replace");
+ replaceButton.Clicked += new EventHandler(ReplaceEvent);
+ replaceAllButton.Clicked += new EventHandler(ReplaceAllEvent);
+ replacePatternEntry.Text = SearchReplaceManager.SearchOptions.ReplacePattern;
+ } else {
+ ReplaceDialogPointer.Title = GettextCatalog.GetString ("Find");
+ markAllButton.Clicked += new EventHandler(MarkAllEvent);
+ }
+ searchPatternEntry.SelectRegion(0, searchPatternEntry.Text.Length);
+
+ SpecialSearchStrategyCheckBoxChangedEvent(null, null);
+ SearchReplaceManager.ReplaceDialog = this;
+ }
+
+ protected void OnClosed()
+ {
+ SaveHistoryValues();
+ SearchReplaceManager.ReplaceDialog = null;
+ }
+
+ void OnDeleted (object o, DeleteEventArgs args)
+ {
+ // perform the standard closing windows event
+ OnClosed();
+ SearchReplaceManager.ReplaceDialog = null;
+ }
+
+ public void SetSearchPattern(string pattern)
+ {
+ searchPatternEntry.Text = pattern;
+ }
+
+ void OnSpecialSearchStrategyChanged (object o, EventArgs e)
+ {
+ if (specialSearchStrategyComboBox.Active != 1) {
+ searchWholeWordOnlyCheckBox.Sensitive = true;
+ } else {
+ searchWholeWordOnlyCheckBox.Sensitive = false;
+ }
+ }
+
+ void SetupSearchReplaceManager()
+ {
+ SearchReplaceManager.SearchOptions.SearchPattern = searchPatternEntry.Text;
+ if (replaceMode) {
+ SearchReplaceManager.SearchOptions.ReplacePattern = replacePatternEntry.Text;
+ }
+
+ SearchReplaceManager.SearchOptions.IgnoreCase = !ignoreCaseCheckBox.Active;
+ SearchReplaceManager.SearchOptions.SearchWholeWordOnly = searchWholeWordOnlyCheckBox.Active;
+
+ if (useSpecialSearchStrategyCheckBox.Active) {
+ switch (specialSearchStrategyComboBox.Active) {
+ case 0:
+ SearchReplaceManager.SearchOptions.SearchStrategyType = SearchStrategyType.Wildcard;
+ break;
+ case 1:
+ SearchReplaceManager.SearchOptions.SearchStrategyType = SearchStrategyType.RegEx;
+ break;
+ }
+ } else {
+ SearchReplaceManager.SearchOptions.SearchStrategyType = SearchStrategyType.Normal;
+ }
+
+ switch (searchLocationComboBox.Active) {
+ case 0:
+ SearchReplaceManager.SearchOptions.DocumentIteratorType = DocumentIteratorType.CurrentDocument;
+ break;
+ case 1:
+ SearchReplaceManager.SearchOptions.DocumentIteratorType = DocumentIteratorType.AllOpenFiles;
+ break;
+ case 2:
+ SearchReplaceManager.SearchOptions.DocumentIteratorType = DocumentIteratorType.WholeCombine;
+ break;
+ }
+ }
+
+ void FindNextEvent(object sender, EventArgs e)
+ {
+ if (searchPatternEntry.Text.Length == 0)
+ return;
+
+ SetupSearchReplaceManager();
+ SearchReplaceManager.FindNext();
+
+ AddSearchHistoryItem(findHistory, searchPatternEntry.Text);
+ }
+
+ void ReplaceEvent(object sender, EventArgs e)
+ {
+ if (searchPatternEntry.Text.Length == 0)
+ return;
+
+ SetupSearchReplaceManager();
+ SearchReplaceManager.Replace();
+
+ AddSearchHistoryItem(replaceHistory, replacePatternEntry.Text);
+ }
+
+ void ReplaceAllEvent(object sender, EventArgs e)
+ {
+ if (searchPatternEntry.Text.Length == 0)
+ return;
+
+ SetupSearchReplaceManager();
+ SearchReplaceManager.ReplaceAll();
+
+ AddSearchHistoryItem(replaceHistory, replacePatternEntry.Text);
+ }
+
+ void MarkAllEvent(object sender, EventArgs e)
+ {
+ if (searchPatternEntry.Text.Length == 0)
+ return;
+
+ SetupSearchReplaceManager();
+ SearchReplaceManager.MarkAll();
+
+ AddSearchHistoryItem(findHistory, searchPatternEntry.Text);
+ }
+
+ void CloseDialogEvent(object sender, EventArgs e)
+ {
+ ReplaceDialogPointer.Hide();
+ OnClosed ();
+ }
+
+ void SpecialSearchStrategyCheckBoxChangedEvent(object sender, EventArgs e)
+ {
+ if (useSpecialSearchStrategyCheckBox != null) {
+ specialSearchStrategyComboBox.Sensitive = useSpecialSearchStrategyCheckBox.Active;
+ if (useSpecialSearchStrategyCheckBox.Active) {
+ if (specialSearchStrategyComboBox.Active == 1) {
+ searchWholeWordOnlyCheckBox.Sensitive = false;
+ }
+ } else {
+ searchWholeWordOnlyCheckBox.Sensitive = true;
+ }
+ }
+ }
+
+ // generic method to add a string to a history item
+ private void AddSearchHistoryItem (StringCollection history, string toAdd)
+ {
+ // add the item to the find history
+ if (history.Contains(toAdd)) {
+ // remove it so it gets added at the top
+ history.Remove(toAdd);
+ }
+ // make sure there is only 20
+ if (history.Count == historyLimit) {
+ history.RemoveAt(historyLimit - 1);
+ }
+ history.Insert(0, toAdd);
+
+ // update the drop down for the combobox
+ ListStore store = new ListStore (typeof (string));
+ for (int i = 0; i < history.Count; i ++)
+ store.AppendValues (history[i]);
+
+ if (history == findHistory)
+ searchPatternEntry.Completion.Model = store;
+ else if( history == replaceHistory)
+ replacePatternEntry.Completion.Model = store;
+ }
+
+ // loads the history arrays from the property service
+ // NOTE: a newline character separates the search history strings
+ private void LoadHistoryValues()
+ {
+ object stringArray;
+ // set the history in properties
+ stringArray = propertyService.GetProperty("MonoDevelop.FindReplaceDialogs.FindHistory");
+
+ if (stringArray != null) {
+ string[] items = stringArray.ToString ().Split (historySeparator);
+ ListStore store = new ListStore (typeof (string));
+
+ if(items != null) {
+ findHistory.AddRange (items);
+ foreach (string i in items) {
+ store.AppendValues (i);
+ }
+ }
+
+ searchPatternEntry.Completion.Model = store;
+ }
+
+ // now do the replace history
+ stringArray = propertyService.GetProperty ("MonoDevelop.FindReplaceDialogs.ReplaceHistory");
+
+ if (replaceMode) {
+ if (stringArray != null) {
+ string[] items = stringArray.ToString ().Split (historySeparator);
+ ListStore store = new ListStore (typeof (string));
+
+ if(items != null) {
+ replaceHistory.AddRange (items);
+ foreach (string i in items) {
+ store.AppendValues (i);
+ }
+ }
+
+ replacePatternEntry.Completion.Model = store;
+ }
+ }
+ }
+
+ // saves the history arrays to the property service
+ // NOTE: a newline character separates the search history strings
+ private void SaveHistoryValues()
+ {
+ string[] stringArray;
+ // set the history in properties
+ stringArray = new string[findHistory.Count];
+ findHistory.CopyTo (stringArray, 0);
+ propertyService.SetProperty ("MonoDevelop.FindReplaceDialogs.FindHistory", string.Join(historySeparator.ToString(), stringArray));
+
+ // now do the replace history
+ if (replaceMode) {
+ stringArray = new string[replaceHistory.Count];
+ replaceHistory.CopyTo (stringArray, 0);
+ propertyService.SetProperty ("MonoDevelop.FindReplaceDialogs.ReplaceHistory", string.Join(historySeparator.ToString(), stringArray));
+ }
+ }
+
+ #region code to pretend to be a dialog (cause we cant inherit Dialog and use glade)
+ public void Present()
+ {
+ ReplaceDialogPointer.Present();
+ }
+
+ public void Destroy()
+ {
+ // save the search and replace history to properties
+ OnClosed ();
+ ReplaceDialogPointer.Destroy();
+ }
+
+ public void ShowAll()
+ {
+ ReplaceDialogPointer.ShowAll();
+ searchPatternEntry.SelectRegion (0, searchPatternEntry.Text.Length);
+ }
+ #endregion
+
+ public Gtk.Dialog DialogPointer
+ {
+ get {
+ return ReplaceDialogPointer;
+ }
+ }
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReplaceInFilesDialog.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReplaceInFilesDialog.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Dialogs/ReplaceInFilesDialog.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,381 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Kr�ger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Drawing;
+using System.ComponentModel;
+
+using MonoDevelop.Gui;
+using MonoDevelop.Core.Properties;
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+using MonoDevelop.Gui.Widgets;
+using MonoDevelop.Gui.Search;
+
+using Glade;
+using Gtk;
+
+namespace MonoDevelop.Gui.Dialogs
+{
+ public class ReplaceInFilesDialog
+ {
+ IMessageService messageService = (IMessageService)ServiceManager.GetService(typeof(IMessageService));
+ public bool replaceMode;
+
+ [Glade.Widget] Gtk.Entry searchPatternEntry;
+ [Glade.Widget] Gtk.Entry replacePatternEntry;
+ [Glade.Widget] Gtk.Button findHelpButton;
+ [Glade.Widget] Gtk.Button findButton;
+ [Glade.Widget] Gtk.Button markAllButton;
+ [Glade.Widget] Gtk.Button closeButton;
+ [Glade.Widget] Gtk.Button replaceButton;
+ [Glade.Widget] Gtk.Button replaceAllButton;
+ [Glade.Widget] Gtk.Button replaceHelpButton;
+ [Glade.Widget] Gtk.CheckButton ignoreCaseCheckBox;
+ [Glade.Widget] Gtk.CheckButton searchWholeWordOnlyCheckBox;
+ [Glade.Widget] Gtk.CheckButton useSpecialSearchStrategyCheckBox;
+ [Glade.Widget] Gtk.ComboBox specialSearchStrategyComboBox;
+ [Glade.Widget] Gtk.ComboBox searchLocationComboBox;
+ [Glade.Widget] Gtk.Label label1;
+ [Glade.Widget] Gtk.Label label2;
+ [Glade.Widget] Gtk.Label searchLocationLabel;
+ [Glade.Widget] Gtk.Dialog FindInFilesDialogWidget;
+ [Glade.Widget] Gtk.Dialog ReplaceInFilesDialogWidget;
+
+ [Glade.Widget] Gtk.CheckButton includeSubdirectoriesCheckBox;
+ [Glade.Widget] Gtk.Entry fileMaskTextBox;
+ [Glade.Widget] Gtk.Entry directoryTextBox;
+ [Glade.Widget] Gtk.Button browseButton;
+ [Glade.Widget] Gtk.Label label6;
+ [Glade.Widget] Gtk.Label label7;
+ [Glade.Widget] Gtk.Button stopButton;
+
+
+ Gtk.Dialog ReplaceDialogPointer;
+
+ void InitDialog ()
+ {
+ findButton.UseUnderline = true;
+ closeButton.UseUnderline = true;
+
+ //set up the size groups
+ SizeGroup labels = new SizeGroup(SizeGroupMode.Horizontal);
+ SizeGroup combos = new SizeGroup(SizeGroupMode.Horizontal);
+ SizeGroup options = new SizeGroup(SizeGroupMode.Horizontal);
+ SizeGroup helpButtons = new SizeGroup(SizeGroupMode.Horizontal);
+ SizeGroup checkButtons = new SizeGroup(SizeGroupMode.Horizontal);
+ labels.AddWidget(label1);
+ labels.AddWidget(label6);
+ labels.AddWidget(label7);
+ combos.AddWidget(searchPatternEntry);
+ combos.AddWidget(directoryTextBox);
+ combos.AddWidget(fileMaskTextBox);
+ helpButtons.AddWidget(findHelpButton);
+ helpButtons.AddWidget(browseButton);
+ checkButtons.AddWidget (includeSubdirectoriesCheckBox);
+ checkButtons.AddWidget(ignoreCaseCheckBox);
+ checkButtons.AddWidget(searchWholeWordOnlyCheckBox);
+ checkButtons.AddWidget(useSpecialSearchStrategyCheckBox);
+ checkButtons.AddWidget(searchLocationLabel);
+ options.AddWidget(specialSearchStrategyComboBox);
+ options.AddWidget(searchLocationComboBox);
+
+ searchPatternEntry.Completion = new EntryCompletion ();
+ searchPatternEntry.Completion.Model = new ListStore (typeof (string));
+ searchPatternEntry.Completion.TextColumn = 0;
+
+ // set button sensitivity
+ findHelpButton.Sensitive = false;
+
+ // set replace dialog properties
+ if (replaceMode)
+ {
+ replacePatternEntry.Completion = new EntryCompletion ();
+ replacePatternEntry.Completion.Model = new ListStore (typeof (string));
+ replacePatternEntry.Completion.TextColumn = 0;
+
+ label2.Text = GettextCatalog.GetString ("Replace in Files");
+
+ // set the size groups to include the replace dialog
+ labels.AddWidget(label2);
+ combos.AddWidget(replacePatternEntry);
+ helpButtons.AddWidget(replaceHelpButton);
+
+ replaceHelpButton.Sensitive = false;
+ ReplaceDialogPointer = this.ReplaceInFilesDialogWidget;
+ }
+ else
+ {
+ ReplaceDialogPointer = this.FindInFilesDialogWidget;
+ }
+ ReplaceDialogPointer.TransientFor = (Gtk.Window)WorkbenchSingleton.Workbench;
+ }
+
+ protected void OnClosed()
+ {
+ //SaveHistoryValues();
+ }
+
+ void OnDeleted (object o, DeleteEventArgs args)
+ {
+ // perform the standard closing windows event
+ OnClosed();
+ SearchReplaceInFilesManager.ReplaceDialog = null;
+ }
+
+ public void Present ()
+ {
+ ReplaceDialogPointer.Present ();
+ }
+
+ public void Destroy ()
+ {
+ ReplaceDialogPointer.Destroy ();
+ }
+
+ void CloseDialogEvent(object sender, EventArgs e)
+ {
+ ReplaceDialogPointer.Hide();
+ OnClosed ();
+ }
+
+ public void ShowAll ()
+ {
+ ReplaceDialogPointer.ShowAll ();
+ SearchReplaceInFilesManager.ReplaceDialog = this;
+ searchPatternEntry.SelectRegion (0, searchPatternEntry.Text.Length);
+ }
+
+ public ReplaceInFilesDialog (bool replaceMode)
+ {
+ this.replaceMode = replaceMode;
+ string dialogName = (replaceMode) ? "ReplaceInFilesDialogWidget" : "FindInFilesDialogWidget";
+ Glade.XML glade = new XML (null, "Base.glade", dialogName, null);
+ glade.Autoconnect (this);
+ InitDialog ();
+
+ CellRendererText cr = new CellRendererText ();
+ Gtk.ListStore store = new ListStore (typeof (string));
+ store.AppendValues (GettextCatalog.GetString ("Wildcards"));
+ store.AppendValues (GettextCatalog.GetString ("Regular Expressions"));
+ specialSearchStrategyComboBox.Model = store;
+ specialSearchStrategyComboBox.PackStart (cr, true);
+ specialSearchStrategyComboBox.AddAttribute (cr, "text", 0);
+
+ int index = 0;
+ switch (SearchReplaceManager.SearchOptions.SearchStrategyType) {
+ case SearchStrategyType.Normal:
+ case SearchStrategyType.Wildcard:
+ break;
+ case SearchStrategyType.RegEx:
+ searchWholeWordOnlyCheckBox.Sensitive = false;
+ index = 1;
+ break;
+ }
+ specialSearchStrategyComboBox.Active = index;
+ specialSearchStrategyComboBox.Changed += new EventHandler (OnSpecialSearchStrategyChanged);
+
+ store = new ListStore (typeof (string));
+ store.AppendValues (GettextCatalog.GetString ("Directories"));
+ store.AppendValues (GettextCatalog.GetString ("All open files"));
+ store.AppendValues (GettextCatalog.GetString ("Whole project"));
+ searchLocationComboBox.Model = store;
+ searchLocationComboBox.PackStart (cr, true);
+ searchLocationComboBox.AddAttribute (cr, "text", 0);
+
+ index = 0;
+ switch (SearchReplaceInFilesManager.SearchOptions.DocumentIteratorType) {
+ case DocumentIteratorType.AllOpenFiles:
+ index = 1;
+ break;
+ case DocumentIteratorType.WholeCombine:
+ index = 2;
+ break;
+ }
+
+ searchLocationComboBox.Active = index;
+ searchLocationComboBox.Changed += new EventHandler(SearchLocationCheckBoxChangedEvent);
+ useSpecialSearchStrategyCheckBox.Toggled += new EventHandler(SpecialSearchStrategyCheckBoxChangedEvent);
+
+ directoryTextBox.Text = SearchReplaceInFilesManager.SearchOptions.SearchDirectory;
+ fileMaskTextBox.Text = SearchReplaceInFilesManager.SearchOptions.FileMask;
+ includeSubdirectoriesCheckBox.Active = SearchReplaceInFilesManager.SearchOptions.SearchSubdirectories;
+
+ browseButton.Clicked += new EventHandler(BrowseDirectoryEvent);
+ findButton.Clicked += new EventHandler(FindEvent);
+
+ stopButton.Clicked += new EventHandler(StopEvent);
+
+ searchPatternEntry.Text = SearchReplaceInFilesManager.SearchOptions.SearchPattern;
+
+ if (replaceMode) {
+ replaceAllButton.Clicked += new EventHandler(ReplaceEvent);
+ replacePatternEntry.Text = SearchReplaceInFilesManager.SearchOptions.ReplacePattern;
+ }
+
+ ReplaceDialogPointer.Close += new EventHandler (CloseDialogEvent);
+ closeButton.Clicked += new EventHandler (CloseDialogEvent);
+ ReplaceDialogPointer.DeleteEvent += new DeleteEventHandler (OnDeleted);
+
+ SearchLocationCheckBoxChangedEvent (null, null);
+ SpecialSearchStrategyCheckBoxChangedEvent (null, null);
+ }
+
+ void FindEvent (object sender, EventArgs e)
+ {
+ if (SetupSearchReplaceInFilesManager ())
+ SearchReplaceInFilesManager.FindAll ();
+ }
+
+ void StopEvent (object sender, EventArgs e)
+ {
+ if (SetupSearchReplaceInFilesManager ())
+ SearchReplaceInFilesManager.CancelSearch();
+ }
+
+ void OnSpecialSearchStrategyChanged (object o, EventArgs e)
+ {
+ if (specialSearchStrategyComboBox.Active != 1) {
+ searchWholeWordOnlyCheckBox.Sensitive = true;
+ } else {
+ searchWholeWordOnlyCheckBox.Sensitive = false;
+ }
+ }
+
+
+ void ReplaceEvent(object sender, EventArgs e)
+ {
+ if (SetupSearchReplaceInFilesManager ())
+ SearchReplaceInFilesManager.ReplaceAll ();
+ }
+
+ void BrowseDirectoryEvent (object sender, EventArgs e)
+ {
+ PropertyService PropertyService = (PropertyService)ServiceManager.GetService (typeof (PropertyService));
+ FolderDialog fd = new FolderDialog (GettextCatalog.GetString ("Select directory"));
+
+ // set up the dialog to point to currently selected folder, or the default projects folder
+ string defaultFolder = this.directoryTextBox.Text;
+ if (defaultFolder == string.Empty || defaultFolder == null) {
+ // only use the bew project default path if there is no path set
+ defaultFolder = PropertyService.GetProperty (
+ "MonoDevelop.Gui.Dialogs.NewProjectDialog.DefaultPath",
+ System.IO.Path.Combine (
+ System.Environment.GetEnvironmentVariable ("HOME"),
+ "Projects")).ToString ();
+ }
+ fd.SetFilename( defaultFolder );
+ if (fd.Run() == (int)Gtk.ResponseType.Ok)
+ {
+ directoryTextBox.Text = fd.Filename;
+ }
+ fd.Hide ();
+ }
+
+ void SearchLocationCheckBoxChangedEvent(object sender, EventArgs e)
+ {
+ bool enableDirectorySearch = searchLocationComboBox.Active == 0;
+ fileMaskTextBox.Sensitive = enableDirectorySearch;
+ directoryTextBox.Sensitive = enableDirectorySearch;
+ browseButton.Sensitive = enableDirectorySearch;
+ includeSubdirectoriesCheckBox.Sensitive = enableDirectorySearch;
+ }
+
+ void SpecialSearchStrategyCheckBoxChangedEvent (object sender, EventArgs e)
+ {
+ specialSearchStrategyComboBox.Sensitive = useSpecialSearchStrategyCheckBox.Active;
+ if (useSpecialSearchStrategyCheckBox.Active) {
+ if (specialSearchStrategyComboBox.Active == 1) {
+ searchWholeWordOnlyCheckBox.Sensitive = false;
+ }
+ } else {
+ searchWholeWordOnlyCheckBox.Sensitive = true;
+ }
+ }
+
+ public void SetSearchPattern(string pattern)
+ {
+ searchPatternEntry.Text = pattern;
+ }
+
+ bool SetupSearchReplaceInFilesManager()
+ {
+ FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.GetService(typeof(FileUtilityService));
+
+ string directoryName = directoryTextBox.Text;
+ string fileMask = fileMaskTextBox.Text;
+ if (fileMask == null || fileMask.Length == 0) {
+ fileMask = "*";
+ }
+
+ if (SearchReplaceInFilesManager.SearchOptions.DocumentIteratorType == DocumentIteratorType.Directory) {
+
+ if (!fileUtilityService.IsValidFileName(directoryName)) {
+ messageService.ShowErrorFormatted(GettextCatalog.GetString ("Invalid directory name: {0}"), directoryName);
+ return false;
+ }
+
+ if (!Directory.Exists(directoryName)) {
+ messageService.ShowErrorFormatted (GettextCatalog.GetString ("Invalid directory name: {0}"), directoryName);
+ return false;
+ }
+
+ if (!fileUtilityService.IsValidFileName(fileMask) || fileMask.IndexOf('\\') >= 0) {
+ messageService.ShowErrorFormatted(GettextCatalog.GetString ("Invalid file mask: {0}"), fileMask);
+ return false;
+ }
+ }
+ if (fileMask == null || fileMask.Length == 0) {
+ SearchReplaceInFilesManager.SearchOptions.FileMask = "*";
+ } else {
+ SearchReplaceInFilesManager.SearchOptions.FileMask = fileMask;
+ }
+ SearchReplaceInFilesManager.SearchOptions.SearchDirectory = directoryName;
+ SearchReplaceInFilesManager.SearchOptions.SearchSubdirectories = includeSubdirectoriesCheckBox.Active;
+
+ SearchReplaceInFilesManager.SearchOptions.SearchPattern = searchPatternEntry.Text;
+ if (replaceMode)
+ SearchReplaceInFilesManager.SearchOptions.ReplacePattern = replacePatternEntry.Text;
+
+ SearchReplaceInFilesManager.SearchOptions.IgnoreCase = !ignoreCaseCheckBox.Active;
+ SearchReplaceInFilesManager.SearchOptions.SearchWholeWordOnly = searchWholeWordOnlyCheckBox.Active;
+
+ if (useSpecialSearchStrategyCheckBox.Active) {
+ switch (specialSearchStrategyComboBox.Active) {
+ case 0:
+ SearchReplaceInFilesManager.SearchOptions.SearchStrategyType = SearchStrategyType.Wildcard;
+ break;
+ case 1:
+ SearchReplaceInFilesManager.SearchOptions.SearchStrategyType = SearchStrategyType.RegEx;
+ break;
+ }
+ } else {
+ SearchReplaceInFilesManager.SearchOptions.SearchStrategyType = SearchStrategyType.Normal;
+ }
+
+ switch (searchLocationComboBox.Active) {
+ case 0:
+ SearchReplaceInFilesManager.SearchOptions.DocumentIteratorType = DocumentIteratorType.Directory;
+ break;
+ case 1:
+ SearchReplaceInFilesManager.SearchOptions.DocumentIteratorType = DocumentIteratorType.AllOpenFiles;
+ break;
+ case 2:
+ SearchReplaceInFilesManager.SearchOptions.DocumentIteratorType = DocumentIteratorType.WholeCombine;
+ break;
+ }
+ return true;
+ }
+
+ public Gtk.Dialog DialogPointer {
+ get {
+ return ReplaceDialogPointer;
+ }
+ }
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DefaultFind.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DefaultFind.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DefaultFind.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,120 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+using System;
+using System.Collections;
+using System.Diagnostics;
+
+namespace MonoDevelop.Gui.Search
+{
+ public class DefaultFind : IFind
+ {
+ ISearchStrategy searchStrategy = null;
+ IDocumentIterator documentIterator = null;
+ ITextIterator textIterator = null;
+ IDocumentInformation info = null;
+ bool cancelled;
+ int searchedFiles;
+ int matches;
+
+ public IDocumentInformation CurrentDocumentInformation {
+ get {
+ return info;
+ }
+ }
+
+ public ITextIterator TextIterator {
+ get {
+ return textIterator;
+ }
+ }
+
+ public ISearchStrategy SearchStrategy {
+ get {
+ return searchStrategy;
+ }
+ set {
+ searchStrategy = value;
+ }
+ }
+
+ public IDocumentIterator DocumentIterator {
+ get {
+ return documentIterator;
+ }
+ set {
+ documentIterator = value;
+ }
+ }
+
+ public int SearchedFileCount {
+ get { return searchedFiles; }
+ }
+
+ public int MatchCount {
+ get { return matches; }
+ }
+
+ public void Reset()
+ {
+ documentIterator.Reset();
+ textIterator = null;
+ cancelled = false;
+ searchedFiles = 0;
+ matches = 0;
+ }
+
+ public void Replace (ISearchResult result, string pattern)
+ {
+ if (CurrentDocumentInformation != null && TextIterator != null) {
+ TextIterator.Position = result.Offset;
+ TextIterator.Replace (result.Length, pattern);
+ }
+ }
+
+ public ISearchResult FindNext(SearchOptions options)
+ {
+ // insanity check
+ Debug.Assert(searchStrategy != null);
+ Debug.Assert(documentIterator != null);
+ Debug.Assert(options != null);
+
+ while (!cancelled)
+ {
+ if (info != null && textIterator != null && documentIterator.CurrentFileName != null) {
+ if (info.FileName != documentIterator.CurrentFileName) { // create new iterator, if document changed
+ info = documentIterator.Current;
+ textIterator = info.GetTextIterator ();
+ }
+
+ ISearchResult result = searchStrategy.FindNext (textIterator, options);
+ if (result != null) {
+ matches++;
+ return result;
+ }
+ }
+
+ if (textIterator != null) textIterator.Close ();
+
+ // not found or first start -> move forward to the next document
+ if (documentIterator.MoveForward()) {
+ searchedFiles++;
+ info = documentIterator.Current;
+ textIterator = info.GetTextIterator ();
+ }
+ else
+ cancelled = true;
+ }
+ cancelled = false;
+ return null;
+ }
+
+ public void Cancel ()
+ {
+ cancelled = true;
+ }
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/AllOpenDocumentIterator.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/AllOpenDocumentIterator.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/AllOpenDocumentIterator.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,105 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+
+namespace MonoDevelop.Gui.Search
+{
+ public class AllOpenDocumentIterator : IDocumentIterator
+ {
+ int startIndex = -1;
+ bool resetted = true;
+
+ public AllOpenDocumentIterator()
+ {
+ Reset();
+ }
+
+ public string CurrentFileName {
+ get {
+ if (!SearchReplaceUtilities.IsTextAreaSelected) {
+ return null;
+ }
+
+ if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.ContentName == null) {
+ return WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.UntitledName;
+ }
+
+ return WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.ContentName;
+ }
+ }
+
+ public IDocumentInformation Current {
+ get {
+ if (!SearchReplaceUtilities.IsTextAreaSelected) {
+ return null;
+ }
+ return WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent as IDocumentInformation;
+ }
+ }
+
+ int GetCurIndex()
+ {
+ for (int i = 0; i < WorkbenchSingleton.Workbench.ViewContentCollection.Count; ++i) {
+ if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent == WorkbenchSingleton.Workbench.ViewContentCollection[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public bool MoveForward()
+ {
+ int curIndex = GetCurIndex();
+ if (curIndex < 0) {
+ return false;
+ }
+
+ if (resetted) {
+ resetted = false;
+ return true;
+ }
+
+ int nextIndex = (curIndex + 1) % WorkbenchSingleton.Workbench.ViewContentCollection.Count;
+ if (nextIndex == startIndex) {
+ return false;
+ }
+ WorkbenchSingleton.Workbench.ViewContentCollection[nextIndex].WorkbenchWindow.SelectWindow();
+ return true;
+ }
+
+ public bool MoveBackward()
+ {
+ int curIndex = GetCurIndex();
+ if (curIndex < 0) {
+ return false;
+ }
+ if (resetted) {
+ resetted = false;
+ return true;
+ }
+
+ if (curIndex == 0) {
+ curIndex = WorkbenchSingleton.Workbench.ViewContentCollection.Count - 1;
+ }
+
+ if (curIndex > 0) {
+ --curIndex;
+ WorkbenchSingleton.Workbench.ViewContentCollection[curIndex].WorkbenchWindow.SelectWindow();
+ return true;
+ }
+ return false;
+ }
+
+ public void Reset()
+ {
+ startIndex = GetCurIndex();
+ resetted = true;
+ }
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/CurrentDocumentIterator.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/CurrentDocumentIterator.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/CurrentDocumentIterator.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,66 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+
+namespace MonoDevelop.Gui.Search
+{
+ public class CurrentDocumentIterator : IDocumentIterator
+ {
+ bool didRead = false;
+
+ public CurrentDocumentIterator()
+ {
+ Reset();
+ }
+
+ public string CurrentFileName {
+ get {
+ if (!SearchReplaceUtilities.IsTextAreaSelected) {
+ return null;
+ }
+ if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.ContentName == null) {
+ return WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.UntitledName;
+ }
+ return WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.ContentName;
+ }
+ }
+
+ public IDocumentInformation Current {
+ get {
+ if (!SearchReplaceUtilities.IsTextAreaSelected) {
+ return null;
+ }
+ return WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent as IDocumentInformation;
+ }
+ }
+
+ public bool MoveForward()
+ {
+ if (!SearchReplaceUtilities.IsTextAreaSelected) {
+ return false;
+ }
+ if (didRead) {
+ return false;
+ }
+ didRead = true;
+
+ return true;
+ }
+
+ public bool MoveBackward()
+ {
+ return MoveForward();
+ }
+
+ public void Reset()
+ {
+ didRead = false;
+ }
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/DirectoryDocumentIterator.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/DirectoryDocumentIterator.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/DirectoryDocumentIterator.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,84 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.IO;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+
+namespace MonoDevelop.Gui.Search
+{
+ public class DirectoryDocumentIterator : IDocumentIterator
+ {
+ string searchDirectory;
+ string fileMask;
+ bool searchSubdirectories;
+
+ StringCollection files = null;
+ int curIndex = -1;
+
+ public DirectoryDocumentIterator(string searchDirectory, string fileMask, bool searchSubdirectories)
+ {
+ this.searchDirectory = searchDirectory;
+ this.fileMask = fileMask;
+ this.searchSubdirectories = searchSubdirectories;
+
+ Reset();
+ }
+
+ public string CurrentFileName {
+ get {
+ if (curIndex < 0 || curIndex >= files.Count) {
+ return null;
+ }
+
+ return files[curIndex].ToString();
+ }
+ }
+
+ public IDocumentInformation Current {
+ get {
+ if (curIndex < 0 || curIndex >= files.Count) {
+ return null;
+ }
+ if (!File.Exists(files[curIndex].ToString())) {
+ ++curIndex;
+ return Current;
+ }
+ string fileName = files[curIndex].ToString();
+ return new FileDocumentInformation(fileName, 0);
+ }
+ }
+
+ public bool MoveForward()
+ {
+ if (curIndex == -1) {
+ FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.GetService(typeof(FileUtilityService));
+ files = fileUtilityService.SearchDirectory(this.searchDirectory, this.fileMask, this.searchSubdirectories);
+ }
+ return ++curIndex < files.Count;
+ }
+
+ public bool MoveBackward()
+ {
+ if (curIndex == -1) {
+ curIndex = files.Count - 1;
+ return true;
+ }
+ return --curIndex >= -1;
+ }
+
+
+ public void Reset()
+ {
+ curIndex = -1;
+ }
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/FileDocumentInformation.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/FileDocumentInformation.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/FileDocumentInformation.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,82 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Text;
+using System.IO;
+using System.Collections;
+
+namespace MonoDevelop.Gui.Search
+{
+ public class FileDocumentInformation: IDocumentInformation
+ {
+ string fileName;
+ int currentOffset;
+ ForwardTextFileIterator iterator;
+
+ public FileDocumentInformation(string fileName, int currentOffset)
+ {
+ this.fileName = fileName;
+ this.currentOffset = currentOffset;
+ }
+
+ public string FileName {
+ get {
+ return fileName;
+ }
+ }
+
+ public int CurrentOffset {
+ get {
+ return currentOffset;
+ }
+ set {
+ currentOffset = value;
+ }
+ }
+
+ public int EndOffset {
+ get {
+ return currentOffset;
+ }
+ }
+
+ public ITextIterator GetTextIterator ()
+ {
+ if (iterator == null)
+ iterator = new ForwardTextFileIterator (this, fileName);
+ return iterator;
+ }
+
+ public string GetLineTextAtOffset (int offset)
+ {
+ FileStream stream = new FileStream (fileName, FileMode.Open, FileAccess.Read);
+ try {
+ ExtendedStreamReader streamReader = new ExtendedStreamReader (new StreamReader (stream));
+ streamReader.Position = offset;
+
+ int lastPos;
+ int b;
+ do {
+ lastPos = streamReader.Position;
+ b = streamReader.ReadBack ();
+ } while (b != -1 && b != 10 && b != 13);
+
+ streamReader.Position = lastPos;
+ StringBuilder sb = new StringBuilder ();
+ b = streamReader.Read ();
+ while (b != -1 && b != 10 && b != 13) {
+ sb.Append ((char)b);
+ b = streamReader.Read ();
+ }
+ return sb.ToString ();
+ } finally {
+ stream.Close ();
+ }
+ }
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/IDocumentInformation.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/IDocumentInformation.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/IDocumentInformation.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,24 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Lluis Sanchez Gual" email="lluis at ximian.com"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Collections;
+
+namespace MonoDevelop.Gui.Search
+{
+ public interface IDocumentInformation
+ {
+ string FileName {
+ get;
+ }
+
+ ITextIterator GetTextIterator ();
+
+ string GetLineTextAtOffset (int offset);
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/IDocumentIterator.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/IDocumentIterator.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/IDocumentIterator.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,54 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+
+namespace MonoDevelop.Gui.Search
+{
+ /// <summary>
+ /// Represents a bi-directional iterator which could move froward/backward
+ /// in a document queue. Note that after move forward is called
+ /// move backward needn't to function correctly either move forward or move
+ /// backward is called but they're not mixed. After a reset the move operation
+ /// can be switched.
+ /// </summary>
+ public interface IDocumentIterator
+ {
+ /// <value>
+ /// Returns the current ProvidedDocumentInformation. This method
+ /// usually creates a new ProvidedDocumentInformation object which can
+ /// be time consuming
+ /// </value>
+ IDocumentInformation Current {
+ get;
+ }
+
+ /// <value>
+ /// Returns the file name of the current provided document information. This
+ /// property usually is not time consuming
+ /// </value>
+ string CurrentFileName {
+ get;
+ }
+
+ /// <remarks>
+ /// Moves the iterator one document forward.
+ /// </remarks>
+ bool MoveForward();
+
+ /// <remarks>
+ /// Moves the iterator one document backward.
+ /// </remarks>
+ bool MoveBackward();
+
+ /// <remarks>
+ /// Resets the iterator to the start position.
+ /// </remarks>
+ void Reset();
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/ReverseDocumentIterator.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/ReverseDocumentIterator.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/ReverseDocumentIterator.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,53 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+
+namespace MonoDevelop.Gui.Search
+{
+ /// <summary>
+ /// Represents a bi-directional iterator which could move froward/backward
+ /// in a document queue.
+ /// </summary>
+ public class ReverseDocumentIterator : IDocumentIterator
+ {
+ IDocumentIterator documentIterator;
+
+ public string CurrentFileName {
+ get {
+ return documentIterator.CurrentFileName;
+ }
+ }
+
+ public IDocumentInformation Current {
+ get {
+ return documentIterator.Current;
+ }
+ }
+
+ public ReverseDocumentIterator(IDocumentIterator documentIterator)
+ {
+ this.documentIterator = documentIterator;
+ }
+
+ public bool MoveForward()
+ {
+ return documentIterator.MoveBackward();
+ }
+
+ public bool MoveBackward()
+ {
+ return documentIterator.MoveBackward();
+ }
+
+ public void Reset()
+ {
+ documentIterator.Reset();
+ }
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/WholeProjectDocumentIterator.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/WholeProjectDocumentIterator.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/DocumentIterator/WholeProjectDocumentIterator.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,107 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+using System.IO;
+
+using MonoDevelop.Internal.Project;
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+
+namespace MonoDevelop.Gui.Search
+{
+ public class WholeProjectDocumentIterator : IDocumentIterator
+ {
+ ArrayList files = new ArrayList();
+ int curIndex = -1;
+
+ public WholeProjectDocumentIterator()
+ {
+ Reset();
+ }
+
+ public string CurrentFileName {
+ get {
+ if (curIndex < 0 || curIndex >= files.Count) {
+ return null;
+ }
+
+ return files[curIndex].ToString();
+ }
+ }
+
+ public IDocumentInformation Current {
+ get {
+ if (curIndex < 0 || curIndex >= files.Count) {
+ return null;
+ }
+ if (!File.Exists(files[curIndex].ToString())) {
+ ++curIndex;
+ return Current;
+ }
+
+ string fileName = files[curIndex].ToString();
+ foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) {
+ // WINDOWS DEPENDENCY : ToUpper
+ if (content.ContentName != null && content.ContentName.ToUpper() == fileName.ToUpper()) {
+ IDocumentInformation doc = content as IDocumentInformation;
+ if (doc != null) return doc;
+ }
+ }
+ return new FileDocumentInformation (fileName, 0);
+ }
+ }
+
+ public bool MoveForward()
+ {
+ return ++curIndex < files.Count;
+ }
+
+ public bool MoveBackward()
+ {
+ if (curIndex == -1) {
+ curIndex = files.Count - 1;
+ return true;
+ }
+ return --curIndex >= -1;
+ }
+
+
+ void AddFiles(Project project)
+ {
+ foreach (ProjectFile file in project.ProjectFiles) {
+ if (file.BuildAction == BuildAction.Compile &&
+ file.Subtype == Subtype.Code) {
+ files.Add(file.Name);
+ }
+ }
+ }
+
+ void AddFiles(Combine combine)
+ {
+ foreach (CombineEntry entry in combine.Entries) {
+ if (entry is Project) {
+ AddFiles ((Project)entry);
+ } else if (entry is Combine) {
+ AddFiles ((Combine)entry);
+ }
+ }
+ }
+
+ public void Reset()
+ {
+ files.Clear();
+ IProjectService projectService = (IProjectService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(IProjectService));
+ if (projectService.CurrentOpenCombine != null) {
+ AddFiles(projectService.CurrentOpenCombine);
+ }
+
+ curIndex = -1;
+ }
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/IFind.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/IFind.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/IFind.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,70 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+using System.Diagnostics;
+
+namespace MonoDevelop.Gui.Search
+{
+ /// <summary>
+ /// The basic interface for search operations in a document.
+ /// </summary>
+ public interface IFind
+ {
+ /// <value>
+ /// An object that implements a search algorithm.
+ /// </value>
+ ISearchStrategy SearchStrategy {
+ get;
+ set;
+ }
+
+ /// <value>
+ /// Gets the current document information
+ /// </value>
+ IDocumentInformation CurrentDocumentInformation {
+ get;
+ }
+
+ /// <value>
+ /// An object that provides a document loading approach.
+ /// </value>
+ IDocumentIterator DocumentIterator {
+ get;
+ set;
+ }
+
+ /// <remarks>
+ /// Does a replace in the current document information. This
+ /// is the only method which should be used for doing replacements
+ /// in a searched document.
+ /// </remarks>
+ void Replace (ISearchResult result, string pattern);
+
+ /// <remarks>
+ /// Finds next pattern.
+ /// <remarks>
+ /// <returns>
+ /// null if the pattern wasn't found. If it returns null the current document
+ /// information will be null too otherwise it will point to the document in which
+ /// the search pattern was found.
+ /// </returns>
+ ISearchResult FindNext(SearchOptions options);
+
+ /// <remarks>
+ /// Resets the find object to the original state.
+ /// </remarks>
+ void Reset();
+
+ void Cancel ();
+
+ int SearchedFileCount { get; }
+
+ int MatchCount { get; }
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/ISearchableDocument.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/ISearchableDocument.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/ISearchableDocument.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,10 @@
+
+using System;
+
+namespace MonoDevelop.TextEditor.Document
+{
+ public interface ISearchableDocument
+ {
+
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/ITextBufferStrategy.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/ITextBufferStrategy.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/ITextBufferStrategy.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,85 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+namespace MonoDevelop.Gui
+{
+ /// <summary>
+ /// Interface to describe a sequence of characters that can be edited.
+ /// </summary>
+ public interface ITextBufferStrategy
+ {
+ /// <value>
+ /// The current length of the sequence of characters that can be edited.
+ /// </value>
+ int Length {
+ get;
+ }
+
+ /// <summary>
+ /// Inserts a string of characters into the sequence.
+ /// </summary>
+ /// <param name="offset">
+ /// offset where to insert the string.
+ /// </param>
+ /// <param name="text">
+ /// text to be inserted.
+ /// </param>
+ void Insert(int offset, string text);
+
+ /// <summary>
+ /// Removes some portion of the sequence.
+ /// </summary>
+ /// <param name="offset">
+ /// offset of the remove.
+ /// </param>
+ /// <param name="length">
+ /// number of characters to remove.
+ /// </param>
+ void Remove(int offset, int length);
+
+ /// <summary>
+ /// Replace some portion of the sequence.
+ /// </summary>
+ /// <param name="offset">
+ /// offset.
+ /// </param>
+ /// <param name="length">
+ /// number of characters to replace.
+ /// </param>
+ /// <param name="text">
+ /// text to be replaced with.
+ /// </param>
+ void Replace(int offset, int length, string text);
+
+ /// <summary>
+ /// Fetches a string of characters contained in the sequence.
+ /// </summary>
+ /// <param name="offset">
+ /// Offset into the sequence to fetch
+ /// </param>
+ /// <param name="length">
+ /// number of characters to copy.
+ /// </param>
+ string GetText(int offset, int length);
+
+ /// <summary>
+ /// Returns a specific char of the sequence.
+ /// </summary>
+ /// <param name="offset">
+ /// Offset of the char to get.
+ /// </param>
+ char GetCharAt(int offset);
+
+ /// <summary>
+ /// This method sets the stored content.
+ /// </summary>
+ /// <param name="text">
+ /// The string that represents the character sequence.
+ /// </param>
+ void SetContent(string text);
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchOptions.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchOptions.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchOptions.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,141 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Drawing;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Core.Properties;
+using MonoDevelop.Internal.Undo;
+
+namespace MonoDevelop.Gui.Search
+{
+ public class SearchOptions
+ {
+ static PropertyService propertyService = (PropertyService)ServiceManager.GetService(typeof(PropertyService));
+ IProperties properties;
+
+ public bool IgnoreCase {
+ get {
+ return properties.GetProperty("IgnoreCase", false);
+ }
+ set {
+ properties.SetProperty("IgnoreCase", value);
+ }
+ }
+
+ public bool SearchWholeWordOnly {
+ get {
+ return properties.GetProperty("SearchWholeWordOnly", false);
+ }
+
+ set {
+ properties.SetProperty("SearchWholeWordOnly", value);
+ }
+ }
+
+ public string SearchPattern {
+ get {
+ return properties.GetProperty("SearchPattern", String.Empty);
+ }
+ set {
+ properties.SetProperty("SearchPattern", value);
+ }
+ }
+
+ public string ReplacePattern {
+ get {
+ return properties.GetProperty("ReplacePattern", String.Empty);
+ }
+ set {
+ properties.SetProperty("ReplacePattern", value);
+ }
+ }
+
+ public DocumentIteratorType DocumentIteratorType {
+ get {
+ return (DocumentIteratorType)propertyService.GetProperty("DocumentIteratorType", DocumentIteratorType.CurrentDocument);
+ }
+ set {
+ if (DocumentIteratorType != value) {
+ propertyService.SetProperty("DocumentIteratorType", value);
+ OnDocumentIteratorTypeChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public SearchStrategyType SearchStrategyType {
+ get {
+ return (SearchStrategyType)propertyService.GetProperty("SearchStrategyType", SearchStrategyType.Normal);
+ }
+ set {
+ if (SearchStrategyType != value) {
+ propertyService.SetProperty("SearchStrategyType", value);
+ OnSearchStrategyTypeChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ public string FileMask {
+ get {
+ return propertyService.GetProperty("FileMask", String.Empty);
+ }
+ set {
+ propertyService.SetProperty("FileMask", value);
+ }
+ }
+
+ public string SearchDirectory {
+ get {
+ return propertyService.GetProperty("SearchDirectory", String.Empty);
+ }
+ set {
+ propertyService.SetProperty("SearchDirectory", value);
+ }
+ }
+
+ public bool SearchSubdirectories {
+ get {
+ return propertyService.GetProperty("SearchSubdirectories", true);
+ }
+ set {
+ propertyService.SetProperty("SearchSubdirectories", value);
+ }
+ }
+
+ /// <remarks>
+ /// For unit testing purposes
+ /// </remarks>
+ public SearchOptions(IProperties properties)
+ {
+ this.properties = properties;
+ }
+
+ public SearchOptions(string propertyName)
+ {
+ properties = (IProperties)propertyService.GetProperty(propertyName, new DefaultProperties());
+ }
+
+ protected void OnDocumentIteratorTypeChanged(EventArgs e)
+ {
+ if (DocumentIteratorTypeChanged != null) {
+ DocumentIteratorTypeChanged(this, e);
+ }
+ }
+
+ protected void OnSearchStrategyTypeChanged(EventArgs e)
+ {
+ if (SearchStrategyTypeChanged != null) {
+ SearchStrategyTypeChanged(this, e);
+ }
+ }
+
+ public event EventHandler DocumentIteratorTypeChanged;
+ public event EventHandler SearchStrategyTypeChanged;
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchReplaceInFilesManager.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchReplaceInFilesManager.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchReplaceInFilesManager.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,230 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+using System.Diagnostics;
+using System.Threading;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+using MonoDevelop.Gui.Dialogs;
+using MonoDevelop.Gui.Pads;
+
+using Gtk;
+
+namespace MonoDevelop.Gui.Search
+{
+ public class SearchReplaceInFilesManager
+ {
+ public static ReplaceInFilesDialog ReplaceDialog;
+
+ static IFind find = new DefaultFind();
+ static SearchOptions searchOptions = new SearchOptions("SharpDevelop.SearchAndReplace.SearchAndReplaceInFilesProperties");
+
+ static DateTime timer;
+ static bool searching;
+ static bool cancelled;
+ static string searchError;
+
+ public static SearchOptions SearchOptions {
+ get {
+ return searchOptions;
+ }
+ }
+
+ static SearchReplaceInFilesManager()
+ {
+ searchOptions.SearchStrategyTypeChanged += new EventHandler(InitializeSearchStrategy);
+ searchOptions.DocumentIteratorTypeChanged += new EventHandler(InitializeDocumentIterator);
+ InitializeDocumentIterator(null, null);
+ InitializeSearchStrategy(null, null);
+ }
+
+ static void InitializeSearchStrategy(object sender, EventArgs e)
+ {
+ find.SearchStrategy = SearchReplaceUtilities.CreateSearchStrategy(SearchOptions.SearchStrategyType);
+ }
+
+ static void InitializeDocumentIterator(object sender, EventArgs e)
+ {
+ find.DocumentIterator = SearchReplaceUtilities.CreateDocumentIterator(SearchOptions.DocumentIteratorType);
+ }
+
+ /// <remarks>
+ /// This method displays the search result in the task view
+ /// </remarks>
+ static void DisplaySearchResult(ISearchResult result)
+ {
+ if (result.Line != -1) {
+ string text = result.DocumentInformation.GetLineTextAtOffset (result.Offset);
+ Runtime.TaskService.AddTask (new Task (result.FileName, text, result.Column, result.Line));
+ } else {
+ string msg = string.Format (GettextCatalog.GetString ("Match at offset {0}"), result.Offset);
+ Runtime.TaskService.AddTask (new Task(result.FileName, msg, -1, -1));
+ }
+ }
+
+ static bool InitializeSearchInFiles()
+ {
+ Debug.Assert(searchOptions != null);
+
+ Runtime.TaskService.ClearTasks();
+
+ InitializeDocumentIterator(null, null);
+ InitializeSearchStrategy(null, null);
+ find.Reset();
+
+ try {
+ find.SearchStrategy.CompilePattern(searchOptions);
+ } catch {
+ Runtime.MessageService.ShowMessage (GettextCatalog.GetString ("Search pattern is invalid"), DialogPointer);
+ return false;
+ }
+ return true;
+ }
+
+ static void FinishSearchInFiles ()
+ {
+ string msg;
+ if (searchError != null)
+ msg = string.Format (GettextCatalog.GetString ("The search could not be finished: {0}"), searchError);
+ else if (cancelled)
+ msg = GettextCatalog.GetString ("Search cancelled.");
+ else
+ msg = string.Format (GettextCatalog.GetString ("Search completed. {0} matches found in {1} files."), find.MatchCount, find.SearchedFileCount);
+
+ Runtime.TaskService.AddTask (new Task(null, msg, -1, -1));
+ Runtime.TaskService.ShowTasks ();
+
+ Console.WriteLine ("Search time: " + (DateTime.Now - timer).TotalSeconds);
+ searching = false;
+
+ // tell the user search is done.
+/* Runtime.MessageService.ShowMessage (GettextCatalog.GetString ("Search completed"));
+ Console.WriteLine ("Done");
+*/ }
+
+ public static void ReplaceAll()
+ {
+ if (searching) {
+ if (!Runtime.MessageService.AskQuestion (GettextCatalog.GetString ("There is a search already in progress. Do you want to cancel it?")))
+ return;
+ CancelSearch ();
+ }
+
+ if (!InitializeSearchInFiles()) {
+ return;
+ }
+
+ string msg = string.Format (GettextCatalog.GetString ("Replacing '{0}' in {1}."), searchOptions.SearchPattern, searchOptions.SearchDirectory);
+ Runtime.TaskService.AddTask (new Task(null, msg, -1, -1));
+
+ timer = DateTime.Now;
+ Runtime.DispatchService.BackgroundDispatch (new MessageHandler(ReplaceAllThread));
+ }
+
+ public static void ReplaceAllThread()
+ {
+ searching = true;
+ searchError = null;
+
+ while (!cancelled)
+ {
+ try
+ {
+ ISearchResult result = find.FindNext(searchOptions);
+ if (result == null) {
+ break;
+ }
+
+ find.Replace(result, result.TransformReplacePattern(SearchOptions.ReplacePattern));
+ DisplaySearchResult (result);
+ }
+ catch (Exception ex)
+ {
+ searchError = ex.Message;
+ break;
+ }
+ }
+
+ FinishSearchInFiles ();
+ }
+
+ public static void FindAll()
+ {
+ if (searching) {
+ if (!Runtime.MessageService.AskQuestion (GettextCatalog.GetString ("There is a search already in progress. Do you want to cancel it?")))
+ return;
+ CancelSearch ();
+ }
+
+ if (!InitializeSearchInFiles()) {
+ return;
+ }
+
+ string msg = string.Format (GettextCatalog.GetString ("Looking for '{0}' in {1}."), searchOptions.SearchPattern, searchOptions.SearchDirectory);
+ Runtime.TaskService.AddTask (new Task(null, msg, -1, -1));
+
+ timer = DateTime.Now;
+ Runtime.DispatchService.BackgroundDispatch (new MessageHandler(FindAllThread));
+ }
+
+ public static void FindAllThread()
+ {
+ searching = true;
+ searchError = null;
+
+ while (!cancelled)
+ {
+ try
+ {
+ ISearchResult result = find.FindNext (searchOptions);
+ if (result == null) {
+ break;
+ }
+
+ DisplaySearchResult (result);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine (ex);
+ searchError = ex.Message;
+ break;
+ }
+ }
+
+ FinishSearchInFiles ();
+ }
+
+ public static void CancelSearch ()
+ {
+ if (!searching) return;
+ cancelled = true;
+ find.Cancel ();
+
+ while (searching) {
+ if (Gtk.Application.EventsPending ())
+ Gtk.Application.RunIteration ();
+ Thread.Sleep (10);
+ }
+
+ cancelled = false;
+ }
+
+ public static Gtk.Dialog DialogPointer
+ {
+ get {
+ if ( ReplaceDialog != null ){
+ return ReplaceDialog.DialogPointer;
+ }
+ return null;
+ }
+ }
+
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchReplaceManager.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchReplaceManager.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchReplaceManager.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,197 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+using System.Diagnostics;
+
+using MonoDevelop.Gui;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+using MonoDevelop.Gui.Dialogs;
+
+namespace MonoDevelop.Gui.Search
+{
+ public enum DocumentIteratorType {
+ None,
+ CurrentDocument,
+ AllOpenFiles,
+ WholeCombine,
+ Directory // only used for search in files
+ }
+
+ public enum SearchStrategyType {
+ None,
+ Normal,
+ RegEx,
+ Wildcard
+ }
+
+ public class SearchReplaceManager
+ {
+ public static ReplaceDialog ReplaceDialog = null;
+
+ static IFind find = new DefaultFind();
+ static SearchOptions searchOptions = new SearchOptions("SharpDevelop.SearchAndReplace.SearchAndReplaceProperties");
+
+ public static SearchOptions SearchOptions {
+ get {
+ return searchOptions;
+ }
+ }
+
+ static SearchReplaceManager()
+ {
+ searchOptions.SearchStrategyTypeChanged += new EventHandler(InitializeSearchStrategy);
+ searchOptions.DocumentIteratorTypeChanged += new EventHandler(InitializeDocumentIterator);
+ InitializeDocumentIterator(null, null);
+ InitializeSearchStrategy(null, null);
+ }
+
+ static void InitializeSearchStrategy(object sender, EventArgs e)
+ {
+ find.SearchStrategy = SearchReplaceUtilities.CreateSearchStrategy(SearchOptions.SearchStrategyType);
+ }
+
+ static void InitializeDocumentIterator(object sender, EventArgs e)
+ {
+ find.DocumentIterator = SearchReplaceUtilities.CreateDocumentIterator(SearchOptions.DocumentIteratorType);
+ }
+
+ // TODO: Transform Replace Pattern
+ public static void Replace()
+ {
+ if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null) {
+ IEditable editable = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent as IEditable;
+ if (editable.SelectedText == SearchOptions.SearchPattern.ToLower ()) {
+ editable.SelectedText = SearchOptions.ReplacePattern;
+ }
+ }
+ FindNext();
+ }
+
+ public static void MarkAll()
+ {
+ find.Reset();
+ try {
+ find.SearchStrategy.CompilePattern(searchOptions);
+ } catch {
+ Runtime.MessageService.ShowMessage (GettextCatalog.GetString ("Search pattern is invalid"), DialogPointer);
+ return;
+ }
+ while (true) {
+ ISearchResult result = SearchReplaceManager.find.FindNext(searchOptions);
+
+ if (result == null) {
+ Runtime.MessageService.ShowMessage(GettextCatalog.GetString ("Mark all completed"), DialogPointer );
+ find.Reset();
+ return;
+ } else {
+ IBookmarkBuffer textArea = OpenView (result.FileName) as IBookmarkBuffer;
+ if (textArea != null) {
+ object pos = textArea.GetPositionFromOffset (result.Offset);
+ textArea.SetBookmarked (pos, true);
+ }
+ }
+ }
+ }
+
+ public static void ReplaceAll()
+ {
+ find.Reset();
+ try {
+ find.SearchStrategy.CompilePattern(searchOptions);
+ } catch {
+ Runtime.MessageService.ShowMessage (GettextCatalog.GetString ("Search pattern is invalid"), DialogPointer);
+ return;
+ }
+
+ while (true) {
+ ISearchResult result = SearchReplaceManager.find.FindNext(SearchReplaceManager.searchOptions);
+
+ if (result == null) {
+ Runtime.MessageService.ShowMessage( string.Format (GettextCatalog.GetString ("Replace all finished. {0} matches found."), find.MatchCount), DialogPointer );
+ find.Reset();
+ return;
+ } else {
+ string transformedPattern = result.TransformReplacePattern(SearchOptions.ReplacePattern);
+ find.Replace (result, transformedPattern);
+ }
+ }
+ }
+
+ static ISearchResult lastResult = null;
+ public static void FindNext()
+ {
+ if (find == null ||
+ searchOptions.SearchPattern == null ||
+ searchOptions.SearchPattern.Length == 0) {
+ return;
+ }
+
+ // Restart the search if the file or cursor position has changed
+ // since the last FindNext.
+
+ if (lastResult != null) {
+ if (find.DocumentIterator.CurrentFileName != lastResult.FileName)
+ find.Reset ();
+ else {
+ ITextBuffer textArea = OpenView (lastResult.FileName) as ITextBuffer;
+ if (textArea == null || (lastResult != null && textArea.GetOffsetFromPosition (textArea.CursorPosition) != lastResult.Offset + lastResult.Length)) {
+ find.Reset();
+ }
+ }
+ }
+ else
+ find.Reset ();
+
+ try {
+ find.SearchStrategy.CompilePattern(searchOptions);
+ } catch {
+ Runtime.MessageService.ShowMessage (GettextCatalog.GetString ("Search pattern is invalid"), DialogPointer);
+ return;
+ }
+
+ ISearchResult result = find.FindNext(searchOptions);
+
+ if (result == null) {
+ Runtime.MessageService.ShowMessage(GettextCatalog.GetString ("Search string not Found:") + "\n" + SearchOptions.SearchPattern, DialogPointer );
+ find.Reset();
+ } else {
+ ITextBuffer textArea = OpenView (result.FileName) as ITextBuffer;
+ if (textArea != null) {
+ Console.WriteLine ("textArea.Text:" + (textArea.Text==null));
+ int startPos = Math.Min (textArea.Text.Length, Math.Max(0, result.Offset));
+ int endPos = Math.Min (textArea.Text.Length, startPos + result.Length);
+
+ textArea.ShowPosition (textArea.GetPositionFromOffset (endPos));
+ textArea.Select (textArea.GetPositionFromOffset (endPos), textArea.GetPositionFromOffset (startPos));
+ }
+ }
+
+ lastResult = result;
+ }
+
+ static object OpenView (string fileName)
+ {
+ Runtime.FileService.OpenFile (fileName).WaitForCompleted ();
+ return WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent;
+ }
+
+ public static Gtk.Dialog DialogPointer
+ {
+ get {
+ if ( ReplaceDialog != null ) {
+ return ReplaceDialog.DialogPointer;
+ }
+ return null;
+ }
+ }
+
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchReplaceUtilities.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchReplaceUtilities.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchReplaceUtilities.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,87 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+
+namespace MonoDevelop.Gui.Search
+{
+ public sealed class SearchReplaceUtilities
+ {
+ public static bool IsTextAreaSelected {
+ get {
+ return WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null && WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent is ITextBuffer;
+ }
+ }
+
+ public static bool IsWordSeparator (char c)
+ {
+ return Char.IsWhiteSpace (c) || (Char.IsPunctuation (c) && c != '_');
+ }
+
+/* public static bool IsWholeWordAt(SourceEditorBuffer document, int offset, int length)
+ {
+ return (offset - 1 < 0 || IsWordSeparator (document.GetCharAt(offset - 1))) &&
+ (offset + length + 1 >= document.Length || IsWordSeparator (document.GetCharAt(offset + length)));
+ }
+*/
+ public static bool IsWholeWordAt (ITextIterator it, int length)
+ {
+ char c = it.GetCharRelative (-1);
+ if (c != char.MinValue && !IsWordSeparator (c)) return false;
+
+ c = it.GetCharRelative (length);
+ return (c == char.MinValue || IsWordSeparator (c));
+ }
+
+ /*public static int CalcCurrentOffset(IDocument document)
+ {
+// TODO:
+// int endOffset = document.Caret.Offset % document.TextLength;
+// return endOffset;
+ return 0;
+ }*/
+
+ public static ISearchStrategy CreateSearchStrategy(SearchStrategyType type)
+ {
+ switch (type) {
+ case SearchStrategyType.None:
+ return null;
+ case SearchStrategyType.Normal:
+ return new BruteForceSearchStrategy(); // new KMPSearchStrategy();
+ case SearchStrategyType.RegEx:
+ return new RegExSearchStrategy();
+ case SearchStrategyType.Wildcard:
+ return new WildcardSearchStrategy();
+ default:
+ throw new System.NotImplementedException("CreateSearchStrategy for type " + type);
+ }
+ }
+
+
+ public static IDocumentIterator CreateDocumentIterator(DocumentIteratorType type)
+ {
+ switch (type) {
+ case DocumentIteratorType.None:
+ return null;
+ case DocumentIteratorType.CurrentDocument:
+ return new CurrentDocumentIterator();
+ case DocumentIteratorType.Directory:
+ return new DirectoryDocumentIterator(SearchReplaceInFilesManager.SearchOptions.SearchDirectory,
+ SearchReplaceInFilesManager.SearchOptions.FileMask,
+ SearchReplaceInFilesManager.SearchOptions.SearchSubdirectories);
+ case DocumentIteratorType.AllOpenFiles:
+ return new AllOpenDocumentIterator();
+ case DocumentIteratorType.WholeCombine:
+ return new WholeProjectDocumentIterator();
+ default:
+ throw new System.NotImplementedException("CreateDocumentIterator for type " + type);
+ }
+ }
+ }
+
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchResult/DefaultSearchResult.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchResult/DefaultSearchResult.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchResult/DefaultSearchResult.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,74 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+
+namespace MonoDevelop.Gui.Search
+{
+ public class DefaultSearchResult : ISearchResult
+ {
+ IDocumentInformation documentInformation;
+ int offset;
+ int length;
+ int line;
+ int column;
+
+ public DefaultSearchResult (ITextIterator iter, int length)
+ {
+ offset = iter.Position;
+ line = iter.Line;
+ column = iter.Column;
+ this.length = length;
+ documentInformation = iter.DocumentInformation;
+ }
+
+ public string FileName {
+ get {
+ return documentInformation.FileName;
+ }
+ }
+
+ public IDocumentInformation DocumentInformation {
+ get {
+ return documentInformation;
+ }
+ }
+
+ public int Offset {
+ get {
+ return offset;
+ }
+ }
+
+ public int Length {
+ get {
+ return length;
+ }
+ }
+
+ public int Line {
+ get { return line; }
+ }
+
+ public int Column {
+ get { return column; }
+ }
+
+ public virtual string TransformReplacePattern (string pattern)
+ {
+ return pattern;
+ }
+
+ public override string ToString()
+ {
+ return String.Format("[DefaultLocation: FileName={0}, Offset={1}, Length={2}]",
+ FileName,
+ Offset,
+ Length);
+ }
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchResult/ISearchResult.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchResult/ISearchResult.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchResult/ISearchResult.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,55 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+
+namespace MonoDevelop.Gui.Search
+{
+ /// <summary>
+ /// This interface describes the result a search strategy must
+ /// return with a call to find next.
+ /// </summary>
+ public interface ISearchResult
+ {
+ /// <value>
+ /// Returns the file name of the search result. This
+ /// value is null till the ProvidedDocumentInformation
+ /// property is set.
+ /// </value>
+ string FileName {
+ get;
+ }
+
+ IDocumentInformation DocumentInformation {
+ get;
+ }
+
+ /// <value>
+ /// The offset of the pattern match
+ /// </value>
+ int Offset {
+ get;
+ }
+
+ int Line { get; }
+
+ int Column {get; }
+
+ /// <value>
+ /// The length of the pattern match.
+ /// </value>
+ int Length {
+ get;
+ }
+
+ /// <remarks>
+ /// Replace operations must transform the replace pattern with this
+ /// method.
+ /// </remarks>
+ string TransformReplacePattern(string pattern);
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/BruteForceSearchStrategy.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/BruteForceSearchStrategy.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/BruteForceSearchStrategy.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,109 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Globalization;
+using MonoDevelop.Core.Properties;
+using MonoDevelop.Internal.Undo;
+
+namespace MonoDevelop.Gui.Search
+{
+ /// <summary>
+ /// Only for fallback purposes.
+ /// </summary>
+ public class BruteForceSearchStrategy : ISearchStrategy
+ {
+ string searchPattern;
+
+ int InternalFindNext(ITextIterator textIterator, SearchOptions options)
+ {
+ int[] compareIndex = new int [searchPattern.Length];
+ int[] startPositions = new int [searchPattern.Length];
+ int maxPoss = 0;
+ bool ignoreCase = options.IgnoreCase;
+ bool searchWord = options.SearchWholeWordOnly;
+ CultureInfo cinfo = CultureInfo.InvariantCulture;
+ int patternLength = searchPattern.Length;
+ bool wasWordStart = true;
+
+ char first = searchPattern[0];
+
+ while (textIterator.MoveAhead(1))
+ {
+ char c = textIterator.Current;
+ if (ignoreCase) c = Char.ToUpper (c, cinfo);
+
+ int freePos = -1;
+ for (int n=0; n<maxPoss; n++)
+ {
+ int pos = compareIndex[n];
+ if (pos != 0) {
+ if (searchPattern[pos] == c) {
+ pos++;
+ if (pos == patternLength) {
+ if (searchWord) {
+ int curp = textIterator.Position;
+ bool endw = !textIterator.MoveAhead (1);
+ endw = endw || SearchReplaceUtilities.IsWordSeparator (textIterator.Current);
+ textIterator.Position = curp;
+ if (endw) return startPositions[n];
+ }
+ else
+ return startPositions[n];
+ }
+ else {
+ compareIndex[n] = pos;
+ continue;
+ }
+ }
+ compareIndex[n] = 0;
+ if (n == maxPoss-1)
+ maxPoss = n;
+ }
+
+ if (freePos == -1)
+ freePos = pos;
+ }
+
+ if (c == first && (!searchWord || wasWordStart)) {
+ if (patternLength == 1)
+ return textIterator.Position;
+
+ if (freePos == -1) {
+ freePos = maxPoss;
+ maxPoss++;
+ }
+
+ compareIndex [freePos] = 1;
+ startPositions [freePos] = textIterator.Position;
+ }
+ wasWordStart = SearchReplaceUtilities.IsWordSeparator (c);
+ }
+
+ return -1;
+ }
+
+ public void CompilePattern(SearchOptions options)
+ {
+ searchPattern = options.IgnoreCase ? options.SearchPattern.ToUpper() : options.SearchPattern;
+ }
+
+ public ISearchResult FindNext(ITextIterator textIterator, SearchOptions options)
+ {
+ int offset = InternalFindNext(textIterator, options);
+ if (offset >= 0) {
+ int pos = textIterator.Position;
+ textIterator.Position = offset;
+ DefaultSearchResult sr = new DefaultSearchResult (textIterator, searchPattern.Length);
+ textIterator.Position = pos;
+ return sr;
+ } else
+ return null;
+ }
+ }
+}
+;
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/ISearchStrategy.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/ISearchStrategy.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/ISearchStrategy.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,31 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+
+namespace MonoDevelop.Gui.Search
+{
+ /// <summary>
+ /// This interface is the basic interface which all
+ /// search algorithms must implement.
+ /// </summary>
+ public interface ISearchStrategy
+ {
+ /// <remarks>
+ /// Only with a call to this method the search strategy must
+ /// update their pattern information. This method will be called
+ /// before the FindNext function.
+ /// </remarks>
+ void CompilePattern(SearchOptions options);
+
+ /// <remarks>
+ /// The find next method should search the next occurrence of the
+ /// compiled pattern in the text using the textIterator and options.
+ /// </remarks>
+ ISearchResult FindNext(ITextIterator textIterator, SearchOptions options);
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/KMPSearchStrategy.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/KMPSearchStrategy.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/KMPSearchStrategy.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,84 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Andrea Paatz" email="andrea at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+
+namespace MonoDevelop.Gui.Search
+{
+ /// <summary>
+ /// Implements the Knuth, Morris, Pratt searching algorithm.
+ /// </summary>
+ public class KMPSearchStrategy : ISearchStrategy
+ {
+ string searchPattern;
+ int[] overlap;
+
+ public void CompilePattern(SearchOptions options)
+ {
+ if (searchPattern != (options.IgnoreCase ? options.SearchPattern.ToUpper() : options.SearchPattern)) {
+ searchPattern = options.IgnoreCase ? options.SearchPattern.ToUpper() : options.SearchPattern;
+ overlap = new int[searchPattern.Length + 1];
+ Preprocessing();
+ }
+ }
+
+ void Preprocessing()
+ {
+ overlap[0] = -1;
+ for (int i = 0, j = -1; i < searchPattern.Length;) {
+ while (j >= 0 && searchPattern[i] != searchPattern[j]) {
+ j = overlap[j];
+ }
+ ++i;
+ ++j;
+ overlap[i] = j;
+ }
+ }
+
+ int InternalFindNext(ITextIterator textIterator, SearchOptions options)
+ {
+ int j = 0;
+ if (!textIterator.MoveAhead(1)) {
+ return -1;
+ }
+ while (true) { // until pattern found or Iterator finished
+ while (j >= 0 && searchPattern[j] != (options.IgnoreCase ? Char.ToUpper(textIterator.GetCharRelative(j)) : textIterator.GetCharRelative(j))) {
+ if (!textIterator.MoveAhead(j - overlap[j])) {
+ return -1;
+ }
+ j = overlap[j];
+ }
+ if (++j >= searchPattern.Length) {
+ if ((!options.SearchWholeWordOnly || SearchReplaceUtilities.IsWholeWordAt(textIterator, searchPattern.Length))) {
+ return textIterator.Position;
+ }
+ if (!textIterator.MoveAhead(j - overlap[j])) {
+ return -1;
+ }
+ j = overlap[j];
+ }
+ }
+ }
+
+ public ISearchResult FindNext(ITextIterator textIterator, SearchOptions options)
+ {
+ int pos = textIterator.Position;
+
+ int offset = InternalFindNext(textIterator, options);
+ if (offset == -1) return null;
+
+ if (textIterator.GetCharRelative (searchPattern.Length) == char.MinValue) {
+ if (pos != offset)
+ return FindNext(textIterator, options);
+ else
+ return null;
+ }
+
+ return new DefaultSearchResult (textIterator, searchPattern.Length);
+ }
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/RegExSearchStrategy.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/RegExSearchStrategy.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/RegExSearchStrategy.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,47 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Text.RegularExpressions;
+
+namespace MonoDevelop.Gui.Search
+{
+ public class RegExSearchStrategy : ISearchStrategy
+ {
+ Regex regex = null;
+
+ public void CompilePattern(SearchOptions options)
+ {
+ RegexOptions regexOptions = RegexOptions.Compiled;
+ if (options.IgnoreCase) {
+ regexOptions |= RegexOptions.IgnoreCase;
+ }
+ regex = new Regex(options.SearchPattern, regexOptions);
+ }
+
+ public ISearchResult FindNext(ITextIterator textIterator, SearchOptions options)
+ {
+ if (!textIterator.MoveAhead(1)) return null;
+ if (regex == null) return null;
+
+ int pos = textIterator.Position;
+ string document = textIterator.ReadToEnd ();
+ textIterator.Position = pos;
+
+ Match m = regex.Match (document, 0);
+ if (m == null || m.Index <= 0 || m.Length <= 0) {
+ return null;
+ } else {
+ if (textIterator.MoveAhead (m.Index)) {
+ return new DefaultSearchResult (textIterator, m.Length);
+ } else {
+ return null;
+ }
+ }
+ }
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/WildcardSearchStrategy.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/WildcardSearchStrategy.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/SearchStrategy/WildcardSearchStrategy.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,160 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+
+using MonoDevelop.Core.Properties;
+using MonoDevelop.Internal.Undo;
+
+namespace MonoDevelop.Gui.Search
+{
+ /// <summary>
+ /// Implements a wildcard search strategy.
+ ///
+ /// Wildcard search has following pattern code :
+ /// * = Zero or more of any character
+ /// ? = Any single character
+ /// # = Any single digit
+ /// [...] = Any one character in the set
+ /// [!...] = Any one character not in the set
+ /// </summary>
+ public class WildcardSearchStrategy : ISearchStrategy
+ {
+ enum CommandType {
+ Match,
+ AnyZeroOrMore,
+ AnySingle,
+ AnyDigit,
+ AnyInList,
+ NoneInList
+ }
+
+ class Command {
+ public CommandType CommandType = CommandType.Match;
+ public char SingleChar = '\0';
+ public string CharList = String.Empty;
+ }
+
+ ArrayList patternProgram = null;
+
+ void CompilePattern(string pattern, bool ignoreCase)
+ {
+ patternProgram = new ArrayList();
+ for (int i = 0; i < pattern.Length; ++i) {
+ Command newCommand = new Command();
+ switch (pattern[i]) {
+ case '#':
+ newCommand.CommandType = CommandType.AnyDigit;
+ break;
+ case '*':
+ newCommand.CommandType = CommandType.AnyZeroOrMore;
+ break;
+ case '?':
+ newCommand.CommandType = CommandType.AnySingle;
+ break;
+ case '[':
+ int index = pattern.IndexOf(']', i);
+ if (index > 0) {
+ newCommand.CommandType = CommandType.AnyInList;
+ string list = pattern.Substring(i + 1, index - i - 1);
+ if (list[0] == '!') {
+ newCommand.CommandType = CommandType.NoneInList;
+ list = list.Substring(1);
+ }
+ newCommand.CharList = ignoreCase ? list.ToUpper() : list;
+ i = index;
+ } else {
+ goto default;
+ }
+ break;
+ default:
+ newCommand.CommandType = CommandType.Match;
+ newCommand.SingleChar = ignoreCase ? Char.ToUpper(pattern[i]) : pattern[i];
+ break;
+ }
+ patternProgram.Add(newCommand);
+ }
+ }
+
+ int Match (ITextIterator textIterator, bool ignoreCase, int programStart)
+ {
+ int matchCharCount = 0;
+ bool moreChars = true;
+ for (int pc = programStart; pc < patternProgram.Count; ++pc)
+ {
+ if (!moreChars) return -1;
+
+ char ch = ignoreCase ? Char.ToUpper(textIterator.Current) : textIterator.Current;
+ Command cmd = (Command)patternProgram[pc];
+
+ switch (cmd.CommandType) {
+ case CommandType.Match:
+ if (ch != cmd.SingleChar) {
+ return -1;
+ }
+ break;
+ case CommandType.AnyZeroOrMore:
+ int p = textIterator.Position;
+ int subMatch = Match (textIterator, ignoreCase, pc + 1);
+ if (subMatch != -1) return matchCharCount + subMatch;
+ textIterator.Position = p;
+ if (!textIterator.MoveAhead (1)) return -1;
+ subMatch = Match (textIterator, ignoreCase, pc);
+ if (subMatch != -1) return matchCharCount + subMatch;
+ else return -1;
+ case CommandType.AnySingle:
+ break;
+ case CommandType.AnyDigit:
+ if (!Char.IsDigit(ch)) {
+ return -1;
+ }
+ break;
+ case CommandType.AnyInList:
+ if (cmd.CharList.IndexOf(ch) < 0) {
+ return -1;
+ }
+ break;
+ case CommandType.NoneInList:
+ if (cmd.CharList.IndexOf(ch) >= 0) {
+ return -1;
+ }
+ break;
+ }
+ matchCharCount++;
+ moreChars = textIterator.MoveAhead (1);
+ }
+ return matchCharCount;
+ }
+
+ int InternalFindNext(ITextIterator textIterator, SearchOptions options)
+ {
+ while (textIterator.MoveAhead(1))
+ {
+ int pos = textIterator.Position;
+ int charCount = Match (textIterator, options.IgnoreCase, 0);
+ textIterator.Position = pos;
+ if (charCount != -1) {
+ if (!options.SearchWholeWordOnly || SearchReplaceUtilities.IsWholeWordAt (textIterator, charCount))
+ return charCount;
+ }
+ }
+ return -1;
+ }
+
+ public void CompilePattern(SearchOptions options)
+ {
+ CompilePattern(options.SearchPattern, options.IgnoreCase);
+ }
+
+ public ISearchResult FindNext(ITextIterator textIterator, SearchOptions options)
+ {
+ int charCount = InternalFindNext(textIterator, options);
+ return charCount != -1 ? new DefaultSearchResult (textIterator, charCount) : null;
+ }
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/TextIterator/ExtendedStreamReader.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/TextIterator/ExtendedStreamReader.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/TextIterator/ExtendedStreamReader.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,300 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Lluis Sanchez" email="lluis at ximian.com"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Text;
+
+namespace MonoDevelop.Gui.Search
+{
+ /// <summary>
+ /// This is a wrapper around StreamReader which is seekable.
+ /// </summary>
+ public class ExtendedStreamReader
+ {
+ StreamReader reader;
+
+ private const int DefaultCacheSize = 4096;
+ private const int MAX_CACHED_BUFFERS = 2;
+
+ char[][] cachedBuffers = new char[MAX_CACHED_BUFFERS][];
+ int[] cachedBufferStartPos = new int[MAX_CACHED_BUFFERS];
+ int[] cachedBufferCharCount = new int[MAX_CACHED_BUFFERS];
+
+ int streamReadPosition;
+ int currentBuffer;
+
+ int pos; // index into buffer[]
+
+ string changeBuffer;
+ int changePos = -1;
+ int curChangePosition = 0;
+ bool inChangeSection = false;
+
+ public ExtendedStreamReader (StreamReader reader)
+ {
+ this.reader = reader;
+
+ for (int n=0; n<MAX_CACHED_BUFFERS; n++) {
+ cachedBufferStartPos [n] = -1;
+ cachedBufferCharCount [n] = 0;
+ }
+ }
+
+ public int Position {
+ get {
+ if (inChangeSection) {
+ return changePos + curChangePosition;
+ }
+ else {
+ int p = cachedBufferStartPos [currentBuffer] + pos;
+ return p >= 0 ? p : 0;
+ }
+ }
+
+ set {
+ if (changePos != -1 && value >= changePos) {
+ curChangePosition = value - changePos;
+ inChangeSection = true;
+ }
+ else {
+ inChangeSection = false;
+
+ for (int n=0; n<MAX_CACHED_BUFFERS; n++)
+ {
+ int start = cachedBufferStartPos[n];
+ if (value >= start && value < start + cachedBufferCharCount [n]) {
+ pos = value - start;
+ currentBuffer = n;
+ return;
+ }
+ }
+
+ reader.BaseStream.Position = 0;
+ reader.DiscardBufferedData ();
+ streamReadPosition = 0;
+ currentBuffer = 0;
+
+ for (int n=0; n<MAX_CACHED_BUFFERS; n++) {
+ cachedBufferStartPos [n] = -1;
+ cachedBufferCharCount [n] = 0;
+ }
+
+ int cp = 0;
+ while (cp < value) {
+ Read ();
+ cp++;
+ }
+ }
+ }
+ }
+
+ private bool ReadBuffer ()
+ {
+ pos = 0;
+ if (currentBuffer > 0) {
+ currentBuffer--;
+ return cachedBufferCharCount [currentBuffer] > 0;
+ }
+
+ // Shift buffers
+
+ char[] lastBuffer = cachedBuffers [MAX_CACHED_BUFFERS-1];
+ for (int n=MAX_CACHED_BUFFERS-1; n>0; n--)
+ {
+ cachedBufferStartPos[n] = cachedBufferStartPos[n-1];
+ cachedBufferCharCount[n] = cachedBufferCharCount[n-1];
+ cachedBuffers[n] = cachedBuffers[n-1];
+ }
+
+ cachedBufferStartPos[0] = streamReadPosition;
+
+ if (lastBuffer == null)
+ lastBuffer = new char [DefaultCacheSize];
+
+ cachedBuffers [0] = lastBuffer;
+
+ int char_count = reader.Read (cachedBuffers [0], 0, cachedBuffers [0].Length);
+ cachedBufferCharCount [0] = char_count;
+ streamReadPosition += char_count;
+ return char_count > 0;
+ }
+
+ public int Peek ()
+ {
+ if (inChangeSection) {
+ if (curChangePosition >= changeBuffer.Length) return -1;
+ return changeBuffer [curChangePosition];
+ }
+
+ if (pos >= cachedBufferCharCount [currentBuffer] && !ReadBuffer ())
+ return -1;
+
+ return cachedBuffers[currentBuffer] [pos];
+ }
+
+ public int Read ()
+ {
+ if (inChangeSection) {
+ if (curChangePosition >= changeBuffer.Length) return -1;
+ return changeBuffer [curChangePosition++];
+ }
+
+ if (pos >= cachedBufferCharCount [currentBuffer] && !ReadBuffer ())
+ return -1;
+
+ int res = cachedBuffers[currentBuffer][pos++];
+
+ // Check if it has just entered the changed section
+
+ if (changePos != -1 && changePos >= Position) {
+ if (Position > changePos) {
+ throw new Exception ("Wrong position");
+ }
+ if (Position == changePos) {
+ inChangeSection = true;
+ curChangePosition = 0;
+ }
+ }
+
+ return res;
+ }
+
+ public int ReadBack ()
+ {
+ if (Position == 0) return -1;
+
+ if (inChangeSection) {
+ if (curChangePosition > 0) {
+ curChangePosition--;
+ return changeBuffer [curChangePosition];
+ }
+ Position--;
+ return cachedBuffers[currentBuffer][pos];
+ }
+
+ if (pos > 0) {
+ pos--;
+ return cachedBuffers[currentBuffer][pos];
+ }
+
+ Position--;
+ return cachedBuffers[currentBuffer][pos];
+ }
+
+ public string ReadToEnd ()
+ {
+ if (changePos == -1) {
+ StringBuilder sb = new StringBuilder ();
+ int c;
+ while ((c = Read()) != -1)
+ sb.Append ((char)c);
+
+ return sb.ToString ();
+ }
+ else if (inChangeSection) {
+ string doc = changeBuffer.Substring (curChangePosition);
+ curChangePosition = changeBuffer.Length;
+ return doc;
+ }
+ else {
+ StringBuilder sb = new StringBuilder ();
+ while (!inChangeSection)
+ sb.Append ((char)Read ());
+
+ inChangeSection = true;
+ curChangePosition = changeBuffer.Length;
+ return sb.ToString() + changeBuffer;
+ }
+ }
+
+ public void Remove (int length)
+ {
+ EnterChangeSection ();
+ changeBuffer = changeBuffer.Substring (0, curChangePosition) + changeBuffer.Substring (curChangePosition + length);
+ }
+
+ public void Insert (string newText)
+ {
+ EnterChangeSection ();
+ changeBuffer = changeBuffer.Substring (0, curChangePosition) + newText + changeBuffer.Substring (curChangePosition);
+ curChangePosition += newText.Length;
+ }
+
+ void EnterChangeSection ()
+ {
+ if (changePos == -1)
+ {
+ // This is the first change in the stream.
+
+ int curPos = Position;
+ changeBuffer = ReadToEnd ();
+ changePos = curPos;
+ curChangePosition = 0;
+ inChangeSection = true;
+ }
+ else if (!inChangeSection)
+ {
+ // There is already a change section, but we are not inside.
+ // Expand the change section to include the current position.
+
+ int curPos = Position;
+ StringBuilder sb = new StringBuilder ();
+ while (!inChangeSection)
+ sb.Append ((char)Read ());
+ changeBuffer = sb.ToString () + changeBuffer;
+ Position = curPos;
+ changePos = curPos;
+ curChangePosition = 0;
+ inChangeSection = true;
+ }
+ }
+
+ public void Close ()
+ {
+ reader.Close ();
+ }
+
+ public bool Modified {
+ get { return changePos != -1; }
+ }
+
+ public void SaveToFile (string file)
+ {
+ StreamWriter swriter = new StreamWriter (file, false, reader.CurrentEncoding);
+
+ try {
+ // Write the old file until the replace position
+
+ reader.BaseStream.Position = 0;
+ reader.DiscardBufferedData ();
+
+ char[] buffer = new char [16*1024];
+ int count = changePos != -1 ? changePos : int.MaxValue;
+ while (count > 0) {
+ int toread = count > buffer.Length ? buffer.Length : count;
+ int nread = reader.Read (buffer, 0, toread);
+ if (nread == 0) break;
+ swriter.Write (buffer, 0, nread);
+ count -= nread;
+ }
+
+ if (changePos == -1)
+ return;
+
+ // Write the modified text
+
+ swriter.Write (changeBuffer);
+ }
+ finally
+ {
+ swriter.Close ();
+ }
+ }
+ }
+}
+
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/TextIterator/ForwardTextFileIterator.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/TextIterator/ForwardTextFileIterator.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/TextIterator/ForwardTextFileIterator.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,183 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Lluis Sanchez" email="lluis at ximian.com"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Text;
+using System.Diagnostics;
+using System.Collections;
+
+namespace MonoDevelop.Gui.Search
+{
+ public class ForwardTextFileIterator : ITextIterator
+ {
+ string fileName;
+ FileStream stream;
+ StreamReader streamReader;
+ ExtendedStreamReader reader;
+ bool started;
+ IDocumentInformation document;
+ int line;
+ int lineStartOffset;
+ bool lineInSync;
+
+ public ForwardTextFileIterator (IDocumentInformation document, string fileName)
+ {
+ this.document = document;
+ this.fileName = fileName;
+ stream = new FileStream (fileName, FileMode.Open, FileAccess.Read);
+ streamReader = new StreamReader (stream);
+ reader = new ExtendedStreamReader (streamReader);
+ Reset();
+ line = lineStartOffset = 0;
+ lineInSync = true;
+ }
+
+ public IDocumentInformation DocumentInformation {
+ get { return document; }
+ }
+
+ public char Current {
+ get {
+ return (char) reader.Peek ();
+ }
+ }
+
+ public int Position {
+ get {
+ return reader.Position;
+ }
+ set {
+ int pos = reader.Position;
+ if (value == pos)
+ return;
+ if (value > pos && lineInSync)
+ MoveAhead (value - pos); // This updates the line count
+ else {
+ if (value < lineStartOffset)
+ lineInSync = false;
+ reader.Position = value;
+ }
+ }
+ }
+
+ public int Line {
+ get {
+ if (!lineInSync)
+ SyncLinePosition ();
+ return line;
+ }
+ }
+ public int Column {
+ get {
+ if (!lineInSync)
+ SyncLinePosition ();
+ return Position - lineStartOffset;
+ }
+ }
+
+ void SyncLinePosition ()
+ {
+ int pos = reader.Position;
+ reader.Position = 0;
+ line = lineStartOffset = 0;
+ MoveAhead (pos);
+ lineInSync = true;
+ }
+
+ public char GetCharRelative(int offset)
+ {
+ int pos = reader.Position;
+
+ if (offset < 0) {
+ offset = -offset;
+ for (int n=0; n<offset; n--)
+ if (reader.ReadBack () == -1) {
+ reader.Position = pos;
+ return char.MinValue;
+ }
+ }
+ else {
+ for (int n=0; n<offset; n++) {
+ if (reader.Read () == -1) {
+ reader.Position = pos;
+ return char.MinValue;
+ }
+ }
+ }
+
+ char c = (char) reader.Peek ();
+ reader.Position = pos;
+ return c;
+ }
+
+ public bool MoveAhead(int numChars)
+ {
+ Debug.Assert(numChars > 0);
+
+ if (!started) {
+ started = true;
+ return (reader.Peek () != -1);
+ }
+
+ int nc = 0;
+ while (nc != -1 && numChars > 0) {
+ numChars--;
+ nc = reader.Read ();
+ if ((char)nc == '\n') {
+ line++;
+ lineStartOffset = reader.Position;
+ }
+ }
+
+ if (nc == -1) return false;
+ return reader.Peek() != -1;
+ }
+
+ public string ReadToEnd ()
+ {
+ return reader.ReadToEnd ();
+ }
+
+ public void Replace (int length, string pattern)
+ {
+ reader.Remove (length);
+ reader.Insert (pattern);
+ }
+
+ public void Reset()
+ {
+ reader.Position = 0;
+ }
+
+ public void Close ()
+ {
+ if (reader.Modified)
+ {
+ string fileBackup = Path.GetTempFileName ();
+ File.Copy (fileName, fileBackup, true);
+
+ try {
+ File.Delete (fileName);
+ reader.SaveToFile (fileName);
+ reader.Close ();
+ }
+ catch
+ {
+ reader.Close ();
+ if (File.Exists (fileName)) File.Delete (fileName);
+ File.Move (fileBackup, fileName);
+ throw;
+ }
+
+ File.Delete (fileBackup);
+ }
+ else
+ reader.Close ();
+ }
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/TextIterator/ForwardTextIterator.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/TextIterator/ForwardTextIterator.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/TextIterator/ForwardTextIterator.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,202 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Diagnostics;
+using System.Collections;
+
+using MonoDevelop.Gui;
+
+namespace MonoDevelop.Gui.Search
+{
+ public class ForwardTextIterator : ITextIterator
+ {
+ enum TextIteratorState {
+ Resetted,
+ Iterating,
+ Done,
+ }
+
+ TextIteratorState state;
+
+ Gtk.TextBuffer textBuffer;
+ int currentOffset;
+ int endOffset;
+ IDocumentInformation docInfo;
+
+ public IDocumentInformation DocumentInformation {
+ get { return docInfo; }
+ }
+
+ public char Current {
+ get {
+ switch (state) {
+ case TextIteratorState.Resetted:
+ throw new System.InvalidOperationException("Call moveAhead first");
+ case TextIteratorState.Iterating:
+ return GetCharAt(currentOffset);
+ case TextIteratorState.Done:
+ throw new System.InvalidOperationException("TextIterator is at the end");
+ default:
+ throw new System.InvalidOperationException("unknown text iterator state");
+ }
+ }
+ }
+
+ public int Position {
+ get {
+ if (state == TextIteratorState.Done) return -1;
+ else return currentOffset;
+ }
+ set {
+ if (value == -1) {
+ state = TextIteratorState.Done;
+ currentOffset = endOffset;
+ return;
+ }
+ if (state == TextIteratorState.Done)
+ state = TextIteratorState.Iterating;
+ currentOffset = value;
+ }
+ }
+
+ public int Line {
+ get {
+ int pos = Position;
+ if (pos == -1) return -1;
+ return textBuffer.GetIterAtOffset (pos).Line;
+ }
+ }
+ public int Column {
+ get {
+ int pos = Position;
+ if (pos == -1) return -1;
+ return textBuffer.GetIterAtOffset (pos).LineOffset;
+ }
+ }
+
+ public ForwardTextIterator (IDocumentInformation docInfo, Gtk.TextView document, int endOffset)
+ {
+ Debug.Assert(endOffset >= 0 && endOffset < BufferLength);
+
+ this.docInfo = docInfo;
+ this.textBuffer = document.Buffer;
+ this.endOffset = endOffset;
+ Reset();
+ }
+
+ public char GetCharRelative(int offset)
+ {
+ if (state != TextIteratorState.Iterating) {
+ throw new System.InvalidOperationException();
+ }
+
+ if (currentOffset + offset < 0 || currentOffset + offset >= BufferLength)
+ return char.MinValue;
+
+ int realOffset = (currentOffset + (1 + Math.Abs(offset) / BufferLength) * BufferLength + offset) % BufferLength;
+
+ return GetCharAt(realOffset);
+ }
+
+ public bool MoveAhead(int numChars)
+ {
+ Debug.Assert(numChars > 0);
+
+ switch (state) {
+ case TextIteratorState.Resetted:
+ currentOffset = endOffset;
+ state = TextIteratorState.Iterating;
+ return true;
+ case TextIteratorState.Done:
+ return false;
+ case TextIteratorState.Iterating:
+ int oldOffset = currentOffset;
+ currentOffset = (currentOffset + numChars) % BufferLength;
+ bool finish = (oldOffset > currentOffset || oldOffset < endOffset) && currentOffset >= endOffset;
+ if (finish) {
+ state = TextIteratorState.Done;
+ currentOffset = endOffset;
+ return false;
+ }
+ return true;
+ default:
+ throw new Exception("Unknown text iterator state");
+ }
+ }
+
+ public string ReadToEnd ()
+ {
+ if (state == TextIteratorState.Done) return "";
+
+ string doc = "";
+ if (currentOffset >= endOffset) {
+ doc = GetText (currentOffset, BufferLength - currentOffset);
+ currentOffset = 0;
+ }
+
+ doc += GetText (currentOffset, endOffset - currentOffset);
+ currentOffset = endOffset;
+ return doc;
+ }
+
+ public void Replace (int length, string pattern)
+ {
+ Gtk.TextIter start = textBuffer.GetIterAtOffset (currentOffset);
+ Gtk.TextIter end = textBuffer.GetIterAtOffset (currentOffset + length);
+ textBuffer.Delete (ref start, ref end);
+
+ Gtk.TextIter put = textBuffer.GetIterAtOffset (currentOffset);
+ textBuffer.Insert (ref put, pattern);
+
+ if (currentOffset <= endOffset) {
+ endOffset = endOffset - length + pattern.Length;
+ }
+
+ currentOffset = currentOffset - length + pattern.Length;
+ }
+
+ char GetCharAt (int offset)
+ {
+ if (offset < 0)
+ offset = 0;
+ Gtk.TextIter iter = textBuffer.GetIterAtOffset (offset);
+ if (iter.Equals (Gtk.TextIter.Zero))
+ return ' ';
+ if (iter.Char == null || iter.Char.Length == 0)
+ return ' ';
+ return iter.Char[0];
+ }
+
+ string GetText (int start, int length)
+ {
+ Gtk.TextIter begin_iter = textBuffer.GetIterAtOffset (start);
+ Gtk.TextIter end_iter = textBuffer.GetIterAtOffset (start + length);
+ return textBuffer.GetText (begin_iter, end_iter, true);
+ }
+
+ public int BufferLength
+ {
+ get { return textBuffer.EndIter.Offset + 1; }
+ }
+
+ public void Reset()
+ {
+ state = TextIteratorState.Resetted;
+ currentOffset = endOffset;
+ }
+
+ public void Close ()
+ {
+ }
+
+ public override string ToString()
+ {
+ return String.Format("[ForwardTextIterator: currentOffset={0}, endOffset={1}, state={2}]", currentOffset, endOffset, state);
+ }
+ }
+}
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/TextIterator/ITextIterator.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/TextIterator/ITextIterator.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Search/TextIterator/ITextIterator.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -0,0 +1,72 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+
+namespace MonoDevelop.Gui.Search
+{
+ /// <summary>
+ /// This iterator iterates on a text buffer strategy.
+ /// </summary>
+ public interface ITextIterator
+ {
+ /// <value>
+ /// Gets the current char this is the same as
+ /// GetCharRelative(0)
+ /// </value>
+ /// <exception cref="System.InvalidOperationException">
+ /// If this method is called before the first MoveAhead or after
+ /// MoveAhead or after MoveAhead returns false.
+ /// </exception>
+ char Current {
+ get;
+ }
+
+ /// <value>
+ /// The current position=offset of the text iterator cursor
+ /// </value>
+ int Position {
+ get;
+ set;
+ }
+
+ int Line { get; }
+
+ int Column {get; }
+
+ /// <remarks>
+ /// Gets a char relative to the current position (negative values
+ /// will work too).
+ /// </remarks>
+ /// <exception cref="System.InvalidOperationException">
+ /// If this method is called before the first MoveAhead or after
+ /// MoveAhead or after MoveAhead returns false.
+ /// Returns Char.MinValue if the relative position is outside the
+ /// text limits.
+ /// </exception>
+ char GetCharRelative(int offset);
+
+ /// <remarks>
+ /// Moves the iterator position numChars
+ /// </remarks>
+ bool MoveAhead(int numChars);
+
+ string ReadToEnd ();
+
+ /// <remarks>
+ /// Rests the iterator
+ /// </remarks>
+ void Reset();
+
+ void Replace (int length, string pattern);
+
+ void Close ();
+
+ IDocumentInformation DocumentInformation { get; }
+ }
+}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Makefile.am
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Makefile.am 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Makefile.am 2005-06-27 21:13:48 UTC (rev 2607)
@@ -130,8 +130,10 @@
Gui/Dialogs/NewFileDialog.cs \
Gui/Dialogs/ProjectOptionsDialog.cs \
Gui/Dialogs/NewLayoutDialog.cs \
+Gui/Dialogs/ReplaceDialog.cs \
+Gui/Dialogs/ReplaceInFilesDialog.cs \
Gui/ContentInterfaces/ICodeStyleOperations.cs \
-Gui/ContentInterfaces/IBookmarkOperations.cs \
+Gui/ContentInterfaces/IBookmarkBuffer.cs \
Gui/ContentInterfaces/IClipboardHandler.cs \
Gui/ContentInterfaces/IPrintable.cs \
Gui/ContentInterfaces/IPositionable.cs \
@@ -139,6 +141,7 @@
Gui/ContentInterfaces/IEditable.cs \
Gui/ContentInterfaces/IParseInformationListener.cs \
Gui/ContentInterfaces/IParsableContent.cs \
+Gui/ContentInterfaces/ITextBuffer.cs \
Gui/IBaseViewContent.cs \
Gui/IWorkbenchLayout.cs \
Gui/ErrorHandlers/GenericError.cs \
@@ -161,6 +164,32 @@
Gui/HtmlControl/IHTMLElement.cs \
Gui/HtmlControl/IWebBrowser.cs \
Gui/HtmlControl/MozillaControl.cs \
+Gui/Search/DocumentIterator/IDocumentInformation.cs \
+Gui/Search/DocumentIterator/FileDocumentInformation.cs \
+Gui/Search/DocumentIterator/DirectoryDocumentIterator.cs \
+Gui/Search/DocumentIterator/AllOpenDocumentIterator.cs \
+Gui/Search/DocumentIterator/IDocumentIterator.cs \
+Gui/Search/DocumentIterator/ReverseDocumentIterator.cs \
+Gui/Search/DocumentIterator/WholeProjectDocumentIterator.cs \
+Gui/Search/DocumentIterator/CurrentDocumentIterator.cs \
+Gui/Search/SearchStrategy/KMPSearchStrategy.cs \
+Gui/Search/SearchStrategy/ISearchStrategy.cs \
+Gui/Search/SearchStrategy/BruteForceSearchStrategy.cs \
+Gui/Search/SearchStrategy/RegExSearchStrategy.cs \
+Gui/Search/SearchStrategy/WildcardSearchStrategy.cs \
+Gui/Search/SearchReplaceManager.cs \
+Gui/Search/DefaultFind.cs \
+Gui/Search/SearchResult/DefaultSearchResult.cs \
+Gui/Search/SearchResult/ISearchResult.cs \
+Gui/Search/SearchOptions.cs \
+Gui/Search/SearchReplaceInFilesManager.cs \
+Gui/Search/SearchReplaceUtilities.cs \
+Gui/Search/IFind.cs \
+Gui/Search/TextIterator/ITextIterator.cs \
+Gui/Search/TextIterator/ForwardTextFileIterator.cs \
+Gui/Search/TextIterator/ForwardTextIterator.cs \
+Gui/Search/TextIterator/ExtendedStreamReader.cs \
+Gui/Search/ITextBufferStrategy.cs \
Gui/Workbench/Layouts/SdiWorkspaceWindow.cs \
Gui/Workbench/Layouts/SdiWorkspaceLayout.cs \
Gui/Workbench/WorkbenchMemento.cs \
@@ -178,6 +207,7 @@
Commands/AutostartCommands.cs \
Commands/ToolsCommands.cs \
Commands/ViewCommands.cs \
+Commands/SearchCommands.cs \
Services/DebuggerService/IDebuggerService.cs \
Services/DebuggerService/IBreakpoint.cs \
Services/DebuggerService/BreakpointEventHandler.cs \
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/MonoDevelopCore.addin.xml
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/MonoDevelopCore.addin.xml 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/MonoDevelopCore.addin.xml 2005-06-27 21:13:48 UTC (rev 2607)
@@ -440,6 +440,43 @@
<Command id = "MonoDevelop.Commands.DebugCommands.ClearAllBreakpoints"
defaultHandler = "MonoDevelop.Commands.ClearAllBreakpointsHandler"
_label = "Clear All Breakpoints" />
+
+ <!-- SearchCommands -->
+
+ <Command id = "MonoDevelop.Commands.SearchCommands.Find"
+ _label = "_Find..."
+ icon = "Icons.16x16.FindIcon"
+ description = "Find"
+ shortcut = "Control|F" />
+ <Command id = "MonoDevelop.Commands.SearchCommands.FindNext"
+ _label = "Find _Next"
+ icon = "Icons.16x16.FindNextIcon"
+ description = "Find next"
+ shortcut = "F3" />
+ <Command id = "MonoDevelop.Commands.SearchCommands.FindSelection"
+ _label = "Find Selection"
+ description = "Find selection"
+ shortcut = "Control|F3" />
+ <Command id = "MonoDevelop.Commands.SearchCommands.FindPrevious"
+ _label = "Find _Previous"
+ icon = "Icons.16x16.FindPrevIcon"
+ description = "Find previous"
+ shortcut = "Shift|F3" />
+ <Command id = "MonoDevelop.Commands.SearchCommands.Replace"
+ _label = "_Replace..."
+ icon = "Icons.16x16.ReplaceIcon"
+ description = "Replace"
+ shortcut = "Control|H" />
+ <Command id = "MonoDevelop.Commands.SearchCommands.FindInFiles"
+ defaultHandler = "MonoDevelop.Commands.FindInFilesHandler"
+ _label = "F_ind In Files..."
+ icon = "Icons.16x16.FindInFiles"
+ description = "Find in files" />
+ <Command id = "MonoDevelop.Commands.SearchCommands.ReplaceInFiles"
+ defaultHandler = "MonoDevelop.Commands.ReplaceInFilesHandler"
+ _label = "R_eplace In Files..."
+ icon = "Icons.16x16.ReplaceInFiles"
+ description = "Replace in files" />
</Extension>
<Extension path = "/SharpDevelop/Views/ProjectBrowser/ContextMenu/CombineBrowserNode">
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/DefaultParserService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/DefaultParserService.cs 2005-06-27 21:13:18 UTC (rev 2606)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/DefaultParserService.cs 2005-06-27 21:13:48 UTC (rev 2607)
@@ -658,6 +658,9 @@
if (fileName == null || fileName.Length == 0) return;
+ if (GetParser (fileName) == null)
+ return;
+
string text = editable.Text;
if (text == null) return;
@@ -1191,6 +1194,7 @@
}
return null;
}
+
public virtual IParser GetParser(string fileName)
{
// HACK: I'm too lazy to do it 'right'
More information about the Monodevelop-patches-list
mailing list