From c7fb290bfd7c5039ba8dc2ecdf209b10bcea5fc8 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Fri, 31 Jan 2003 13:50:21 +0000 Subject: [PATCH] Fix Helge's index bugs. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6010 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 8 ++++++++ src/factory.C | 15 ++++++++++----- src/frontends/qt2/ChangeLog | 5 +++++ src/frontends/qt2/Dialogs2.C | 2 +- src/frontends/xforms/ChangeLog | 5 +++++ src/frontends/xforms/Dialogs2.C | 2 +- src/text2.C | 28 ++++++++++++---------------- 7 files changed, 42 insertions(+), 23 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 571c7826e0..1c0357744d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2003-01-30 Angus Leeming + + * factory.C (createInset): create an InsetCommandParam of type "index" + and use it to 'do the right thing'. + + * text2.C (getStringToIndex): ensure that cursor position is always + reset to the reset_cursor position. + 2003-01-28 Jean-Marc Lasgouttes * lyxfunc.C (getStatus): "buffer-export custom" should never be diff --git a/src/factory.C b/src/factory.C index 9fac9fc925..3509bc8150 100644 --- a/src/factory.C +++ b/src/factory.C @@ -93,11 +93,16 @@ Inset * createInset(FuncRequest const & cmd) return 0; case LFUN_INDEX_INSERT: { - string entry = cmd.argument; - if (entry.empty()) - entry = bv->getLyXText()->getStringToIndex(bv); - if (!entry.empty()) - return new InsetIndex(InsetCommandParams("index", entry)); + string const entry = cmd.argument.empty() ? + "index" : cmd.argument; + InsetCommandParams icp; + icp.setFromString(entry); + + if (icp.getContents().empty()) + icp.setContents(bv->getLyXText()->getStringToIndex(bv)); + if (!icp.getContents().empty()) + return new InsetIndex(icp); + bv->owner()->getDialogs().createIndex(); return 0; } diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 0fe472beb5..713272d319 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,8 @@ +2003-01-30 Angus Leeming + + * Dialogs2.C (createIndex): enable ControlCommand to create an + InsetCommandParam of type "index", not null. + 2003-01-26 Michael Schmitt * ui/QThesaurusDialogBase.ui: add colons to labels. diff --git a/src/frontends/qt2/Dialogs2.C b/src/frontends/qt2/Dialogs2.C index 975f018015..c0a1ab536a 100644 --- a/src/frontends/qt2/Dialogs2.C +++ b/src/frontends/qt2/Dialogs2.C @@ -127,7 +127,7 @@ void Dialogs::showIndex(InsetCommand * ic) void Dialogs::createIndex() { - pimpl_->index.controller().createInset(string()); + pimpl_->index.controller().createInset("index"); } diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 30dfdd842b..955800bf2e 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2003-01-30 Angus Leeming + + * Dialogs2.C (createIndex): enable ControlCommand to create an + InsetCommandParam of type "index", not null. + 2003-01-26 Michael Schmitt * forms/form_thesaurus.fd: add colons to labels. Shrink dialog. diff --git a/src/frontends/xforms/Dialogs2.C b/src/frontends/xforms/Dialogs2.C index 37653f557c..0a7f9f4f58 100644 --- a/src/frontends/xforms/Dialogs2.C +++ b/src/frontends/xforms/Dialogs2.C @@ -129,7 +129,7 @@ void Dialogs::showIndex(InsetCommand * ic) void Dialogs::createIndex() { - pimpl_->index.controller().createInset(string()); + pimpl_->index.controller().createInset("index"); } diff --git a/src/text2.C b/src/text2.C index 00b4dbbc4b..a4592c79ce 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1039,33 +1039,29 @@ 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 const reset_cursor = cursor; bool const implicitSelection = selectWordWhenUnderCursor(bview, PREVIOUS_WORD); - if (!selection.set()) { + string idxstring; + if (!selection.set()) bview->owner()->message(_("Nothing to index!")); - return string(); - } - if (selection.start.par() != selection.end.par()) { + else if (selection.start.par() != selection.end.par()) bview->owner()->message(_("Cannot index more than one paragraph!")); - return string(); - } + else + idxstring = selectionAsString(bview->buffer(), false); - idxstring = selectionAsString(bview->buffer(), false); + // Reset cursors to their original position. + cursor = reset_cursor; + setCursor(bview, cursor.par(), cursor.pos()); + selection.cursor = cursor; - // Implicit selections are cleared afterwards - //and cursor is set to the original position. - if (implicitSelection) { + // Clear the implicit selection. + if (implicitSelection) clearSelection(); - cursor = reset_cursor; - setCursor(bview, cursor.par(), cursor.pos()); - selection.cursor = cursor; - } + return idxstring; } -- 2.39.2