fix indexing first word in a list layout

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2738 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2001-09-12 10:41:25 +00:00
parent 0e0913d030
commit 43cb604df7
9 changed files with 44 additions and 18 deletions

View File

@ -3071,13 +3071,14 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
string arg = argument;
if (arg.empty()) {
arg = bv_->getLyXText()->selectionAsString(buffer_);
arg = bv_->getLyXText()->selectionAsString(buffer_,
false);
// FIXME
if (arg.size() > 100 || arg.empty()) {
// Get word or selection
bv_->getLyXText()->selectWordWhenUnderCursor(bv_, LyXText::WHOLE_WORD);
arg = bv_->getLyXText()->selectionAsString(buffer_);
arg = bv_->getLyXText()->selectionAsString(buffer_, false);
// FIXME: where is getLyXText()->unselect(bv_) ?
}
}

View File

@ -1,3 +1,16 @@
2001-09-12 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* text2.C (copySelection):
(cutSelection):
* lyxfind.C (LyXReplace):
* BufferView_pimpl.C (Dispatch): pass the correct flag to
LyXText::selectionAsString.
* paragraph.C (asString): add "label" argument to the second form
* text2.C (selectionAsString): add "label" argument and pass it to
Paragraph::asString.
2001-09-10 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* lyx_main.C (commandLineHelp): remove version information

View File

@ -80,10 +80,10 @@ int LyXReplace(BufferView * bv,
string str2;
if (casesens) {
str1 = searchstr;
str2 = text->selectionAsString(bv->buffer());
str2 = text->selectionAsString(bv->buffer(), false);
} else {
str1 = lowercase(searchstr);
str2 = lowercase(text->selectionAsString(bv->buffer()));
str2 = lowercase(text->selectionAsString(bv->buffer(), false));
}
if (str1 != str2) {
if (!LyXFind(bv, searchstr, fw, false, casesens, matchwrd) ||

View File

@ -280,7 +280,7 @@ public:
///
void clearSelection() const;
///
string const selectionAsString(Buffer const *) const;
string const selectionAsString(Buffer const *, bool label) const;
/// select the word we need depending on word_location
void getWord(LyXCursor & from, LyXCursor & to,

View File

@ -1,3 +1,8 @@
2001-09-12 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* formulabase.C (mathDispatchCreation): pass second argument
'false' (no label) to selectionAsString
2001-09-11 André Pönitz <poenitz@gmx.net>
* math_atom.[Ch]: new basic item in the MathArray

View File

@ -732,7 +732,8 @@ void mathDispatchCreation(BufferView * bv, string const & arg, bool display)
// sel = "";
//else
string sel = bv->getLyXText()->selectionAsString(bv->buffer());
string sel = bv->getLyXText()->selectionAsString(bv->buffer(),
false);
InsetFormulaBase * f;
if (sel.empty()) {

View File

@ -1930,12 +1930,13 @@ string const Paragraph::asString(Buffer const * buffer, bool label)
string const Paragraph::asString(Buffer const * buffer,
Paragraph::size_type beg,
Paragraph::size_type end)
Paragraph::size_type beg,
Paragraph::size_type end,
bool label)
{
ostringstream ost;
if (beg == 0 && !params().labelString().empty())
if (beg == 0 && label && !params().labelString().empty())
ost << params().labelString() << ' ';
for (Paragraph::size_type i = beg; i < end; ++i) {

View File

@ -111,7 +111,8 @@ public:
string const asString(Buffer const *, bool label);
///
string const asString(Buffer const *, size_type beg, size_type end);
string const asString(Buffer const *, size_type beg, size_type end,
bool label);
///
void writeFile(Buffer const *, std::ostream &, BufferParams const &,

View File

@ -1013,7 +1013,8 @@ void LyXText::setSelection(BufferView * bview)
}
string const LyXText::selectionAsString(Buffer const * buffer) const
string const LyXText::selectionAsString(Buffer const * buffer,
bool label) const
{
if (!selection.set()) return string();
string result;
@ -1022,7 +1023,8 @@ string const LyXText::selectionAsString(Buffer const * buffer) const
if (selection.start.par() == selection.end.par()) {
result += selection.start.par()->asString(buffer,
selection.start.pos(),
selection.end.pos());
selection.end.pos(),
label);
return result;
}
@ -1031,7 +1033,8 @@ string const LyXText::selectionAsString(Buffer const * buffer) const
// First paragraph in selection
result += selection.start.par()->asString(buffer,
selection.start.pos(),
selection.start.par()->size())
selection.start.par()->size(),
label)
+ "\n\n";
// The paragraphs in between (if any)
@ -1039,13 +1042,14 @@ string const LyXText::selectionAsString(Buffer const * buffer) const
tmpcur.par(tmpcur.par()->next());
while (tmpcur.par() != selection.end.par()) {
result += tmpcur.par()->asString(buffer, 0,
tmpcur.par()->size()) +"\n\n";
tmpcur.par()->size(),
label) + "\n\n";
tmpcur.par(tmpcur.par()->next());
}
// Last paragraph in selection
result += selection.end.par()->asString(buffer, 0,
selection.end.pos());
selection.end.pos(), label);
return result;
}
@ -1153,7 +1157,7 @@ LyXText::getStringToIndex(BufferView * bview)
return string();
}
idxstring = selectionAsString(bview->buffer());
idxstring = selectionAsString(bview->buffer(), false);
// Implicit selections are cleared afterwards
//and cursor is set to the original position.
@ -1723,7 +1727,7 @@ void LyXText::cutSelection(BufferView * bview, bool doclear, bool realcut)
// finished. The solution used currently just works, to make it
// faster we need to be more clever and probably also have more
// calls to stuffClipboard. (Lgb)
bview->stuffClipboard(selectionAsString(bview->buffer()));
bview->stuffClipboard(selectionAsString(bview->buffer(), true));
// This doesn't make sense, if there is no selection
if (!selection.set())
@ -1802,7 +1806,7 @@ void LyXText::copySelection(BufferView * bview)
// finished. The solution used currently just works, to make it
// faster we need to be more clever and probably also have more
// calls to stuffClipboard. (Lgb)
bview->stuffClipboard(selectionAsString(bview->buffer()));
bview->stuffClipboard(selectionAsString(bview->buffer(), true));
// this doesnt make sense, if there is no selection
if (!selection.set())