On Mon, Sep 23, 2013 at 8:15 PM, simargl <[email protected]> wrote:

> Hi,
>
> Emendo is a simple text editor with syntax highlighting written in Vala,
> using Gtk+3 and Gtksourceview. If someone is interested source tarball can
> be found here:http://alphaos.tuxfamily.org/forum/viewtopic.php?f=8&t=702#p1151
>
> Presenting this text editor to you is one thing, but more important there
> are two known bugs I am still not able to solve:
>
> First, before closing program from toolbar or with Ctrl+Q, there is
> source_buffer_check method called (line 700) from action_quit (line 573)
> method, that offers to save changes if source buffer is modified. That
> works fine if program is closing from toolbar button or Ctrl+Q, but when X
> in titlebar is clicked, program first closes then shows that dialog box and
> offers to save changes.
>
> Second, replace_all method (line 545) works OK, but it is not undoable,
> when undo button from toolbar is clicked, everything from sourcebuffer gets
> deleted.
>
> Thank you for any help.
>

Solved not undoable replace_all with adding two lines:

source_buffer.begin_user_action();

and

source_buffer.end_user_action();

..................
    private void replace_all()
    {
      string search_string = replace_search_entry.text;
      string replace_string = replace_entry.text;
      Gtk.TextSearchFlags flags = Gtk.TextSearchFlags.TEXT_ONLY;
      Gtk.TextIter start_iter, match_start, match_end;
      source_buffer.get_start_iter (out start_iter);
      while (start_iter.forward_search (search_string, flags, out
match_start, out match_end, null))
      {
        source_buffer.begin_user_action();
        source_buffer.@delete (ref match_start, ref match_end);
        source_buffer.insert (ref match_start, replace_string,
replace_string.length);
        start_iter = match_start;
        source_view.scroll_to_iter (start_iter, 0.10, false, 0, 0);
        source_buffer.end_user_action();
      }
    }
....................
_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to