diff --git a/Scribus/scribus/pageitem_textframe.cpp b/Scribus/scribus/pageitem_textframe.cpp index c4718ba..4dfdc8a 100644 --- a/Scribus/scribus/pageitem_textframe.cpp +++ b/Scribus/scribus/pageitem_textframe.cpp @@ -3376,7 +3376,7 @@ void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat) return; } //>> - + ScribusView* view = m_Doc->view(); switch (kk) { @@ -3428,14 +3428,31 @@ void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat) unicodeInputString = ""; if (ok) { + UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::ITextFrame,Um::InsertText,"",Um::IDelete)); if (itemText.lengthOfSelection() > 0) deleteSelectedTextFromFrame(); if (conv < 31) conv = 32; + if (UndoManager::undoEnabled()) + { + SimpleState *ss = dynamic_cast(undoManager->getLastUndo()); + if(ss && ss->get("ETEA") == "insert_frametext") + ss->set("TEXT_STR",ss->get("TEXT_STR") + QString(QChar(conv))); + else { + ss = new SimpleState(Um::InsertText,"",Um::ICreate); + ss->set("INSERT_FRAMETEXT", "insert_frametext"); + ss->set("ETEA", QString("insert_frametext")); + ss->set("TEXT_STR", QString(QChar(conv))); + ss->set("START", itemText.cursorPosition()); + undoManager->action(this, ss); + } + } itemText.insertChars(QString(QChar(conv)), true); + trans.commit(); // Tinput = true; m_Doc->scMW()->setTBvals(this); update(); + doc()->changed(); keyRepeat = false; return; } @@ -3739,14 +3756,18 @@ void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat) if (itemText.lengthOfSelection() == 0) itemText.select(itemText.cursorPosition(), 1, true); deleteSelectedTextFromFrame(); + updateLayout(); + if (oldLast != lastInFrame() && NextBox != 0 && NextBox->invalid) + NextBox->updateLayout(); update(); // Tinput = false; - if ((cr == QChar(13)) && (itemText.length() != 0)) - { +// if ((cr == QChar(13)) && (itemText.length() != 0)) +// { // m_Doc->chAbStyle(this, findParagraphStyle(m_Doc, itemText.paragraphStyle(qMax(itemText.cursorPosition()-1,0)))); // Tinput = false; - } +// } m_Doc->scMW()->setTBvals(this); + doc()->changed(); // view->RefreshItem(this); break; case Qt::Key_Backspace: @@ -3793,6 +3814,7 @@ void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat) } m_Doc->scMW()->setTBvals(this); update(); + doc()->changed(); // view->RefreshItem(this); break; default: @@ -3905,12 +3927,12 @@ void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat) updateLayout(); if (oldLast != lastInFrame() && NextBox != 0 && NextBox->invalid) NextBox->updateLayout(); + doc()->changed(); } //check if cursor need to jump to next linked frame if ((itemText.cursorPosition() > lastInFrame() + 1) && (lastInFrame() < (itemText.length() - 2)) && NextBox != 0) { view->Deselect(true); - view->Deselect(true); NextBox->update(); m_Doc->scMW()->selectItemsFromOutlines(NextBox); } @@ -3919,10 +3941,7 @@ void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat) // update(); // view->slotDoCurs(true); if ((kk == Qt::Key_Left) || (kk == Qt::Key_Right) || (kk == Qt::Key_Up) || (kk == Qt::Key_Down)) - { keyRepeat = false; - return; - } } void PageItem_TextFrame::deleteSelectedTextFromFrame() diff --git a/Scribus/scribus/scribus.cpp b/Scribus/scribus/scribus.cpp index 8eb4d5e..a948b01 100644 --- a/Scribus/scribus/scribus.cpp +++ b/Scribus/scribus/scribus.cpp @@ -1346,8 +1346,6 @@ void ScribusMainWindow::keyPressEvent(QKeyEvent *k) QList windows; QMdiSubWindow* w = NULL; int kk = k->key(); - QString uc = k->text(); -// QString cr, Tcha, Twort; if (HaveDoc) { if ((doc->appMode == modeMagnifier) && (kk == Qt::Key_Shift)) @@ -1598,16 +1596,16 @@ void ScribusMainWindow::keyPressEvent(QKeyEvent *k) if (currItem->asImageFrame() && !currItem->locked()) { currItem->handleModeEditKey(k, keyrep); + slotDocCh(false); } //FIXME:av view->oldCp = currItem->CPos; - if (currItem->itemType() == PageItem::TextFrame) + else if (currItem->itemType() == PageItem::TextFrame) { bool kr=keyrep; view->canvasMode()->keyPressEvent(k); //Hack for 1.4.x for stopping the cursor blinking while moving about currItem->handleModeEditKey(k, keyrep); keyrep=kr; } - slotDocCh(false); } } }