Merge pull request #3916 from techee/symtree_icons
[geany-mirror.git] / src / search.h
blob9f05cae2aa0e408d1bbe3e6ec47a1df26431b197
1 /*
2 * search.h - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2006 The Geany contributors
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 /**
22 * @file search.h
23 * Search (prefs).
24 **/
27 #ifndef GEANY_SEARCH_H
28 #define GEANY_SEARCH_H 1
30 #include <glib.h>
33 G_BEGIN_DECLS
35 typedef enum GeanyFindFlags
37 GEANY_FIND_MATCHCASE = 1 << 0,
38 GEANY_FIND_WHOLEWORD = 1 << 1,
39 GEANY_FIND_WORDSTART = 1 << 2,
40 GEANY_FIND_REGEXP = 1 << 3,
41 GEANY_FIND_MULTILINE = 1 << 4
43 GeanyFindFlags;
45 /** @gironly
46 * Find selection options */
47 typedef enum
49 GEANY_FIND_SEL_CURRENT_WORD,
50 GEANY_FIND_SEL_X,
51 GEANY_FIND_SEL_AGAIN
53 GeanyFindSelOptions;
55 /** Search preferences */
56 typedef struct GeanySearchPrefs
58 gboolean always_wrap; /* don't ask whether to wrap search */
59 gboolean use_current_word; /**< Use current word for default search text */
60 gboolean use_current_file_dir; /* find in files directory to use on showing dialog */
61 gboolean hide_find_dialog; /* hide the find dialog on next or previous */
62 gboolean replace_and_find_by_default; /* enter in replace window performs Replace & Find instead of Replace */
63 GeanyFindSelOptions find_selection_type;
64 gboolean skip_confirmation_for_replace_in_session; /* do *not* ask for confirmation
65 before using "replace in session */
67 GeanySearchPrefs;
69 typedef struct GeanyMatchInfo
71 GeanyFindFlags flags;
72 /* range */
73 gint start, end;
74 /* only valid if (flags & GEANY_FIND_REGEX) */
75 gchar *match_text; /* text actually matched */
76 struct
78 gint start, end;
80 matches[10]; /* sub-patterns */
82 GeanyMatchInfo;
84 void search_show_find_in_files_dialog(const gchar *dir);
87 #ifdef GEANY_PRIVATE
89 struct GeanyDocument; /* document.h includes this header */
90 struct _ScintillaObject;
91 struct Sci_TextToFind;
94 /* the flags given in the search dialog for "find next", also used by the search bar */
95 typedef struct GeanySearchData
97 gchar *text;
98 GeanyFindFlags flags;
99 gboolean backwards;
100 /* set to TRUE when text was set by a search bar callback to keep track of
101 * search bar background colour */
102 gboolean search_bar;
103 /* text as it was entered by user */
104 gchar *original_text;
106 GeanySearchData;
108 extern GeanySearchData search_data;
110 extern GeanySearchPrefs search_prefs;
113 void search_init(void);
115 void search_finalize(void);
117 void search_show_find_dialog(void);
119 void search_show_replace_dialog(void);
121 void search_show_find_in_files_dialog_full(const gchar *text, const gchar *dir);
123 void geany_match_info_free(GeanyMatchInfo *info);
125 gint search_find_prev(struct _ScintillaObject *sci, const gchar *str, GeanyFindFlags flags, GeanyMatchInfo **match_);
127 gint search_find_next(struct _ScintillaObject *sci, const gchar *str, GeanyFindFlags flags, GeanyMatchInfo **match_);
129 gint search_find_text(struct _ScintillaObject *sci, GeanyFindFlags flags, struct Sci_TextToFind *ttf, GeanyMatchInfo **match_);
131 void search_find_again(gboolean change_direction);
133 void search_find_usage(const gchar *search_text, const gchar *original_search_text, GeanyFindFlags flags, gboolean in_session);
135 void search_find_selection(struct GeanyDocument *doc, gboolean search_backwards);
137 gint search_mark_all(struct GeanyDocument *doc, const gchar *search_text, GeanyFindFlags flags);
139 gint search_replace_match(struct _ScintillaObject *sci, const GeanyMatchInfo *match, const gchar *replace_text);
141 guint search_replace_range(struct _ScintillaObject *sci, struct Sci_TextToFind *ttf,
142 GeanyFindFlags flags, const gchar *replace_text);
144 #endif /* GEANY_PRIVATE */
146 G_END_DECLS
148 #endif /* GEANY_SEARCH_H */