[rkward-cvs] rkward/rkward/windows rkcommandeditorwindow.cpp,1.13,1.14

Pierre ecoch at users.sourceforge.net
Wed Apr 20 16:33:39 UTC 2005


Update of /cvsroot/rkward/rkward/rkward/windows
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32449/rkward/windows

Modified Files:
	rkcommandeditorwindow.cpp 
Log Message:
Now we should be able to get help on function with a '.' in their name.

Index: rkcommandeditorwindow.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/windows/rkcommandeditorwindow.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** rkcommandeditorwindow.cpp	3 Apr 2005 13:26:19 -0000	1.13
--- rkcommandeditorwindow.cpp	20 Apr 2005 16:33:34 -0000	1.14
***************
*** 36,39 ****
--- 36,41 ----
  #include <qtabwidget.h>
  #include <qfile.h>
+ #include <qstringlist.h>
+ #include <qregexp.h>
  
  #include <klocale.h>
***************
*** 283,289 ****
  void RKCommandEditorWindow::showHelp()
  {
  	chain=0;
  	QString s="help(\"";
! 	s.append(m_view->currentWord());
  	s.append("\", htmlhelp=TRUE)[1]");
  	
--- 285,331 ----
  void RKCommandEditorWindow::showHelp()
  {
+ 	// I know, there must be simpler way to do it...
+ 	// What we do here is that we look for the word under the cursor.
+ 	
+ 
+ 	uint para=0; uint p=0;
+ 	m_view->cursorPosition (&para, &p);
+ 
+ 	QString line=m_view->currentTextLine() + " ";
+ 	if(line.isEmpty() || line.isNull())
+ 		return;
+ 	
+ 	
+ 	// We want to match any valid R name, that is, everything composed of letters, 0-9, '.'s and '_'s..
+ 	QRegExp rx( "[^A-Za-z0-9'.''_']" );
+ 	QRegExp rx2( "[A-Za-z0-9'.''_']" );
+ 	
+ 	QStringList list=QStringList::split(rx,line);
+ 	QStringList list2=QStringList::split(rx2,line);
+ 
+ 	QStringList::Iterator it = list.begin();
+ 	QStringList::Iterator it2 = list2.begin();
+ 	uint pos=0;
+ 	QString result="";
+ 	
+ 	while( it != list.end() &&  it2 != list2.end() ) {
+ 		if (pos<=p) result=*it;
+ 		
+ 		pos=pos+(*it).length();
+ 		pos=pos+(*it2).length();
+ 		
+ 		++it;
+ 		++it2;
+ 	}
+ 
+ 	
+ 	if(result=="" && !line.isEmpty()){
+ 		//There is only one word on this line
+ 		result=line;
+ 	}
+ 		
  	chain=0;
  	QString s="help(\"";
! 	s.append(result);
  	s.append("\", htmlhelp=TRUE)[1]");
  	





More information about the rkward-tracker mailing list