From 5cebcf89e045ce4bc98dd8d1ae7dc4b9f86e082f Mon Sep 17 00:00:00 2001
From: Masaki Muranaka <monamour@monaka.org>
Date: Sun, 16 Oct 2011 20:30:19 +0900
Subject: [PATCH] Fix to enable the inline editing with input method engines.

---
 Scribus/scribus/ui/storyeditor.cpp |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/Scribus/scribus/ui/storyeditor.cpp b/Scribus/scribus/ui/storyeditor.cpp
index 4abe806..487545b 100644
--- a/Scribus/scribus/ui/storyeditor.cpp
+++ b/Scribus/scribus/ui/storyeditor.cpp
@@ -282,14 +282,12 @@ void SEditor::setCurrentDocument(ScribusDoc *docc)
 void SEditor::inputMethodEvent(QInputMethodEvent *event)
 {
 	QString uc = event->commitString();
-	if ((!uc.isEmpty()) && ((*doc->AllFonts)[CurrFont].canRender(uc[0])))
+	if (!uc.isEmpty() && (uc[0] == '\n'))
 	{
-		// Should be processed by the handleContentsChange slot
-		// insertCharsInternal(event->commitString());
-		QTextEdit::inputMethodEvent(event);
 		emit SideBarUp(true);
 		emit SideBarUpdate();
 	}
+	QTextEdit::inputMethodEvent(event);
 }
 
 void SEditor::keyPressEvent(QKeyEvent *k)
@@ -451,7 +449,7 @@ void SEditor::handleContentsChange(int position, int charsRemoved, int charsAdde
 		{
 			QTextCursor cursor = textCursor();
 			cursor.setPosition(position);
-			cursor.setPosition(position + charsAdded, QTextCursor::KeepAnchor);
+			cursor.setPosition(position + charsAdded - charsRemoved, QTextCursor::KeepAnchor);
 			QString addedChars = cursor.selectedText();
 			if (addedChars.length() > 0)
 				StyledText.insertChars(position, addedChars, true);
-- 
1.7.3.2

