OSDN Git Service

fix move cursor
authorsuma <suma@users.sourceforge.jp>
Thu, 16 Apr 2009 07:33:31 +0000 (16:33 +0900)
committersuma <suma@users.sourceforge.jp>
Thu, 16 Apr 2009 07:33:31 +0000 (16:33 +0900)
src/control/standard/hexview.cpp
src/control/standard/scursor.cpp

index bd5845e..aaeabbe 100644 (file)
@@ -258,7 +258,7 @@ COUNTUP:// Count up
                if (--itr_color->Length <= 0) {
                        // Move next color
                        ++itr_color;
-                       // Make color update
+                       // Change color
                        reset_color = true;
                }
 
@@ -527,27 +527,35 @@ void HexView::keyPressEvent(QKeyEvent *ev)
        bool keepAnchor = ev->modifiers() & Qt::SHIFT ? true : false;
        switch (ev->key()) {
        case Qt::Key_Home:
+               cursor->HighNibble = true;
                cursor->movePosition(0, keepAnchor, false);
                break;
        case Qt::Key_End:
+               cursor->HighNibble = true;
                cursor->movePosition(document->length(), keepAnchor, false);
                break;
        case Qt::Key_Left:
+               cursor->HighNibble = true;
                cursor->moveRelativePosition(-1, keepAnchor, false);
                break;
        case Qt::Key_Right:
+               cursor->HighNibble = true;
                cursor->moveRelativePosition(1, keepAnchor, false);
                break;
        case Qt::Key_Up:
+               cursor->HighNibble = true;
                cursor->moveRelativePosition(-16, keepAnchor, false);
                break;
        case Qt::Key_Down:
+               cursor->HighNibble = true;
                cursor->moveRelativePosition(16, keepAnchor, false);
                break;
        case Qt::Key_PageUp:
+               cursor->HighNibble = true;
                cursor->moveRelativePosition(-16 * 15, keepAnchor, true);
                break;
        case Qt::Key_PageDown:
+               cursor->HighNibble = true;
                cursor->moveRelativePosition(16 * 15, keepAnchor, true);
                break;
        case Qt::Key_Backspace:
@@ -561,6 +569,7 @@ void HexView::keyPressEvent(QKeyEvent *ev)
                break;
        default:
                {
+                       // copy from QtCreator
                        QString text = ev->text();
                        for (int i = 0; i < text.length(); i++) {
                                QChar c = text.at(i);
@@ -576,6 +585,7 @@ void HexView::keyPressEvent(QKeyEvent *ev)
                                if (cursor->HighNibble) {
                                        //changeData(m_cursorPosition, (nibble << 4) + (m_data[m_cursorPosition] & 0x0f), true);
                                        cursor->HighNibble = false;
+                                       cursor->moveRelativePosition(0, false, false);
                                } else {
                                        //changeData(m_cursorPosition, nibble + (m_data[m_cursorPosition] & 0xf0));
                                        cursor->HighNibble = true;
index 9beb1ba..84880f3 100644 (file)
@@ -28,7 +28,7 @@ Cursor::Cursor(Document *Doc, HexView *View)
 void Cursor::movePosition(quint64 pos, bool sel, bool hold_vpos)
 {
        Q_ASSERT(pos <= document->length());
-       // FIXME: replace drawView/drawCaret callings to udpate event
+       // FIXME: replace drawView/drawCaret callings by doc udpate event
        
        const quint64 oldTop = Top;
        const quint64 oldPos = Position;
@@ -79,6 +79,9 @@ void Cursor::movePosition(quint64 pos, bool sel, bool hold_vpos)
        Position = pos;
        PositionAnchor = sel ? PositionAnchor : Position;
 
+       // Reset Nibble
+       //HighNibble = true;
+
        // Redraw view
        if (Top == oldTop) {
                if (!sel && oldSelection) {