[rkward-cvs] rkward/rkward rkconsolepart.rc,NONE,1.1 Makefile.am,1.57,1.58 khelpdlg.cpp,1.9,1.10 khelpdlg.h,1.6,1.7 rkconsole.cpp,1.9,1.10 rkconsole.h,1.7,1.8 rkglobals.cpp,1.7,1.8 rkglobals.h,1.6,1.7 rkward.cpp,1.98,1.99 rkward.h,1.47,1.48

Thomas Friedrichsmeier tfry at users.sourceforge.net
Sat Sep 17 19:23:54 UTC 2005


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

Modified Files:
	Makefile.am khelpdlg.cpp khelpdlg.h rkconsole.cpp rkconsole.h 
	rkglobals.cpp rkglobals.h rkward.cpp rkward.h 
Added Files:
	rkconsolepart.rc 
Log Message:
added part for RKConsole. Provide context help for console, too.

Index: rkconsole.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkconsole.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** rkconsole.cpp	5 May 2005 20:20:49 -0000	1.9
--- rkconsole.cpp	17 Sep 2005 19:23:52 -0000	1.10
***************
*** 27,40 ****
   
  #include <klocale.h>
   
  #include "rkconsole.h"
  
  #include "rkglobals.h"
  #include "rbackend/rinterface.h"
  #include "rbackend/rcommand.h"
  
! RKConsole::RKConsole(QWidget *parent, const char *name)
!  : KTextEdit(parent, name)
! {
  	QFont font ("Courier");
  	setFont (font);
--- 27,44 ----
   
  #include <klocale.h>
+ #include <kaction.h>
   
  #include "rkconsole.h"
  
  #include "rkglobals.h"
+ #include "rkward.h"
+ #include "khelpdlg.h"
+ #include "debug.h"
  #include "rbackend/rinterface.h"
  #include "rbackend/rcommand.h"
  
! RKConsole::RKConsole (QWidget *parent, const char *name) : KTextEdit (parent, name) {
! 	RK_TRACE (APP);
! 
  	QFont font ("Courier");
  	setFont (font);
***************
*** 51,59 ****
  	
  	connect (this, SIGNAL (userCommandFinished ()), this, SLOT (slotCommandFinished ()));
  }
  
  
! RKConsole::~RKConsole()
! {
  }
  
--- 55,65 ----
  	
  	connect (this, SIGNAL (userCommandFinished ()), this, SLOT (slotCommandFinished ()));
+ 
+ 	RKGlobals::rkApp()->m_manager->addPart (new RKConsolePart (this), false);
  }
  
  
! RKConsole::~RKConsole () {
! 	RK_TRACE (APP);
  }
  
***************
*** 227,235 ****
  }
  
- #include "rkconsole.moc"
- 
- 
- 
- 
  
  void RKConsole::slotCommandFinished()
--- 233,236 ----
***************
*** 261,263 ****
  	newLine();
  	
! }
\ No newline at end of file
--- 262,296 ----
  	newLine();
  	
! }
! 
! ///################### END RKConsole ########################
! ///################### BEGIN RKConsolePart ####################
! 
! RKConsolePart::RKConsolePart (RKConsole *console) : KParts::Part (0) {
! 	RK_TRACE (APP);
! 
! 	KInstance* instance = new KInstance ("rkward");
! 	setInstance (instance);
! 
! 	setWidget (console);
! 	RKConsolePart::console = console;
! 
! 	setXMLFile ("rkconsolepart.rc");
! 
! 	context_help = new KAction (i18n ("&Function reference"), KShortcut ("F2"), this, SLOT (showContextHelp ()), actionCollection (), "function_reference");
! }
! 
! RKConsolePart::~RKConsolePart () {
! 	RK_TRACE (APP);
! }
! 
! void RKConsolePart::showContextHelp () {
! 	RK_TRACE (APP);
! 
! 	int para, p;
! 	console->getCursorPosition (&para, &p);
! 
! 	RKGlobals::helpDialog ()->getContextHelp (console->text (para), p);
! }
! 
! #include "rkconsole.moc"

Index: rkward.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkward.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** rkward.h	17 Sep 2005 17:16:37 -0000	1.47
--- rkward.h	17 Sep 2005 19:23:52 -0000	1.48
***************
*** 56,60 ****
  class RKMenuList;
  class RKCommandEditorWindow;
- class KHelpDlg;
  class RKConsole;
  
--- 56,59 ----
***************
*** 252,256 ****
  	
  	RObjectBrowser *object_browser;
- 	KHelpDlg *helpDlg;
  	RKConsole * console;
  	
--- 251,254 ----

Index: rkconsole.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkconsole.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** rkconsole.h	5 May 2005 20:20:49 -0000	1.7
--- rkconsole.h	17 Sep 2005 19:23:52 -0000	1.8
***************
*** 19,22 ****
--- 19,24 ----
  
  #include <ktextedit.h>
+ #include <kparts/part.h>
+ 
  #include <qptrlist.h>
  
***************
*** 88,92 ****
  /** We overload the clear function.*/
  	void clear();
-     
  private slots:
  /** Called when a command has been executed. */
--- 90,93 ----
***************
*** 94,96 ****
--- 95,118 ----
  };
  
+ /** A part interface to RKConsole. Provides the context-help functionality
+ 
+ @author Thomas Friedrichsmeier */
+ 
+ class RKConsolePart : public KParts::Part {
+ 	Q_OBJECT
+ public:
+ /** constructor.
+ @param console The console for this part */
+ 	RKConsolePart (RKConsole *console);
+ /** destructor */
+ 	~RKConsolePart ();
+ public slots:
+ /** show context help on the current word */
+ 	void showContextHelp ();
+ private:
+ 	KAction *context_help;
+ 
+ 	RKConsole *console;
+ };
+ 
  #endif

Index: rkglobals.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkglobals.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** rkglobals.cpp	9 Sep 2005 13:02:57 -0000	1.7
--- rkglobals.cpp	17 Sep 2005 19:23:52 -0000	1.8
***************
*** 23,26 ****
--- 23,27 ----
  RKModificationTracker *RKGlobals::mtracker;
  RKComponentMap *RKGlobals::cmap;
+ KHelpDlg *RKGlobals::helpdlg;
  
  /* statics

Index: khelpdlg.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/khelpdlg.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** khelpdlg.cpp	14 Sep 2005 16:32:25 -0000	1.9
--- khelpdlg.cpp	17 Sep 2005 19:23:52 -0000	1.10
***************
*** 27,30 ****
--- 27,31 ----
  #include <qlistview.h>
  #include <qlineedit.h>
+ #include <qregexp.h>
  
  #include "rbackend/rinterface.h"
***************
*** 72,75 ****
--- 73,96 ----
  {}
  
+ void KHelpDlg::getContextHelp (const QString &context_line, int cursor_pos) {
+ 	if (context_line.isEmpty () || context_line.isNull ()) return;
+ 
+ 	// step 1: find out word under cursor
+ 	// We want to match any valid R name, that is, everything composed of letters, 0-9, '.'s and '_'s..
+ 	QRegExp rx_no_word ("[^A-Za-z0-9\\._]");
+ 
+ 	// find out the next non-word stuff left and right of the current cursor position
+ 	int current_word_start = context_line.findRev (rx_no_word, cursor_pos-1) + 1;
+ 	int current_word_end = context_line.find (rx_no_word, cursor_pos);
+ 
+ 	// if both return the same position, we're on a non-word.
+ 	if (current_word_start == current_word_end) return;
+ 
+ 	QString result = context_line.mid (current_word_start, current_word_end - current_word_start);
+ 
+ 	// step 2: retrieve help
+ 	RKGlobals::rInterface ()->issueCommand ("help(\"" + result + "\", htmlhelp=TRUE)[1]", RCommand::App | RCommand::Sync | RCommand::GetStringVector, "", this, GET_HELP_URL, 0);
+ }
+ 
  /*$SPECIALIZATION$*/
  void KHelpDlg::slotFindButtonClicked()

Index: Makefile.am
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/Makefile.am,v
retrieving revision 1.57
retrieving revision 1.58
diff -C2 -d -r1.57 -r1.58
*** Makefile.am	14 Sep 2005 16:32:25 -0000	1.57
--- Makefile.am	17 Sep 2005 19:23:52 -0000	1.58
***************
*** 65,69 ****
  
  rcdir = $(kde_datadir)/rkward
! rc_DATA = rkwardui.rc
  
  messages: rc.cpp
--- 65,69 ----
  
  rcdir = $(kde_datadir)/rkward
! rc_DATA = rkwardui.rc rkconsolepart.rc
  
  messages: rc.cpp

--- NEW FILE: rkconsolepart.rc ---
<!DOCTYPE kpartgui>
<kpartgui name="rkward" version="0.3.3">
	<MenuBar>
		<Menu name="help"><text>&Help</text>
			<Action name="function_reference"></Action>
		</Menu>
	</MenuBar>
</kpartgui>
Index: rkward.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkward.cpp,v
retrieving revision 1.98
retrieving revision 1.99
diff -C2 -d -r1.98 -r1.99
*** rkward.cpp	17 Sep 2005 17:16:37 -0000	1.98
--- rkward.cpp	17 Sep 2005 19:23:52 -0000	1.99
***************
*** 195,201 ****
  	addToolWindow(console,KDockWidget::DockBottom, getMainDockWidget(), 10);
  	
! 	helpDlg = new KHelpDlg(0);
! 	helpDlg->setIcon(SmallIcon("help"));
! 	addToolWindow(helpDlg,KDockWidget::DockBottom, getMainDockWidget(), 10);
  
  	if (initial_url) {
--- 195,201 ----
  	addToolWindow(console,KDockWidget::DockBottom, getMainDockWidget(), 10);
  	
! 	RKGlobals::helpdlg = new KHelpDlg(0);
! 	RKGlobals::helpDialog ()->setIcon(SmallIcon("help"));
! 	addToolWindow(RKGlobals::helpDialog (), KDockWidget::DockBottom, getMainDockWidget(), 10);
  
  	if (initial_url) {

Index: rkglobals.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkglobals.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** rkglobals.h	9 Sep 2005 13:02:57 -0000	1.6
--- rkglobals.h	17 Sep 2005 19:23:52 -0000	1.7
***************
*** 24,27 ****
--- 24,28 ----
  class RKModificationTracker;
  class RKComponentMap;
+ class KHelpDlg;
  
  // deletes the given char*, if it is not a special value. Does not set to 0.
***************
*** 35,41 ****
  class RKGlobals{
  public:
!     RKGlobals();
! 
!     ~RKGlobals();
  
  /// static pointer to the app
--- 36,43 ----
  class RKGlobals{
  public:
! /** constructor. Do not use. No instance needed of this class. Only static stuff inside */
! 	RKGlobals ();
! /** destructor. Do not use. No instance needed of this class. Only static stuff inside */
! 	~RKGlobals ();
  
  /// static pointer to the app
***************
*** 51,54 ****
--- 53,58 ----
  /// static pointer to the RKComponentMap
  	static RKComponentMap *componentMap () { return cmap; };
+ /// static pointer to the RKHelpDlg
+ 	static KHelpDlg *helpDialog () { return helpdlg; };
  
  /// an empty char
***************
*** 71,74 ****
--- 75,79 ----
  	static RKModificationTracker *mtracker;
  	static RKComponentMap *cmap;
+ 	static KHelpDlg *helpdlg;
  };
  

Index: khelpdlg.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/khelpdlg.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** khelpdlg.h	24 Apr 2005 16:16:09 -0000	1.6
--- khelpdlg.h	17 Sep 2005 19:23:52 -0000	1.7
***************
*** 33,37 ****
      ~KHelpDlg();
      void rCommandDone (RCommand *command);
!     
    /*$PUBLIC_FUNCTIONS$*/
  
--- 33,43 ----
      ~KHelpDlg();
      void rCommandDone (RCommand *command);
! 
! /** small convenience function to get context help for RKCommandEditorWindow and RKConsole.
! @param context_line The current line
! @param cursor_pos cursor position in the current line
! Will figure out the word under the cursor, and provide help on that (if there is such a word, and such help exists) */
! 	void getContextHelp (const QString &context_line, int cursor_pos);
! 
    /*$PUBLIC_FUNCTIONS$*/
  





More information about the rkward-tracker mailing list