[rkward-cvs] SF.net SVN: rkward:[4008] trunk/rkward/rkward/windows

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Oct 28 15:34:49 UTC 2011


Revision: 4008
          http://rkward.svn.sourceforge.net/rkward/?rev=4008&view=rev
Author:   tfry
Date:     2011-10-28 15:34:49 +0000 (Fri, 28 Oct 2011)
Log Message:
-----------
Make an effort to locate current source line, even if no srcref is available.

Modified Paths:
--------------
    trunk/rkward/rkward/windows/rkcallstackviewer.cpp
    trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
    trunk/rkward/rkward/windows/rkcommandeditorwindow.h

Modified: trunk/rkward/rkward/windows/rkcallstackviewer.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcallstackviewer.cpp	2011-10-28 14:10:59 UTC (rev 4007)
+++ trunk/rkward/rkward/windows/rkcallstackviewer.cpp	2011-10-28 15:34:49 UTC (rev 4008)
@@ -145,12 +145,18 @@
 									Qt::escape (RKDebugHandler::instance ()->calls ().value (frame_number)),
 									Qt::escape (RKDebugHandler::instance ()->environments ().value (frame_number)),
 									Qt::escape (RKDebugHandler::instance ()->locals ().value (frame_number).split ('\n').join (", "))));
-	frame_source->setText (RKDebugHandler::instance ()->functions ().value (frame_number));
+	frame_source->setText (RKDebugHandler::instance ()->functions ().value (frame_number) + "\n");
 	int line = RKDebugHandler::instance ()->relativeSourceLines ().value (frame_number, 0);
-	frame_source->clearLineHighlights ();
-	if (line > 0) frame_source->highlightLine (line -1);
-	else {
-		// TODO: some clever heuristics
+	if (line > 0) frame_source->highlightLine (line - 1);
+	else if (frame_number < RKDebugHandler::instance ()->calls ().size () - 1) {
+		// no (valid) source reference available? Make an effort to locate (candidate line(s) for) the call
+		QStringList lines = RKDebugHandler::instance ()->functions ().value (frame_number).split ('\n');
+		QString call = RKDebugHandler::instance ()->calls ().value (frame_number + 1);
+		call = call.left (call.indexOf ('(')).trimmed ();
+		QRegExp call_exp (QRegExp::escape (call) + "\\s*\\(");
+		for (int i = lines.size () - 1; i >= 0; --i) {
+			if (lines.at (i).contains (call_exp)) frame_source->highlightLine (i);
+		}
 	}
 }
 

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2011-10-28 14:10:59 UTC (rev 4007)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2011-10-28 15:34:49 UTC (rev 4008)
@@ -487,6 +487,8 @@
 	bool old_rw = m_doc->isReadWrite ();
 	if (!old_rw) m_doc->setReadWrite (true);
 	m_doc->setText (text);
+	KTextEditor::MarkInterface *markiface = qobject_cast<KTextEditor::MarkInterface*> (m_doc);
+	if (markiface) markiface->clearMarks ();
 	if (!old_rw) m_doc->setReadWrite (false);
 }
 
@@ -500,22 +502,11 @@
 	}
 	bool old_rw = m_doc->isReadWrite ();
 	if (!old_rw) m_doc->setReadWrite (true);
-	markiface->addMark (linenum, KTextEditor::MarkInterface::BreakpointActive);
+	markiface->addMark (linenum, KTextEditor::MarkInterface::Execution);
+	m_view->setCursorPosition (KTextEditor::Cursor (linenum, 0));
 	if (!old_rw) m_doc->setReadWrite (false);
 }
 
-void RKCommandEditorWindow::clearLineHighlights() {
-	KTextEditor::MarkInterface *markiface = qobject_cast<KTextEditor::MarkInterface*> (m_doc);
-	if (!markiface) {
-		RK_ASSERT (markiface);
-		return;
-	}
-	bool old_rw = m_doc->isReadWrite ();
-	if (!old_rw) m_doc->setReadWrite (true);
-	markiface->clearMarks ();
-	if (!old_rw) m_doc->setReadWrite (false);
-}
-
 void RKCommandEditorWindow::updateCaption (KTextEditor::Document*) {
 	RK_TRACE (COMMANDEDITOR);
 	QString name = url ().fileName ();

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2011-10-28 14:10:59 UTC (rev 4007)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2011-10-28 15:34:49 UTC (rev 4008)
@@ -190,7 +190,6 @@
 	QString currentCompletionWord () const;
 
 	void highlightLine (int linenum);
-	void clearLineHighlights ();
 public slots:
 /** update Tab caption according to the current url. Display the filename-component of the URL, or - if not available - a more elaborate description of the url. Also appends a "[modified]" if appropriate */
 	void updateCaption (KTextEditor::Document* = 0);

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