From 43cb604df7775c765716b328e49c33e61beda987 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 12 Sep 2001 10:41:25 +0000 Subject: [PATCH] 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 --- src/BufferView_pimpl.C | 5 +++-- src/ChangeLog | 13 +++++++++++++ src/lyxfind.C | 4 ++-- src/lyxtext.h | 2 +- src/mathed/ChangeLog | 5 +++++ src/mathed/formulabase.C | 3 ++- src/paragraph.C | 7 ++++--- src/paragraph.h | 3 ++- src/text2.C | 20 ++++++++++++-------- 9 files changed, 44 insertions(+), 18 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 72c5611855..eb645466b8 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -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_) ? } } diff --git a/src/ChangeLog b/src/ChangeLog index cab3736be8..1fc3c5df70 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2001-09-12 Jean-Marc Lasgouttes + + * 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 * lyx_main.C (commandLineHelp): remove version information diff --git a/src/lyxfind.C b/src/lyxfind.C index 7174e5ca64..e5d0f75afb 100644 --- a/src/lyxfind.C +++ b/src/lyxfind.C @@ -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) || diff --git a/src/lyxtext.h b/src/lyxtext.h index 08e22dde7a..8e35b20d51 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -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, diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index ec3bde91da..6e8f8a3688 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,8 @@ +2001-09-12 Jean-Marc Lasgouttes + + * formulabase.C (mathDispatchCreation): pass second argument + 'false' (no label) to selectionAsString + 2001-09-11 André Pönitz * math_atom.[Ch]: new basic item in the MathArray diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 9e950a7942..ab62ccb72c 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -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()) { diff --git a/src/paragraph.C b/src/paragraph.C index 80745161f2..91b7cad91a 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -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) { diff --git a/src/paragraph.h b/src/paragraph.h index 1b54a1df1a..0b4ba210e8 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -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 &, diff --git a/src/text2.C b/src/text2.C index 78be236665..526f671a7b 100644 --- a/src/text2.C +++ b/src/text2.C @@ -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())