[Idle-dev] Position info (Brkpoints)

Dirk-Ulrich Heise hei@adtranzsig.de
Thu, 2 Mar 2000 09:27:00 +0100


Guido mentioned the need of a global 
database for tracking persistent brkpoint positions.

In an editor i'm writing i needed to track positions
for folding. I didn't like the Origami approach of
leaving strange comments in the files; this changes
the file, and the editor has to know about the language
to make a valid comment. (Don't know if Origami
still does it that way, i had a copy about 7 years ago)

My solution was to store the line number and the
trimmed content of the line together in an ASCII file.
(trimmed off whitespace at start and end of line)

On startup, the editor can check the content of the file
it loads at the given line number; if the content equals
the one stored in the "data base", it's ok, otherwise,
the file might have been changed by a second editor,
and you can now try to seek neighbouring lines for
the content you expect. If the distance gets too big
during this seeking, say, more than 20 lines, the
re-synching process would be aborted, and the fold
deleted.

During editing, the positions (just like for a breakpoint,
only the line number is considered important) are
updated by the editors operations.

Although only one line of context is stored for 
each position, this scheme works very nice for my folds: 
I'm able to
fold any kind of program source, the editor will not
mess up the file, and you can even make (small) edits
with other tools without losing all the folding info.

Of course, it works not very well when the position is on an
empty line; but for your breakpoints, this will not be
the case, anyway.

If you favor that approach, i could submit some C++
snippets that figure out the peculiarities of the re-synching
and the likes. (No heavy template magic or the likes,
should be straightforward to re-code in Python)

Dirk