You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: PythonScript/src/ScintillaPython.cpp
+11-1Lines changed: 11 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,8 @@ BOOST_PYTHON_MODULE(Npp)
35
35
.def("replace", &ScintillaWrapper::replacePlain, boost::python::args("search", "replace"), "Simple search and replace. Replace [search] with [replace]")
36
36
.def("replace", &ScintillaWrapper::replacePlainFlags, boost::python::args("search", "replace", "flags"), "Simple search and replace. Replace 'search' with 'replace' using the given flags.\nFlags are from the re module, and only re.IGNORECASE has an effect. ")
37
37
.def("replace", &ScintillaWrapper::replacePlainFlagsStart, boost::python::args("search", "replace", "flags", "startPosition"), "Simple search and replace. Replace 'search' with 'replace' using the given flags.\nFlags are from the re module, and only re.IGNORECASE has an effect. Starts from the given (binary) startPosition")
38
-
.def("replace", &ScintillaWrapper::replacePlainFlagsStartEnd, boost::python::args("search", "replace", "flags", "startPosition", "endPosition"), "Simple search and replace. Replace 'search' with 'replace' using the given flags.\nFlags are from the re module, and only re.IGNORECASE has an effect. Starts from the given (binary) startPosition")
38
+
.def("replace", &ScintillaWrapper::replacePlainFlagsStartEnd, boost::python::args("search", "replace", "flags", "startPosition", "endPosition"), "Simple search and replace. Replace 'search' with 'replace' using the given flags.\nFlags are from the re module, and only re.IGNORECASE has an effect. Starts from the given (binary) startPosition, and replaces until the endPosition has been reached.")
39
+
.def("replace", &ScintillaWrapper::replacePlainFlagsStartEndMaxCount, boost::python::args("search", "replace", "flags", "startPosition", "endPosition", "maxCount"), "Simple search and replace. Replace 'search' with 'replace' using the given flags.\nFlags are from the re module, and only re.IGNORECASE has an effect. Starts from the given (binary) startPosition, replaces until either the endPosition has been reached, or the maxCount of replacements have been performed")
39
40
.def("rereplace", &ScintillaWrapper::replaceRegex, boost::python::args("searchRegex", "replace"), "Regular expression search and replace. Replaces 'searchRegex' with 'replace'. ^ and $ by default match the starts and end of the document. Use additional flags (re.MULTILINE) to treat ^ and $ per line.\n"
40
41
"The 'replace' parameter can be a python function, that recieves an object similar to a re.Match object.\n"
41
42
"So you can have a function like\n"
@@ -64,6 +65,15 @@ BOOST_PYTHON_MODULE(Npp)
64
65
" return int(m.group(1)) + 1\n\n"
65
66
"And call rereplace('([0-9]+)', myIncrement) and it will increment all the integers.")
66
67
68
+
.def("rereplace", &ScintillaWrapper::replaceRegexFlagsStartEndMaxCount, boost::python::args("searchRegex", "replace", "flags", "startPosition", "endPosition", "maxCount"), "Regular expression search and replace. Replaces 'searchRegex' with 'replace'. Flags are the flags from the python re module (re.IGNORECASE, re.MULTILINE, re.DOTALL), and can be ORed together.\n"
69
+
"startPosition and endPosition are the binary position to start and end the search from.\n"
70
+
"maxCount is the maximum count of replacements to perform.\n"
71
+
"^ and $ by default match the starts and end of the document. Use re.MULTILINE as the flags to treat ^ and $ per line.\n"
72
+
"The 'replace' parameter can be a python function, that recieves an object similar to a re.Match object.\n"
73
+
"So you can have a function like\n"
74
+
" def myIncrement(m):\n"
75
+
" return int(m.group(1)) + 1\n\n"
76
+
"And call rereplace('([0-9]+)', myIncrement) and it will increment all the integers.")
67
77
.def("getWord", &ScintillaWrapper::getWord, "getWord([position[, useOnlyWordChars]])\nGets the word at position. If position is not given or None, the current caret position is used.\nuseOnlyWordChars is a bool that is passed to Scintilla - see Scintilla rules on what is match. If not given or None, it is assumed to be true.")
68
78
.def("getWord", &ScintillaWrapper::getWordNoFlags, "getWord([position[, useOnlyWordChars]])\nGets the word at position. If position is not given or None, the current caret position is used.\nuseOnlyWordChars is a bool that is passed to Scintilla - see Scintilla rules on what is match. If not given or None, it is assumed to be true.")
69
79
.def("getWord", &ScintillaWrapper::getCurrentWord, "getWord([position[, useOnlyWordChars]])\nGets the word at position. If position is not given or None, the current caret position is used.\nuseOnlyWordChars is a bool that is passed to Scintilla - see Scintilla rules on what is match. If not given or None, it is assumed to be true.")
voidScintillaWrapper::replacePlainFlagsStartEnd(boost::python::object searchStr, boost::python::object replaceStr, int flags, int startPosition, int endPosition)
voidScintillaWrapper::replacePlainFlagsStartEndMaxCount(boost::python::object searchStr, boost::python::object replaceStr, int flags, int startPosition, int endPosition, int maxCount)
voidScintillaWrapper::replaceRegexFlagsStartEndMaxCount(boost::python::object searchStr, boost::python::object replaceStr, int flags, int start, int end, int count)
Copy file name to clipboardExpand all lines: PythonScript/src/ScintillaWrapper.h
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -76,10 +76,12 @@ class ScintillaWrapper : public NppPythonScript::PyProducerConsumer<CallbackExec
76
76
voidreplacePlainFlags(boost::python::object searchStr, boost::python::object replaceStr, int flags);
77
77
voidreplacePlainFlagsStart(boost::python::object searchStr, boost::python::object replaceStr, int flags, int startPosition);
78
78
voidreplacePlainFlagsStartEnd(boost::python::object searchStr, boost::python::object replaceStr, int flags, int startPosition, int endPosition);
79
+
voidreplacePlainFlagsStartEndMaxCount(boost::python::object searchStr, boost::python::object replaceStr, int flags, int startPosition, int endPosition, int maxCount);
voidreplaceRegexFlags(boost::python::object searchStr, boost::python::object replaceStr, int flags);
81
82
voidreplaceRegexFlagsStart(boost::python::object searchStr, boost::python::object replaceStr, int flags, int start);
82
83
voidreplaceRegexFlagsStartEnd(boost::python::object searchStr, boost::python::object replaceStr, int flags, int start, int end);
84
+
voidreplaceRegexFlagsStartEndMaxCount(boost::python::object searchStr, boost::python::object replaceStr, int flags, int start, int end, int maxCount);
83
85
84
86
voidreplaceImpl(boost::python::object searchStr, boost::python::object replaceStr, int count, NppPythonScript::python_re_flags flags, int startPosition, int endPosition);
0 commit comments