[RkWard-devel] Context sensitive history

Roland Vollgaf vro at cs.tu-berlin.de
Mon Jan 15 21:04:05 UTC 2007


On Sunday 14 January 2007 23:34, Thomas Friedrichsmeier wrote:

> > Another "enhacement idea" that came to my mind last week regards the 
script
> > editor. I think it would be cool to be able to run the current block 
(block
> > in terms of the code folding brackets). Usually I have a couple of 
function
> > assignments in the script editor and would like to run either of them
> > seperately without selecting it before. The blocks to run are given by the
> > toplevel code folding nodes. So do you think one could by any means access
> > KateCodeFoldingTree *foldingTree() in the KateDocument class to implement
> > such a feature. As far as I understand the kdelibs-API one can only access
> > the Kate::Document interface which does not provide the necessary  
methods.
> > Maybe you've got an idea about that.
> 
> Nice idea. But in fact, I can see no elegant way to do it right now. 
Probably 
> we'd have to do a simplified parse from the start of the document, counting 
> the number of opening curly braces minus closing open braces up to the 
cursor 
> (being careful to exclude comments and strings), remembering the position of 
> the last top-level opening brache encountered. Then count down closing curly 
> braces after the cursor to determine the end of the statement. Finally 
> determine the start of the expression the opening curly brace belongs to 
(not 
> quite trivial, as this may be inside a function call such as for "try 
> ({expr})", or eben a nested function call, and on a different line 
> altogether). Possible, but not exactly a simple thing to add.
> 
> Supposedly in KDE4 we will gain access to the parse tree of the syntax 
> highlighting machine 
> 
(http://developer.kde.org/documentation/library/cvs-api/kdelibs-apidocs/interfaces/ktexteditor/html/classKTextEditor_1_1SmartInterface.html ; 
> but I have not looked at it in detail, so far). Then implementing this 
> feature (and some other nice things) will be a lot easier. So I think I'll 
> rather delay this. But if you'd like to scratch that itch, I'd be more than 
> happy to accept a patch...

Hi Thomas,

what do you think about this: Let the user enter begin and open marks for the 
regions he want to run. Therfore the IconBorder seems to be well suited. I 
enabled two more marks in the MarkInterfaceExtension, one showing an opening 
bracket and one a closing one. The action "run_region" then runs the region 
inside the pair of brackets containing the cursor. Not as elegant as 
automatic region determination, but for the first it does the job. Multiple 
regions can be defined, but not nested. 

I'm appending a patch and two icons. Propabliy the way I included strings and 
pixmaps is not actually correct  in terms i18n etc.  I think some dedicated 
icons  for the "run_xxxx" actions are overdue, but I don't how they are 
correctly linked into the project (thus I just picked an arbitrary existing 
icon, play_pause)

Hope this is of any use to anybody. For my work, at least, it does the job.

Have fun,

Roland









-------------- next part --------------
A non-text attachment was scrubbed...
Name: region_end.xpm
Type: image/x-xpm
Size: 412 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20070115/3b1ae4d0/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RunRegion.diff
Type: text/x-diff
Size: 7378 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20070115/3b1ae4d0/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: region_start.xpm
Type: image/x-xpm
Size: 414 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20070115/3b1ae4d0/attachment-0002.bin>


More information about the Rkward-devel mailing list