[pygtk] Search for paragraph separators in a TextBuffer
Francesco Marchetti-Stasi
fms at linux.it
Thu May 18 19:19:39 WST 2006
Hello,
I wrote a small editor targeted at handhelds, which I used to use on an
ipaq and which is now running on a Zaurus. For a bettere use of the
higher screen resolution, I need a new simple feature: paragraph
justification, where a paragraph is a block of text delimited by empty
lines (I am using this editor mainly on TeX files). Therefore, I start
by jumping at the beginning of the paragraph, as follows:
buffer = self.get_buffer()
curr = buffer.get_iter_at_mark(buffer.get_insert())
res = curr.backward_search('\n\n', 0)
if res:
par_start = res[1]
else:
par_start = buffer.get_start_iter()
buffer.place_cursor(par_start)
Apparently, this works if I am in the middle of the paragraph; but if I
am at the very beginning, it finds a match somewhere FORWARD in the
middle of the paragraph; and in some cases from the new position the
cursor also jumps back to the second character in the paragraph, and
there it stays if I keep on searching. I am really confused; am I doing
something inherently wrong, did I miss something, or is this a bug?
I have pygtk 2.6.2 and python 2.4.2. Upgrading is not really feasible
because I don't have enough RAM on my PC to run OpenEmbedded and
recompile everything, so I am using precompiled packages.
Any hint is welcome... thanks!
Francesco.
More information about the pygtk
mailing list