2 * search.h - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2006-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 * Copyright 2006-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #ifndef GEANY_SEARCH_H
29 #define GEANY_SEARCH_H 1
36 struct GeanyDocument
; /* document.h includes this header */
37 struct _ScintillaObject
;
38 struct Sci_TextToFind
;
40 typedef enum GeanyFindFlags
42 GEANY_FIND_MATCHCASE
= 1 << 0,
43 GEANY_FIND_WHOLEWORD
= 1 << 1,
44 GEANY_FIND_WORDSTART
= 1 << 2,
45 GEANY_FIND_REGEXP
= 1 << 3,
46 GEANY_FIND_MULTILINE
= 1 << 4
50 /* the flags given in the search dialog for "find next", also used by the search bar */
51 typedef struct GeanySearchData
56 /* set to TRUE when text was set by a search bar callback to keep track of
57 * search bar background colour */
59 /* text as it was entered by user */
64 extern GeanySearchData search_data
;
67 enum GeanyFindSelOptions
69 GEANY_FIND_SEL_CURRENT_WORD
,
74 /** Search preferences */
75 typedef struct GeanySearchPrefs
77 gboolean always_wrap
; /* don't ask whether to wrap search */
78 gboolean use_current_word
; /**< Use current word for default search text */
79 gboolean use_current_file_dir
; /* find in files directory to use on showing dialog */
80 gboolean hide_find_dialog
; /* hide the find dialog on next or previous */
81 enum GeanyFindSelOptions find_selection_type
;
85 extern GeanySearchPrefs search_prefs
;
88 typedef struct GeanyMatchInfo
93 /* only valid if (flags & GEANY_FIND_REGEX) */
94 gchar
*match_text
; /* text actually matched */
99 matches
[10]; /* sub-patterns */
104 void search_init(void);
106 void search_finalize(void);
108 void search_show_find_dialog(void);
110 void search_show_replace_dialog(void);
112 void search_show_find_in_files_dialog(const gchar
*dir
);
114 void search_show_find_in_files_dialog_full(const gchar
*text
, const gchar
*dir
);
116 void geany_match_info_free(GeanyMatchInfo
*info
);
118 gint
search_find_prev(struct _ScintillaObject
*sci
, const gchar
*str
, GeanyFindFlags flags
, GeanyMatchInfo
**match_
);
120 gint
search_find_next(struct _ScintillaObject
*sci
, const gchar
*str
, GeanyFindFlags flags
, GeanyMatchInfo
**match_
);
122 gint
search_find_text(struct _ScintillaObject
*sci
, GeanyFindFlags flags
, struct Sci_TextToFind
*ttf
, GeanyMatchInfo
**match_
);
124 void search_find_again(gboolean change_direction
);
126 void search_find_usage(const gchar
*search_text
, const gchar
*original_search_text
, GeanyFindFlags flags
, gboolean in_session
);
128 void search_find_selection(struct GeanyDocument
*doc
, gboolean search_backwards
);
130 gint
search_mark_all(struct GeanyDocument
*doc
, const gchar
*search_text
, GeanyFindFlags flags
);
132 gint
search_replace_match(struct _ScintillaObject
*sci
, const GeanyMatchInfo
*match
, const gchar
*replace_text
);
134 guint
search_replace_range(struct _ScintillaObject
*sci
, struct Sci_TextToFind
*ttf
,
135 GeanyFindFlags flags
, const gchar
*replace_text
);
139 #endif /* GEANY_SEARCH_H */