}
}
+
+bool Paragraph::find(docstring const & str, bool cs, bool mw,
+ pos_type pos, bool del) const
+{
+ int const strsize = str.length();
+ int i = 0;
+ pos_type const parsize = d->text_.size();
+ for (i = 0; pos + i < parsize; ++i) {
+ if (i >= strsize)
+ break;
+ if (cs && str[i] != d->text_[pos + i])
+ break;
+ if (!cs && uppercase(str[i]) != uppercase(d->text_[pos + i]))
+ break;
+ if (!del && isDeleted(pos + i))
+ break;
+ }
+
+ if (i != strsize)
+ return false;
+
+ // if necessary, check whether string matches word
+ if (mw) {
+ if (pos > 0 && isLetter(pos - 1))
+ return false;
+ if (pos + strsize < parsize
+ && isLetter(pos + strsize))
+ return false;
+ }
+
+ return true;
+}
+
+
char_type Paragraph::getChar(pos_type pos) const
{
return d->text_[pos];
void changeCase(BufferParams const & bparams, pos_type pos,
pos_type right, TextCase action);
+ /// find \param str string inside Paragraph.
+ /// \return true if the specified string is at the specified position
+ /// \param del specifies whether deleted strings in ct mode will be considered
+ bool find(
+ docstring const & str, ///< string to search
+ bool cs, ///<
+ bool mw, ///<
+ pos_type pos, ///< start from here.
+ bool del = true) const;
+
private:
/// Pimpl away stuff
class Private;
// del specifies whether deleted strings in ct mode will be considered
bool operator()(Paragraph const & par, pos_type pos, bool del = true) const
{
- docstring::size_type const size = str.length();
- pos_type i = 0;
- pos_type const parsize = par.size();
- for (i = 0; pos + i < parsize; ++i) {
- if (docstring::size_type(i) >= size)
- break;
- if (cs && str[i] != par.getChar(pos + i))
- break;
- if (!cs && uppercase(str[i]) != uppercase(par.getChar(pos + i)))
- break;
- if (!del && par.isDeleted(pos + i))
- break;
- }
-
- if (size != docstring::size_type(i))
- return false;
-
- // if necessary, check whether string matches word
- if (mw) {
- if (pos > 0 && par.isLetter(pos - 1))
- return false;
- if (pos + pos_type(size) < parsize
- && par.isLetter(pos + size))
- return false;
- }
-
- return true;
+ return par.find(str, cs, mw, pos, del);
}
private: