+2004-01-14 Alfredo Braunstein <abraunst@lyx.org>
+
+ * text.C (getWord): fix getWord (and thus LFUN_WORDSEL)
+ * text3.C (dispatch): fix LFUN_WORD{RIGHT,LEFT}SEL
2004-01-13 André Pönitz <poenitz@gmx.net>
lyx::pos_type getColumnNearX(ParagraphList::iterator pit,
Row const & row, int & x, bool & boundary) const;
- /// select the word we need depending on word_location
+ /** Find the word under \c from in the relative location
+ * defined by \c word_location.
+ * @param from return here the start of the word
+ * @param to return here the end of the word
+ */
void getWord(CursorSlice & from, CursorSlice & to, lyx::word_location const);
/// just selects the word the cursor is in
void selectWord(lyx::word_location loc);
void LyXText::getWord(CursorSlice & from, CursorSlice & to, word_location const loc)
{
ParagraphList::iterator from_par = getPar(from);
- ParagraphList::iterator to_par = getPar(to);
switch (loc) {
case lyx::WHOLE_WORD_STRICT:
if (from.pos() == 0 || from.pos() == from_par->size()
break;
}
to = from;
+ ParagraphList::iterator to_par = getPar(to);
while (to.pos() < to_par->size()
&& !to_par->isSeparator(to.pos())
&& !to_par->isKomma(to.pos())
if (paragraphs().begin()->rows.empty())
return;
- // get the cursor y position in text
-
+ // now some strict checking
ParagraphList::iterator pit = getPar(par);
Row const & row = *pit->getRow(pos);
pos_type const end = row.endpos();
break;
case LFUN_WORDRIGHTSEL:
+ if (!selection.set())
+ bv->resetAnchor();
if (rtl())
cursorLeftOneWord();
else
break;
case LFUN_WORDLEFTSEL:
+ if (!selection.set())
+ bv->resetAnchor();
if (rtl())
cursorRightOneWord();
else
break;
case LFUN_WORDSEL: {
- CursorSlice cur1 = cursor();
- CursorSlice cur2;
- getWord(cur1, cur2, lyx::WHOLE_WORD);
- setCursor(cur1.par(), cur1.pos());
- clearSelection();
- setCursor(cur2.par(), cur2.pos());
+ selectWord(lyx::WHOLE_WORD);
finishChange(bv, true);
break;
}