public class SearchAndReplace
extends java.lang.Object
There are two main groups of methods in this class:
jEdit.setBooleanProperty("search.hypersearch.toggle",true);
jEdit.setBooleanProperty("search.keepDialog.toggle",true);
If you are not using the dialog to undertake a search or replace, you may
call any of the search and replace methods (including
hyperSearch(View)) without concern for the value of these
properties.| Constructor and Description |
|---|
SearchAndReplace() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
escapeRegexp(java.lang.String str,
boolean multiline)
Escapes characters with special meaning in a regexp.
|
static boolean |
find(View view)
Finds the next occurrence of the search string.
|
static boolean |
find(View view,
Buffer buffer,
int start)
Finds the next instance of the search string in the specified
buffer.
|
static boolean |
find(View view,
Buffer buffer,
int start,
boolean firstTime,
boolean reverse)
Finds the next instance of the search string in the specified
buffer.
|
static boolean |
getAutoWrapAround()
Returns the state of the auto wrap around flag.
|
static boolean |
getBeanShellReplace()
Returns the state of the BeanShell replace flag.
|
static boolean |
getIgnoreCase()
Returns the state of the ignore case flag.
|
static boolean |
getRegexp()
Returns the state of the regular expression flag.
|
static java.lang.String |
getReplaceString()
Returns the current replacement string.
|
static boolean |
getReverseSearch()
Returns the state of the reverse search flag.
|
static SearchFileSet |
getSearchFileSet()
Returns the current search file set.
|
static SearchMatcher |
getSearchMatcher()
Returns the current search string matcher.
|
static java.lang.String |
getSearchString()
Returns the current search string.
|
static boolean |
getSmartCaseReplace()
Returns if the replacement string will assume the same case as
each specific occurrence of the search string.
|
static boolean |
getWholeWord()
Returns the state of the whole word flag.
|
static boolean |
hyperSearch(View view)
Performs a HyperSearch.
|
static boolean |
hyperSearch(View view,
boolean selection)
Performs a HyperSearch.
|
static void |
load()
Loads search and replace state from the properties.
|
static boolean |
replace(View view)
Replaces the current selection with the replacement string.
|
static boolean |
replace(View view,
Buffer buffer,
int start,
int end)
Replaces text in the specified range with the replacement string.
|
static boolean |
replaceAll(View view)
Replaces all occurrences of the search string with the replacement
string.
|
static boolean |
replaceAll(View view,
boolean dontOpenChangedFiles)
Replaces all occurrences of the search string with the replacement
string.
|
static void |
save()
Saves search and replace state to the properties.
|
static void |
setAutoWrapAround(boolean wrap)
Sets the state of the auto wrap around flag.
|
static void |
setBeanShellReplace(boolean beanshell)
Sets the state of the BeanShell replace flag.
|
static void |
setIgnoreCase(boolean ignoreCase)
Sets the ignore case flag.
|
static void |
setRegexp(boolean regexp)
Sets the state of the regular expression flag.
|
static void |
setReplaceString(java.lang.String replace)
Sets the current replacement string.
|
static void |
setReverseSearch(boolean reverse)
Determines whether a reverse search will conducted from the current
position to the beginning of a buffer.
|
static void |
setSearchFileSet(SearchFileSet fileset)
Sets the current search file set.
|
static void |
setSearchMatcher(SearchMatcher matcher)
Sets a custom search string matcher.
|
static void |
setSearchString(java.lang.String search)
Sets the current search string.
|
static void |
setWholeWord(boolean wholeWord)
Sets the whole word flag.
|
public static void setSearchString(java.lang.String search)
search - The new search stringpublic static java.lang.String getSearchString()
public static void setReplaceString(java.lang.String replace)
replace - The new replacement stringpublic static java.lang.String getReplaceString()
public static void setWholeWord(boolean wholeWord)
wholeWord - True if only whole words should be searched,
false otherwisepublic static void setIgnoreCase(boolean ignoreCase)
ignoreCase - True if searches should be case insensitive,
false otherwisepublic static boolean getWholeWord()
public static boolean getIgnoreCase()
public static void setRegexp(boolean regexp)
regexp - True if regular expression searches should be
performedpublic static boolean getRegexp()
public static void setReverseSearch(boolean reverse)
reverse - True if searches should go backwards,
false otherwisepublic static boolean getReverseSearch()
public static void setBeanShellReplace(boolean beanshell)
beanshell - True if the replace string is a BeanShell expressionpublic static boolean getBeanShellReplace()
public static void setAutoWrapAround(boolean wrap)
wrap - If true, the 'continue search from start' dialog
will not be displayedpublic static boolean getAutoWrapAround()
public static void setSearchMatcher(SearchMatcher matcher)
setSearchString(String), setWholeWord(boolean),
setIgnoreCase(boolean), or setRegexp(boolean)
will reset the matcher to the default.public static SearchMatcher getSearchMatcher() throws java.lang.Exception
java.lang.IllegalArgumentException - if regular expression search
is enabled, the search string or replacement string is invalidjava.lang.Exceptionpublic static void setSearchFileSet(SearchFileSet fileset)
fileset - The file set to perform searches inAllBufferSet,
CurrentBufferSet,
DirectoryListSetpublic static SearchFileSet getSearchFileSet()
public static boolean getSmartCaseReplace()
public static boolean hyperSearch(View view)
view - The viewpublic static boolean hyperSearch(View view, boolean selection)
view - The viewselection - If true, will only search in the current selection.
Note that the file set must be the current buffer file set for this
to work.public static boolean find(View view)
view - The viewpublic static boolean find(View view, Buffer buffer, int start) throws java.lang.Exception
view - The viewbuffer - The bufferstart - Location where to start the searchjava.lang.Exceptionpublic static boolean find(View view, Buffer buffer, int start, boolean firstTime, boolean reverse) throws java.lang.Exception
view - The viewbuffer - The bufferstart - Location where to start the searchfirstTime - See SearchMatcher.nextMatch(CharSequence,boolean,boolean,boolean,boolean).java.lang.Exceptionpublic static boolean replace(View view)
view - The viewpublic static boolean replace(View view, Buffer buffer, int start, int end)
view - The viewbuffer - The bufferstart - The start offsetend - The end offsetpublic static boolean replaceAll(View view)
view - The viewpublic static boolean replaceAll(View view, boolean dontOpenChangedFiles)
view - The viewdontOpenChangedFiles - Whether to open changed files or to autosave them quietlypublic static java.lang.String escapeRegexp(java.lang.String str,
boolean multiline)
str - the string to escapemultiline - Should \n be escaped?public static void load()
public static void save()