From fd836612cb8540458e0952026c30ade6e0bd56bb Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 30 Jul 2001 10:50:37 +0000 Subject: [PATCH] various fixes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2387 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/POTFILES.in | 2 ++ src/BufferView_pimpl.C | 46 ++++++++---------------- src/ChangeLog | 14 ++++++++ src/bufferlist.h | 2 ++ src/commandtags.h | 3 ++ src/frontends/ChangeLog | 4 +++ src/frontends/Liason.C | 1 + src/frontends/controllers/ChangeLog | 4 +++ src/frontends/controllers/ControlPrint.C | 1 + src/insets/ChangeLog | 6 ++++ src/insets/insetfoot.h | 2 +- src/insets/insetgraphicsParams.C | 1 + src/lyxtext.h | 3 ++ src/text2.C | 33 +++++++++++++++++ 14 files changed, 90 insertions(+), 32 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 0497eaf198..a7c774ba2e 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -9,6 +9,7 @@ src/converter.C src/CutAndPaste.C src/debug.C src/exporter.C +src/ext_l10n.h src/figureForm.C src/figure_form.C src/FontLoader.C @@ -24,6 +25,7 @@ src/frontends/controllers/ControlPreamble.C src/frontends/controllers/ControlPrint.C src/frontends/controllers/ControlSearch.C src/frontends/controllers/ControlSpellchecker.C +src/frontends/controllers/ControlThesaurus.C src/frontends/controllers/helper_funcs.C src/frontends/gnome/FormCitation.C src/frontends/gnome/FormIndex.C diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 79205be07d..8eff02dd2c 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -2984,19 +2984,11 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) LyXText * lt = bv_->getLyXText(); if (argument.empty()) { - // Get word or selection - lt->selectWordWhenUnderCursor(bv_, LyXText::PREVIOUS_WORD); - - if (!lt->selection.set()) { - owner_->message(_("Nothing to index!")); - break; - } - if (lt->selection.start.par() != lt->selection.end.par()) { - owner_->message(_("Cannot index more than one paragraph!")); + string const idxstring(bv_->getLyXText()->getStringToIndex(bv_)); + if (!idxstring.empty()) + p.setContents(idxstring); + else break; - } - - p.setContents(lt->selectionAsString(buffer_)); } else { p.setContents(argument); } @@ -3020,26 +3012,18 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) case LFUN_INDEX_INSERT_LAST: { - LyXText * lt = bv_->getLyXText(); - // Get word or selection - lt->selectWordWhenUnderCursor(bv_, LyXText::PREVIOUS_WORD); - - if (!lt->selection.set()) { - owner_->message(_("Nothing to index!")); - break; - } - if (lt->selection.start.par() != lt->selection.end.par()) { - owner_->message(_("Cannot index more than one paragraph!")); - break; + string const idxstring(bv_->getLyXText()->getStringToIndex(bv_)); + if (!idxstring.empty()) { + owner_->message(_("Word `") + + idxstring + _(("' indexed."))); + InsetCommandParams p("index", idxstring); + InsetIndex * inset = new InsetIndex(p); + + if (!insertInset(inset)) + delete inset; + else + updateInset(inset, true); } - - InsetCommandParams p("index", lt->selectionAsString(buffer_)); - InsetIndex * inset = new InsetIndex(p); - - if (!insertInset(inset)) - delete inset; - else - updateInset(inset, true); } break; diff --git a/src/ChangeLog b/src/ChangeLog index 6eebafc324..138f1c71a0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2001-07-30 Jean-Marc Lasgouttes + + * BufferView_pimpl.C (Dispatch): improve handling of + LFUN_INDEX_INSERT_LAST and LFUN_INDEX_CREATE + + * commandtags.h: #include lyxfont.h here temporarily to avoid + keybinding bug. + + * bufferlist.h: include LString.h here. + +2001-07-27 Jean-Marc Lasgouttes + + * text2.C (getStringToIndex): new method. + 2001-07-29 Asger Alstrup Nielsen * *: Reduced header file dependencies all over. diff --git a/src/bufferlist.h b/src/bufferlist.h index 8d1c31645c..9520605070 100644 --- a/src/bufferlist.h +++ b/src/bufferlist.h @@ -23,6 +23,8 @@ class UpdatableInset; #include #include +#include "LString.h" + /** A class to hold all the buffers in a structure The point of this class is to hide from bufferlist what kind of structure the buffers are stored in. Should be no concern for diff --git a/src/commandtags.h b/src/commandtags.h index 2088b5e589..d9a2380316 100644 --- a/src/commandtags.h +++ b/src/commandtags.h @@ -12,6 +12,9 @@ #include +// this will not be needed anymore when NO_LATEX is the default. +#include "lyxfont.h" + /** These are all the lyxfunctions (as enums). Please add new functions at the end of the enum, right before LFUN_LASTACTION. diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 60c835ebad..9945f3c887 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,7 @@ +2001-07-30 Jean-Marc Lasgouttes + + * Liason.C: #include LAssert.h + 2001-07-24 John Levon * Dialogs.h: add showThesaurus diff --git a/src/frontends/Liason.C b/src/frontends/Liason.C index f916688f2c..f4d0082dfb 100644 --- a/src/frontends/Liason.C +++ b/src/frontends/Liason.C @@ -21,6 +21,7 @@ #include "lyxrc.h" #include "PrinterParams.h" #include "lyx_gui_misc.h" +#include "support/LAssert.h" #include "support/lstrings.h" #include "support/filetools.h" #include "support/path.h" diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 736aa2af66..aea5ce8ed9 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,7 @@ +2001-07-30 Jean-Marc Lasgouttes + + * ControlPrint.C: #include Lassert.h here. + 2001-07-26 Baruch Even * ControlGraphics.C: changed file search string to cover eps, jpeg, gif diff --git a/src/frontends/controllers/ControlPrint.C b/src/frontends/controllers/ControlPrint.C index 77bbf8cdbc..a9fb35a0c3 100644 --- a/src/frontends/controllers/ControlPrint.C +++ b/src/frontends/controllers/ControlPrint.C @@ -31,6 +31,7 @@ #include "lyx_gui_misc.h" // WriteAlert #include "gettext.h" #include "BufferView.h" +#include "support/LAssert.h" using Liason::printBuffer; using Liason::getPrinterParams; diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index e0ce2691a8..cf686e2269 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,9 @@ +2001-07-30 Jean-Marc Lasgouttes + + * insetgraphicsParams.C: #include LOstream.h here. + + * insetfoot.h: remove InsetFoot:: qualifier. + 2001-07-30 Baruch Even * insetgraphics.C (decideOutputImageFormat): when doing postscript output diff --git a/src/insets/insetfoot.h b/src/insets/insetfoot.h index d8e1f8cb4d..87e9067f66 100644 --- a/src/insets/insetfoot.h +++ b/src/insets/insetfoot.h @@ -39,7 +39,7 @@ public: /// string const editMessage() const; /// - void InsetFoot::validate(LaTeXFeatures & features) const; + void validate(LaTeXFeatures & features) const; }; #endif diff --git a/src/insets/insetgraphicsParams.C b/src/insets/insetgraphicsParams.C index 6626aea350..ed5980e72a 100644 --- a/src/insets/insetgraphicsParams.C +++ b/src/insets/insetgraphicsParams.C @@ -19,6 +19,7 @@ #include "support/translator.h" #include "support/filetools.h" #include "support/lyxlib.h" +#include "support/LOstream.h" #include "support/LAssert.h" diff --git a/src/lyxtext.h b/src/lyxtext.h index e446658a6d..6a756e5c80 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -150,6 +150,9 @@ public: /// void toggleFree(BufferView *, LyXFont const &, bool toggleall = false); + + /// + string getStringToIndex(BufferView *); /** recalculates the heights of all previous rows of the specified paragraph. needed, if the last characters font diff --git a/src/text2.C b/src/text2.C index 8898e4cae0..bc975e2d66 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1059,6 +1059,39 @@ void LyXText::toggleFree(BufferView * bview, } +string +LyXText::getStringToIndex(BufferView * bview) +{ + string idxstring; + + // Try implicit word selection + // If there is a change in the language the implicit word selection + // is disabled. + LyXCursor resetCursor = cursor; + bool implicitSelection = selectWordWhenUnderCursor(bview, PREVIOUS_WORD); + + if (!selection.set()) { + bview->owner()->message(_("Nothing to index!")); + return string(); + } + if (selection.start.par() != selection.end.par()) { + bview->owner()->message(_("Cannot index more than one paragraph!")); + return string(); + } + + idxstring = selectionAsString(bview->buffer()); + + // Implicit selections are cleared afterwards + //and cursor is set to the original position. + if (implicitSelection) { + clearSelection(bview); + cursor = resetCursor; + setCursor(bview, cursor.par(), cursor.pos()); + selection.cursor = cursor; + } + return idxstring; +} + Paragraph::size_type LyXText::beginningOfMainBody(Buffer const * buf, Paragraph const * par) const -- 2.39.2