Re: [gedit-list] Plugin development question



Btw,

I would maybe look into the performance problem. For example, I see
that you use get_iter_at_line with a line index, which could be
potentially very slow. You could replace that by something that moves
the iter to the next line each time, pseudo code would be something
like this:

iter = buffer.get_start_iter()
enditer = buffer.get_end_iter()

while not iter.equal(enditer):
  if not iter.ends_line():
    iter.forward_to_line_end()

  strip_spaces(iter)
  iter.forward_line()


Jesse

2011/7/9 Jesse van den Kieboom <jesse icecrew nl>:
> Hi Jon,
>
> See gtk_text_view_scroll_to_iter and gtk_text_view_scroll_to_mark:
>
> http://developer.gnome.org/gtk3/stable/GtkTextView.html#gtk-text-view-scroll-to-iter
> http://developer.gnome.org/gtk3/stable/GtkTextView.html#gtk-text-view-scroll-to-mark
>
>
> Jesse
>
> 2011/7/9 Jon Leighton <j jonathanleighton com>:
>> Hi there,
>>
>> A few weeks ago I ported the trailsave plugin to Gedit 3
>> (https://github.com/jonleighton/gedit-trailsave).
>>
>> It worked, but I found it to be pretty slow, particularly on large
>> documents. So today I have been looking at a new strategy:
>>
>> * Get the contents of the buffer as a python string
>> * Use regular expressions for the replacement
>> * Save the result back to the buffer
>>
>> This seems to be much faster.
>>
>> One issue is preserving the state of the window to the user. I have
>> managed to cook up some code which restores the cursor position.
>>
>> However, I am struggle to restore the scroll position of the view. I
>> found that the Gedit.View implements the Gtk.Scrollable interface, so I
>> have been trying to use set_vadjustment. However, it simply doesn't
>> work.
>>
>> Any hints would be much appreciated. I am not really a python or a gtk
>> programmer, so apologies in advance for any ignorance on my part :) The
>> code in question is:
>>
>> https://github.com/jonleighton/gedit-trailsave/blob/master/trailsave.py#L87
>>
>> Many thanks,
>>
>> Jon Leighton
>>
>> --
>> http://jonathanleighton.com/
>>
>> _______________________________________________
>> gedit-list mailing list
>> gedit-list gnome org
>> http://mail.gnome.org/mailman/listinfo/gedit-list
>>
>>
>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]