2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU Library General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 #ifndef _SEARCH_REPLACE_BACKEND_H
18 #define _SEARCH_REPLACE_BACKEND_H
27 #include <libanjuta/interfaces/ianjuta-document-manager.h>
28 #include <libanjuta/interfaces/ianjuta-editor.h>
31 /* PCRE search compiled pattern and other info */
32 typedef struct _PcreInfo
40 /* Search expression options */
41 typedef struct _SearchExpression
56 /* Direction to search (only valid for the current buffer). Note that backward
57 search does not work for regular expressions. */
58 typedef enum _SearchDirection
60 SD_FORWARD
, /* Forward from the cursor */
61 SD_BACKWARD
, /* Backward from the cursor */
62 SD_BEGINNING
/* From the beginning of the buffer */
65 /* Where to search - type */
66 typedef enum _SearchRangeType
68 SR_BUFFER
, /* Current buffer */
69 SR_SELECTION
, /* Selected text only */
70 SR_BLOCK
, /* Current block */
71 SR_FUNCTION
, /* Current function */
72 SR_OPEN_BUFFERS
, /* All open buffers */
73 SR_PROJECT
, /* All project files */
74 SR_FILES
/* A set of patterns specifying which files to search */
78 ** Search variable is a string which is expanded using the properties interface
80 typedef gchar
*SearchVar
;
82 /* Specify files to search in. Note that each GList is a list of strings which
83 can be fixed strings or contain globbing patterns (the type used by ls). */
84 typedef struct _SearchFiles
91 gboolean ignore_hidden_files
;
92 gboolean ignore_hidden_dirs
;
96 /* Search range - used to create search list of files */
97 typedef struct _SearchRange
100 SearchDirection direction
; /* type = SR_BUFFER */
102 SearchVar var
; /* type = SR_VARIABLE */
103 SearchFiles files
; /* type = SR_FILES */
106 /* What to do with the result of the search */
107 typedef enum _SearchAction
109 SA_SELECT
, /* Jump to the next match and select it (current buffer only)*/
110 SA_BOOKMARK
, /* Bookmark all lines containing a match (open buffers only) */
111 SA_HIGHLIGHT
, /* Highlight all matched strings (open buffers only) */
112 SA_FIND_PANE
, /* Show result in find pane */
113 SA_REPLACE
, /* Replace next match with specified string */
114 SA_REPLACEALL
/* Replace all matches with specified string */
117 /* Search master option structure */
118 typedef struct _Search
120 SearchExpression expr
;
124 gint incremental_pos
;
125 gboolean incremental_wrap
;
126 gboolean basic_search
;
129 /* Contains information about replacement */
130 typedef struct _Replace
139 typedef struct _SearchReplace
143 IAnjutaDocumentManager
*docman
;
147 typedef enum _FileBufferType
150 FB_FILE
, /* File loaded from disk */
151 FB_EDITOR
/* Corresponding to a TextEditor structure */
154 typedef struct _FileBuffer
157 /* The following are valid only for files loaded from disk */
158 gchar
*name
; /* Name of the file */
159 gchar
*path
; /* Full path to the file */
160 gchar
*buf
; /* Contents of the file */
161 gint len
; /* Length of the buffer */
162 gint pos
; /* Current position */
163 gint endpos
; /* Restrict action upto this position */
164 gint line
; /* Current line */
165 GList
*lines
; /* List of integers specifying line start positions */
166 /* The following are valid only for files corresponding to a TextEditor */
171 /* A search entry is a file or buffer to search. This can be a file,
172 a buffer or part of a buffer (such as selected text) */
173 typedef enum _SearchEntryType
179 typedef struct _SearchEntry
181 SearchEntryType type
;
184 SearchDirection direction
;
189 typedef struct _MatchInfo
194 GList
*subs
; /* <MatchSubStr *> */
198 // void search_and_replace_backend_init (AnjutaDocman *dm);
200 void function_select (IAnjutaEditor
*te
);
202 GList
*create_search_entries(Search
*s
);
204 FileBuffer
*file_buffer_new_from_te (IAnjutaEditor
*te
);
207 file_buffer_new_from_path(const char *path
, const char *buf
, int len
, int pos
);
210 file_buffer_new_from_path(const char *path
, const char *buf
, int len
, int pos
);
212 gchar
*file_match_line_from_pos(FileBuffer
*fb
, int pos
);
214 MatchInfo
*get_next_match(FileBuffer
*fb
, SearchDirection direction
, SearchExpression
*s
);
216 gchar
*regex_backref(MatchInfo
*mi
, FileBuffer
*fb
);
218 void match_info_free (MatchInfo
*mi
);
220 void file_buffer_free (FileBuffer
*fb
);
222 SearchReplace
*create_search_replace_instance(IAnjutaDocumentManager
*docman
);
224 void clear_pcre(void);
230 #endif /* _SEARCH_REPLACE_H */