On 3/5/07, Josiah Carlson <[EMAIL PROTECTED]> wrote:
On 3/5/07, SPE Stani's Python Editor <[EMAIL PROTECTED]> wrote:
> Realtime updating is also which belongs to the generic part. Therefore
> we need to be able to diffs between a previous state and a current
> state and to add a property expanded (True/False) to the nodes. Again
> if we implement this in a generic way, we get everything for free for
> all languages.

I actually implemented a variant of 'diff in place' method for trees after
seeing yours.  It doesn't handle renames very well (it ends up recreating
the subtree of a named node), but it seemed to speed up the tree
manipulations that PyPE was doing.  I need to release a new version of PyPE
soon, so I'll let everyone know where the code can be found when it is
available.
Interesting. Is it not somewhere in cvs or subversion? I thought my
process could be optimized as you do not need to 'diff in place' for
nodes or create subtrees, only when they are expanded. Does your
implementation have this 'lazy diff in place'? For doing diffs I was
also wondering maybe to provide the tree and nodes with a __str__
method so you can use the diff functionality from the standard diff in
the hope that is well written, optimized code.

> Another thing is that fold explorer will be a good tool for what I

I have considered local code blocks, but I don't believe that they are
really all that practical.  You end up needing to update line numbers for
all later code blocks anyways, so you may as well just do the entire thing.
For syntax errors I still do think it is possible in the following
way. Ask scintilla the first and last visible line. Than we need to
find the top line equal or above the first line and the bottom line
equal or below the last line. If the first line is an except statement
we need to go up till the try statement, otherwise we can just use the
first visible line. What concerns the last line, we need to go down to
the first not folding node, again with the exception that every try
statement has to be closed. This is not tested and probably it has to
be corrected but maybe it should work.

As for class explorers the task is more difficult indeed. I am just
wondering if there are more hidden treasures in Scintilla for
notifications and identifying changes. I need to study this more.

Maybe it is crazy idea, but we could also invent a new way of dealing
with source editing:
- first we load the whole document so that scintilla can parse it
- than if a user (right) clicks on a tree item, it *only* displays
that code. If you want to have more overview, you click a higher node
etc...
- every time a user (right) clicks a node the editor substitutes the
new code with the previous selection between start and end

- why?
- sometimes it is nicer to work more zoomed in and you still have the
overview if you click on the root node which can be called 'whole
document'
- if the selection exceeds a certain number of lines (user preference)
realtime features are turned off (or switch to threading)
- this will be faster than any other method. Also threading as it only
works on part of the document

Maybe this is a nice idea, but a bit unconvential. Does anybody knows
an editor which works like this. Leo maybe? This could be also an
optional feature which can be turned or off at any time.

What I have found works reasonably well is to update syntax errors and trees
after a delay that is a function of how long it took to generate the
information the last time.  When generating, I have a secondary thread do
the compilation, etc., to allow the main thread to do its business of
letting people edit, etc., then taking control to update controls, etc.  The
only issue is that you can't use the standard STCStyleEditor.py to handle
style setting, as it uses the wx.FileConfig class, which seems to have
threading issues
(http://lists.wxwidgets.org/cgi-bin/ezmlm-cgi?11:mss:47836:200602:nmkejbkeoodckphegicd
).  If you switch to the StyleSetter.py that is included with PyPE, you
should be able to use multiple threads at the same time (PyPE has been doing
so for over a year now).
I would prefer to have a not-threading alternative. For example you
can not run SPE in Blender with threads. For compiling/syntax errors
you need only a few lines of output (error label, line number, etc..),
so it could also be done with a subprocess as most cpus become
multi-core and threading is only single-core.

Stani
--
http://pythonide.stani.be

Reply via email to