Merge pull request #1133 from techee/readme_rst
[geany-mirror.git] / src / search.h
blobba4e456f09710052ceb47249e0f066ed654d7c10
1 /*
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.
22 /**
23 * @file search.h
24 * Search (prefs).
25 **/
28 #ifndef GEANY_SEARCH_H
29 #define GEANY_SEARCH_H 1
31 #include <glib.h>
34 G_BEGIN_DECLS
36 typedef enum GeanyFindFlags
38 GEANY_FIND_MATCHCASE = 1 << 0,
39 GEANY_FIND_WHOLEWORD = 1 << 1,
40 GEANY_FIND_WORDSTART = 1 << 2,
41 GEANY_FIND_REGEXP = 1 << 3,
42 GEANY_FIND_MULTILINE = 1 << 4
44 GeanyFindFlags;
46 /** @gironly
47 * Find selection options */
48 typedef enum
50 GEANY_FIND_SEL_CURRENT_WORD,
51 GEANY_FIND_SEL_X,
52 GEANY_FIND_SEL_AGAIN
54 GeanyFindSelOptions;
56 /** Search preferences */
57 typedef struct GeanySearchPrefs
59 gboolean always_wrap; /* don't ask whether to wrap search */
60 gboolean use_current_word; /**< Use current word for default search text */
61 gboolean use_current_file_dir; /* find in files directory to use on showing dialog */
62 gboolean hide_find_dialog; /* hide the find dialog on next or previous */
63 gboolean replace_and_find_by_default; /* enter in replace window performs Replace & Find instead of Replace */
64 GeanyFindSelOptions find_selection_type;
66 GeanySearchPrefs;
68 typedef struct GeanyMatchInfo
70 GeanyFindFlags flags;
71 /* range */
72 gint start, end;
73 /* only valid if (flags & GEANY_FIND_REGEX) */
74 gchar *match_text; /* text actually matched */
75 struct
77 gint start, end;
79 matches[10]; /* sub-patterns */
81 GeanyMatchInfo;
83 void search_show_find_in_files_dialog(const gchar *dir);
86 #ifdef GEANY_PRIVATE
88 struct GeanyDocument; /* document.h includes this header */
89 struct _ScintillaObject;
90 struct Sci_TextToFind;
93 /* the flags given in the search dialog for "find next", also used by the search bar */
94 typedef struct GeanySearchData
96 gchar *text;
97 GeanyFindFlags flags;
98 gboolean backwards;
99 /* set to TRUE when text was set by a search bar callback to keep track of
100 * search bar background colour */
101 gboolean search_bar;
102 /* text as it was entered by user */
103 gchar *original_text;
105 GeanySearchData;
107 extern GeanySearchData search_data;
109 extern GeanySearchPrefs search_prefs;
112 void search_init(void);
114 void search_finalize(void);
116 void search_show_find_dialog(void);
118 void search_show_replace_dialog(void);
120 void search_show_find_in_files_dialog_full(const gchar *text, const gchar *dir);
122 void geany_match_info_free(GeanyMatchInfo *info);
124 gint search_find_prev(struct _ScintillaObject *sci, const gchar *str, GeanyFindFlags flags, GeanyMatchInfo **match_);
126 gint search_find_next(struct _ScintillaObject *sci, const gchar *str, GeanyFindFlags flags, GeanyMatchInfo **match_);
128 gint search_find_text(struct _ScintillaObject *sci, GeanyFindFlags flags, struct Sci_TextToFind *ttf, GeanyMatchInfo **match_);
130 void search_find_again(gboolean change_direction);
132 void search_find_usage(const gchar *search_text, const gchar *original_search_text, GeanyFindFlags flags, gboolean in_session);
134 void search_find_selection(struct GeanyDocument *doc, gboolean search_backwards);
136 gint search_mark_all(struct GeanyDocument *doc, const gchar *search_text, GeanyFindFlags flags);
138 gint search_replace_match(struct _ScintillaObject *sci, const GeanyMatchInfo *match, const gchar *replace_text);
140 guint search_replace_range(struct _ScintillaObject *sci, struct Sci_TextToFind *ttf,
141 GeanyFindFlags flags, const gchar *replace_text);
143 #endif /* GEANY_PRIVATE */
145 G_END_DECLS
147 #endif /* GEANY_SEARCH_H */