v...@lyx.org schreef:
Author: vfr
Date: Wed Apr 15 18:42:38 2009
New Revision: 29245
URL: http://www.lyx.org/trac/changeset/29245
Log:
Fix bug 5894: Inserting tabs with inline selections.
Modified:
lyx-devel/trunk/src/insets/InsetListings.cpp
Modified: lyx-devel/trunk/src/insets/InsetListings.cpp
==============================================================================
--- lyx-devel/trunk/src/insets/InsetListings.cpp Wed Apr 15 09:28:37
2009 (r29244)
+++ lyx-devel/trunk/src/insets/InsetListings.cpp Wed Apr 15 18:42:38
2009 (r29245)
@@ -18,6 +18,7 @@
#include "BufferParams.h"
#include "Counters.h"
#include "Cursor.h"
+#include "CutAndPaste.h"
#include "DispatchResult.h"
#include "Encoding.h"
#include "FuncRequest.h"
@@ -288,13 +289,17 @@
InsetListings::string2params(to_utf8(cmd.argument()), params());
break;
}
+
case LFUN_INSET_DIALOG_UPDATE:
cur.bv().updateDialog("listings", params2string(params()));
break;
- case LFUN_TAB_INSERT:
- if (cur.selection()) {
- // If there is a selection, a tab is inserted at the
- // beginning of each paragraph.
+
+ case LFUN_TAB_INSERT: {
+ bool const multi_par_selection = cur.selection() &&
+ cur.selBegin().pit() != cur.selEnd().pit();
+ if (multi_par_selection) {
+ // If there is a multi-paragraph selection, a tab is
inserted
+ // at the beginning of each paragraph.
cur.recordUndoSelection();
pit_type const pit_end = cur.selEnd().pit();
for (pit_type pit = cur.selBegin().pit(); pit <=
pit_end; pit++) {
@@ -312,10 +317,14 @@
// Maybe we shouldn't allow tabs within a line, because
they
// are not (yet) aligned as one might do expect.
cur.recordUndo();
+ if (cur.selection())
+ cap::cutSelection(cur, false, false);
cur.insert(from_ascii("\t"));
cur.finishUndo();
}
break;
+ }
+
case LFUN_TAB_DELETE:
if (cur.selection()) {
// If there is a selection, a tab (if present) is
removed from
and
Author: vfr
Date: Wed Apr 15 19:00:43 2009
New Revision: 29246
URL: http://www.lyx.org/trac/changeset/29246
Log:
InsetListings.cpp: simplify.
Modified:
lyx-devel/trunk/src/insets/InsetListings.cpp
Modified: lyx-devel/trunk/src/insets/InsetListings.cpp
==============================================================================
--- lyx-devel/trunk/src/insets/InsetListings.cpp Wed Apr 15 18:42:38
2009 (r29245)
+++ lyx-devel/trunk/src/insets/InsetListings.cpp Wed Apr 15 19:00:43
2009 (r29246)
@@ -316,11 +316,8 @@
} else {
// Maybe we shouldn't allow tabs within a line, because
they
// are not (yet) aligned as one might do expect.
- cur.recordUndo();
- if (cur.selection())
- cap::cutSelection(cur, false, false);
- cur.insert(from_ascii("\t"));
- cur.finishUndo();
+ FuncRequest cmd(LFUN_SELF_INSERT, from_ascii("\t"));
+ dispatch(cur, cmd);
}
break;
}
To branch ?
Vincent