VirtualBox

Changeset 38813 in vbox


Ignore:
Timestamp:
Sep 21, 2011 12:28:27 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
74108
Message:

VBoxDbgConsole: Fixed busted text handling wrt selections and cursor positioning.

Location:
trunk/src/VBox/Debugger
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/VBoxDbgConsole.cpp

    r35346 r38813  
    9494
    9595void
    96 VBoxDbgConsoleOutput::appendText(const QString &rStr)
     96VBoxDbgConsoleOutput::appendText(const QString &rStr, bool fClearSelection)
    9797{
    9898    Assert(m_hGUIThread == RTThreadNativeSelf());
     
    102102
    103103    /*
    104      * Insert all in one go and make sure it's visible.
     104     * Insert all in one go and make sure it's visible.
     105     * 
     106     * We need to move the cursor and unselect any selected text before
     107     * inserting anything, otherwise, text will disappear.
    105108     */
    106109    QTextCursor Cursor = textCursor();
    107     if (!Cursor.atEnd())
    108         moveCursor(QTextCursor::End); /* make sure we append the text */
    109     Cursor.insertText(rStr);
    110     ensureCursorVisible();
     110    if (!fClearSelection && Cursor.hasSelection())
     111    {
     112        QTextCursor SavedCursor = Cursor;
     113        Cursor.clearSelection();
     114        Cursor.movePosition(QTextCursor::End);
     115
     116        Cursor.insertText(rStr);
     117
     118        setTextCursor(SavedCursor);
     119    }
     120    else
     121    {
     122        if (Cursor.hasSelection())
     123            Cursor.clearSelection();
     124        if (!Cursor.atEnd())
     125            Cursor.movePosition(QTextCursor::End);
     126
     127        Cursor.insertText(rStr);
     128
     129        setTextCursor(Cursor);
     130        ensureCursorVisible();
     131    }
    111132}
    112133
     
    381402    m_pszInputBuf[m_cbInputBuf++] = '\n';
    382403
    383     m_pOutput->appendText(rCommand + "\n");
     404    m_pOutput->appendText(rCommand + "\n", true /*fClearSelection*/);
    384405    m_pOutput->ensureCursorVisible();
    385406
     
    401422    if (m_cbOutputBuf)
    402423    {
    403         m_pOutput->appendText(QString::fromUtf8((const char *)m_pszOutputBuf, (int)m_cbOutputBuf));
     424        m_pOutput->appendText(QString::fromUtf8((const char *)m_pszOutputBuf, (int)m_cbOutputBuf), false /*fClearSelection*/);
    404425        m_cbOutputBuf = 0;
    405426    }
  • trunk/src/VBox/Debugger/VBoxDbgConsole.h

    r31530 r38813  
    5454     * unless the previous char was a newline ('\n').
    5555     *
    56      * @param   rStr        The text string to append.
    57      */
    58     virtual void appendText(const QString &rStr);
     56     * @param   rStr        The text string to append.
     57     * @param   fClearSelection     Whether to clear selected text before appending.
     58     *                              If @c false the selection and window position
     59     *                              are preserved.
     60     */
     61    virtual void appendText(const QString &rStr, bool fClearSelection);
    5962
    6063protected:
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette