From b9b2d298a41b2c7d71877a8febec1dcc7435126a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Sun, 5 Feb 2012 16:07:57 +0000 Subject: [PATCH] [GB.QT4.EXT] * BUG: Editor cursor is ensured to be visible only if the editor has the focus. git-svn-id: svn://localhost/gambas/trunk@4452 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- gb.qt4/src/ext/gdocument.cpp | 1 + gb.qt4/src/ext/gdocument.h | 3 ++- gb.qt4/src/ext/gview.cpp | 12 +++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/gb.qt4/src/ext/gdocument.cpp b/gb.qt4/src/ext/gdocument.cpp index 2a1851eee..c4725c86c 100644 --- a/gb.qt4/src/ext/gdocument.cpp +++ b/gb.qt4/src/ext/gdocument.cpp @@ -53,6 +53,7 @@ GLine::GLine() proc = false; unicode = false; highlight = NULL; + nobreak = false; } GLine::~GLine() diff --git a/gb.qt4/src/ext/gdocument.h b/gb.qt4/src/ext/gdocument.h index a2619d407..64ef45258 100644 --- a/gb.qt4/src/ext/gdocument.h +++ b/gb.qt4/src/ext/gdocument.h @@ -69,7 +69,8 @@ public: unsigned proc : 1; unsigned unicode : 1; unsigned baptized : 1; - unsigned _reserved : 3; + unsigned nobreak : 1; + unsigned _reserved : 2; signed tag : 16; GLine(); diff --git a/gb.qt4/src/ext/gview.cpp b/gb.qt4/src/ext/gview.cpp index 5e143d56f..6a9c6c843 100644 --- a/gb.qt4/src/ext/gview.cpp +++ b/gb.qt4/src/ext/gview.cpp @@ -2223,18 +2223,20 @@ void GEditor::ensureCursorVisible() { int xx, yy; - if (!isUpdatesEnabled()) + if (!isUpdatesEnabled() || !hasFocus()) return; xx = lineWidth(y, x); // + _charWidth['m'] / 2 yy = realToView(y) * _cellh + _cellh / 2; - //qDebug("%p: xx = %d yy = %d vw = %d vh = %d", this, xx, yy, visibleWidth(), visibleHeight()); + //fprintf(stderr, "%p: xx = %d yy = %d vw = %d vh = %d center = %d contentX() = %d", this, xx, yy, visibleWidth(), visibleHeight(), center, contentsX()); if (xx >= visibleWidth() || contentsX() > 0) - ensureVisible(xx, yy, visibleWidth() / 2, center ? (visibleHeight() / 2) : _cellh); - else ensureVisible(xx, yy, margin + 2, center ? (visibleHeight() / 2) : _cellh); + else + ensureVisible(0, yy, margin + 2, center ? (visibleHeight() / 2) : _cellh); + + //fprintf(stderr, " -> %d\n", contentsX()); center = false; _ensureCursorVisibleLater = false; @@ -2266,7 +2268,7 @@ void GEditor::blinkTimerTimeout() void GEditor::focusInEvent(QFocusEvent *e) { startBlink(); - //ensureCursorVisible(); + ensureCursorVisible(); Q3ScrollView::focusInEvent(e); }