[rkward-cvs] SF.net SVN: rkward:[4021] trunk/rkward/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Mon Nov 7 19:26:21 UTC 2011
Revision: 4021
http://rkward.svn.sourceforge.net/rkward/?rev=4021&view=rev
Author: tfry
Date: 2011-11-07 19:26:20 +0000 (Mon, 07 Nov 2011)
Log Message:
-----------
Make an effort to keep scroll position (or at least cursor position) in code display, and default to top / left, instead of bottom scroll.
Modified Paths:
--------------
trunk/rkward/rkward/plugin/rkstandardcomponentgui.cpp
trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
trunk/rkward/rkward/windows/rkcommandeditorwindow.h
Modified: trunk/rkward/rkward/plugin/rkstandardcomponentgui.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponentgui.cpp 2011-11-07 19:00:23 UTC (rev 4020)
+++ trunk/rkward/rkward/plugin/rkstandardcomponentgui.cpp 2011-11-07 19:26:20 UTC (rev 4021)
@@ -256,12 +256,17 @@
void RKStandardComponentGUI::updateCodeNow () {
RK_TRACE (PLUGIN);
+ static bool was_valid = false;
+ if (was_valid) code_display->saveScrollPosition ();
if (!code_property->isValid ()) {
code_display->setText (i18n ("Processing. Please wait"));
RK_DO (qDebug ("code not ready to be displayed: pre %d, cal %d, pri %d", !code_property->preprocess ().isNull (), !code_property->calculate ().isNull (), !code_property->printout ().isNull ()), PLUGIN, DL_DEBUG);
+ was_valid = false;
} else {
code_display->setText ("local({\n" + code_property->preprocess () + code_property->calculate () + code_property->printout () + "})\n");
+ code_display->restoreScrollPosition ();
+ was_valid = true;
}
}
Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp 2011-11-07 19:00:23 UTC (rev 4020)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp 2011-11-07 19:26:20 UTC (rev 4021)
@@ -482,6 +482,23 @@
setFocus();
}
+void RKCommandEditorWindow::restoreScrollPosition () {
+ RK_TRACE (COMMANDEDITOR);
+
+ KTextEditor::Cursor c = saved_scroll_position;
+ c.setLine (qMin (c.line (), m_doc->lines () - 1));
+ if (c.column () >= m_doc->lineLength (c.line ())) c.setColumn (0);
+ m_view->setCursorPosition (c);
+}
+
+void RKCommandEditorWindow::saveScrollPosition () {
+ RK_TRACE (COMMANDEDITOR);
+
+ KTextEditor::Cursor c = m_view->cursorPosition ();
+ if (!c.isValid ()) c = KTextEditor::Cursor::start ();
+ saved_scroll_position = c;
+}
+
void RKCommandEditorWindow::setText (const QString &text) {
RK_TRACE (COMMANDEDITOR);
bool old_rw = m_doc->isReadWrite ();
Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.h 2011-11-07 19:00:23 UTC (rev 4020)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.h 2011-11-07 19:26:20 UTC (rev 4021)
@@ -175,6 +175,10 @@
void insertText (const QString &text);
/** set the current text (clear all previous text, and sets new text) */
void setText (const QString &text);
+/** @see restoreScrollPosition (). Note: Currently this saves/restored the cursor position, not necessarily the scroll position. */
+ void saveScrollPosition ();
+/** @see saveScrollPosition (). Note: Currently this saves/restored the cursor position, not necessarily the scroll position. */
+ void restoreScrollPosition ();
/** copy current selection. Wrapper for use by external classes */
void copy ();
@@ -243,6 +247,7 @@
/** handle any errors during auto-saving */
void autoSaveHandlerJobFinished (RKJobSequence* seq);
private:
+ KTextEditor::Cursor saved_scroll_position;
KTextEditor::Document *m_doc;
KTextEditor::View *m_view;
KTextEditor::CodeCompletionInterface *cc_iface;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list