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
25 #include <libanjuta/interfaces/ianjuta-document-manager.h>
26 #include <libanjuta/interfaces/ianjuta-editor.h>
28 /* Search expression options */
29 typedef struct _SearchExpression
44 /* Direction to search (only valid for the current buffer). Note that backward
45 search does not work for regular expressions. */
46 typedef enum _SearchDirection
48 SD_FORWARD
, /* Forward from the cursor */
49 SD_BACKWARD
, /* Backward from the cursor */
50 SD_BEGINNING
/* From the beginning of the buffer */
53 /* Where to search - type */
54 typedef enum _SearchRangeType
56 SR_BUFFER
, /* Current buffer */
57 SR_SELECTION
, /* Selected text only */
58 SR_BLOCK
, /* Current block */
59 SR_FUNCTION
, /* Current function */
60 SR_OPEN_BUFFERS
, /* All open buffers */
61 SR_PROJECT
, /* All project files */
62 SR_FILES
/* A set of patterns specifying which files to search */
66 ** Search variable is a string which is expanded using the properties interface
68 typedef gchar
*SearchVar
;
70 /* Specify files to search in. Note that each GList is a list of strings which
71 can be fixed strings or contain globbing patterns (the type used by ls). */
72 typedef struct _SearchFiles
79 gboolean ignore_hidden_files
;
80 gboolean ignore_hidden_dirs
;
84 /* Search range - used to create search list of files */
85 typedef struct _SearchRange
88 SearchDirection direction
; /* type = SR_BUFFER */
90 SearchVar var
; /* type = SR_VARIABLE */
91 SearchFiles files
; /* type = SR_FILES */
94 /* What to do with the result of the search */
95 typedef enum _SearchAction
97 SA_SELECT
, /* Jump to the next match and select it (current buffer only)*/
98 SA_BOOKMARK
, /* Bookmark all lines containing a match (open buffers only) */
99 SA_HIGHLIGHT
, /* Highlight all matched strings (open buffers only) */
100 SA_FIND_PANE
, /* Show result in find pane */
101 SA_REPLACE
, /* Replace next match with specified string */
102 SA_REPLACEALL
/* Replace all matches with specified string */
105 /* Search master option structure */
106 typedef struct _Search
108 SearchExpression expr
;
112 gint incremental_pos
;
113 gboolean incremental_wrap
;
114 gboolean basic_search
;
117 /* Contains information about replacement */
118 typedef struct _Replace
127 typedef struct _SearchReplace
131 IAnjutaDocumentManager
*docman
;
135 typedef enum _FileBufferType
138 FB_FILE
, /* File loaded from disk */
139 FB_EDITOR
/* Corresponding to a TextEditor structure */
142 typedef struct _FileBuffer
145 /* The following are valid only for files loaded from disk */
146 gchar
*name
; /* Name of the file */
147 gchar
*path
; /* Full path to the file */
148 gchar
*uri
; /* URI to the file */
149 gchar
*buf
; /* Contents of the file */
150 gint len
; /* Length of the buffer */
151 gint pos
; /* Current position */
152 gint endpos
; /* Restrict action upto this position */
153 gint line
; /* Current line */
154 GList
*lines
; /* List of integers specifying line start positions */
155 /* The following are valid only for files corresponding to a TextEditor */
160 /* A search entry is a file or buffer to search. This can be a file,
161 a buffer or part of a buffer (such as selected text) */
162 typedef enum _SearchEntryType
168 typedef struct _SearchEntry
170 SearchEntryType type
;
173 SearchDirection direction
;
178 typedef struct _MatchInfo
183 GList
*subs
; /* <MatchSubStr *> */
187 // void search_and_replace_backend_init (AnjutaDocman *dm);
189 void function_select (IAnjutaEditor
*te
);
191 GList
*create_search_entries(Search
*s
);
193 FileBuffer
*file_buffer_new_from_te (IAnjutaEditor
*te
);
196 file_buffer_new_from_path(const char *path
, const char *buf
, int len
, int pos
);
199 file_buffer_new_from_path(const char *path
, const char *buf
, int len
, int pos
);
201 gchar
*file_match_line_from_pos(FileBuffer
*fb
, int pos
);
203 MatchInfo
*get_next_match(FileBuffer
*fb
, SearchDirection direction
, SearchExpression
*s
);
205 gchar
*regex_backref(MatchInfo
*mi
, FileBuffer
*fb
);
207 void match_info_free (MatchInfo
*mi
);
209 void file_buffer_free (FileBuffer
*fb
);
211 SearchReplace
*create_search_replace_instance(IAnjutaDocumentManager
*docman
);
217 #endif /* _SEARCH_REPLACE_H */