mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
fix backwards search (bug 1666)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8988 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3f589b3511
commit
09b67226eb
@ -357,11 +357,8 @@ void BufferView::putSelectionAt(DocIterator const & cur,
|
||||
|
||||
if (length) {
|
||||
if (backwards) {
|
||||
cursor().pos() += length;
|
||||
cursor().setSelection(cursor(), -length);
|
||||
DocIterator const it = cursor();
|
||||
cursor().setCursor(cursor().anchor_);
|
||||
cursor().selection() = true;
|
||||
cursor().anchor_ = it;
|
||||
} else
|
||||
cursor().setSelection(cursor(), length);
|
||||
}
|
||||
|
@ -162,7 +162,11 @@ public:
|
||||
LyXText * text() const;
|
||||
///
|
||||
void setCursor(ParIterator const & par, lyx::pos_type pos);
|
||||
///
|
||||
/* Sets the selection. When \c backwards == false, set anchor
|
||||
* to \c cur and cursor to \c cur + \c length. When \c
|
||||
* backwards == true, set anchor to \c cur and cursor to \c
|
||||
* cur + \c length.
|
||||
*/
|
||||
void putSelectionAt(DocIterator const & cur,
|
||||
int length, bool backwards);
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
2004-09-16 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
Fix bug #1666
|
||||
|
||||
* BufferView.C (putSelectionAt): change the semantics when
|
||||
backwards == true: now, this just swaps cursor and anchor wrt the
|
||||
forward case
|
||||
|
||||
* BufferView.h (putSelectionAt): add some documentation
|
||||
|
||||
* lyxfind.C (findBackwards): rewrite using while(). In particular,
|
||||
make sure backwardChar is done at least once (to avoid getting
|
||||
stuck)
|
||||
(findNextChange): use putSelectionAt in the forward direction
|
||||
(operator()): use Paragraph::isWord
|
||||
|
||||
2004-09-16 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* Spacing.C (set): c_str fix
|
||||
|
@ -1,3 +1,8 @@
|
||||
2004-09-14 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* ControlSpellchecker.C (check): do not set the selection
|
||||
backwards, but translate it to the left instead.
|
||||
|
||||
2004-09-15 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* ControlInclude.C (load): open nonlyx files via formats.edit()
|
||||
|
@ -213,7 +213,8 @@ void ControlSpellchecker::check()
|
||||
}
|
||||
|
||||
int const size = getWord().size();
|
||||
kernel().bufferview()->putSelectionAt(cur, size, true);
|
||||
cur.pos() -= size;
|
||||
kernel().bufferview()->putSelectionAt(cur, size, false);
|
||||
|
||||
// set suggestions
|
||||
if (res != SpellBase::OK && res != SpellBase::IGNORE) {
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "frontends/Alert.h"
|
||||
#include "frontends/LyXView.h"
|
||||
|
||||
#include "support/textutils.h"
|
||||
#include "support/tostr.h"
|
||||
|
||||
#include <sstream>
|
||||
@ -86,10 +85,10 @@ public:
|
||||
|
||||
// if necessary, check whether string matches word
|
||||
if (mw) {
|
||||
if (pos > 0 && IsLetterCharOrDigit(par.getChar(pos - 1)))
|
||||
if (pos > 0 && par.isWord(pos - 1))
|
||||
return false;
|
||||
if (pos + lyx::pos_type(size) < parsize
|
||||
&& IsLetterCharOrDigit(par.getChar(pos + size)));
|
||||
&& par.isWord(pos + size));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -117,9 +116,11 @@ bool findForward(DocIterator & cur, MatchString const & match)
|
||||
|
||||
bool findBackwards(DocIterator & cur, MatchString const & match)
|
||||
{
|
||||
for (; cur; cur.backwardChar())
|
||||
while (cur) {
|
||||
cur.backwardChar();
|
||||
if (cur.inTexted() && match(cur.paragraph(), cur.pos()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -344,10 +345,10 @@ bool findNextChange(BufferView * bv)
|
||||
return false;
|
||||
|
||||
Paragraph const & par = cur.paragraph();
|
||||
pos_type pos = cur.pos();
|
||||
const pos_type pos = cur.pos();
|
||||
|
||||
Change orig_change = par.lookupChangeFull(pos);
|
||||
pos_type parsize = par.size();
|
||||
const pos_type parsize = par.size();
|
||||
pos_type end = pos;
|
||||
|
||||
for (; end != parsize; ++end) {
|
||||
@ -361,7 +362,8 @@ bool findNextChange(BufferView * bv)
|
||||
}
|
||||
}
|
||||
pos_type length = end - pos;
|
||||
bv->putSelectionAt(cur, length, true);
|
||||
bv->putSelectionAt(cur, length, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
2004-09-10 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* textutils.h (IsLetterCharOrDigit): remove
|
||||
|
||||
2004-09-10 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||
|
||||
* filetools.C (LibScriptSearch): quote the path of the script, in
|
||||
|
@ -95,11 +95,4 @@ bool IsDigit(unsigned char ch)
|
||||
}
|
||||
|
||||
|
||||
/// return true if the char is alphanumeric
|
||||
inline
|
||||
bool IsLetterCharOrDigit(unsigned char ch)
|
||||
{
|
||||
return IsLetterChar(ch) || IsDigit(ch);
|
||||
}
|
||||
|
||||
#endif // TEXTUTILS_H
|
||||
|
Loading…
Reference in New Issue
Block a user