Re: [Builder] Search and replace - reusable frontend



On 06/04/2016 03:14 AM, Sébastien Wilmet wrote:
The mockups for a new search and replace UI are really nice:
https://wiki.gnome.org/Apps/Builder/SearchAndReplace

Builder is not the only application that would benefit from the new UI.
Any text editor or IDE needs such feature, so it would be nice to make
the implementation reusable. I.e. depend only on GTK+, possibly the
libgd, and GtkSourceView.

Maybe even decouple the frontend from the controller, so that only the
controller depends on GtkSourceView (supposing that the GtkSourceSearch*
API will be used).

And a search and replace UI makes total sense to include it in
GtkSourceView. (but maybe not directly, in case refactorings are needed
and the API needs to change).

Being able to share these with Gedit is definitely a goal of ours. Like
most of our upstream work has gone in the last couple years, I imagine
we'll prototype first (which Matthew Leeds will be working on it), and
then look to see how it can be abstracted into GSV (or alternatively the
new library you've been starting for editors built on GSV).

We do intend to build the project-wide search/replace API on top of a
simple refactoring engine, but I don't think it will be all that
complex. I'm assuming something simple like:

  RefactoryCommand {
    gboolean (*do)       (RefactoryCommand *, GError **error);
    gboolean (*undo)     (RefactoryCommand *, GError **error);
    gboolean (*can_undo) (RefactoryCommand *);
    gboolean (*can_redo) (RefactoryCommand *);
    gchar   *(*get_label)(RefactoryCommand *);

    /* this allows us to push multiple items on the stack but
     * undo them as a single operation.
     */
    gboolean (*chain)    (RefactoryCommand *, RefactoryCommand *next);
  }

Which is basically just your typical undo/redo stack item (although
we'll likely need them to be async).

I envision things like F2 to rename variables/symbols/classes will
create a command like this and do refactory_engine.run(command)

-- Christian



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