This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

Auto Indentation

Simply writing code by automatically indenting the source code as you type.

Status

Goals

Non Goals

Implementation Notes

The main piece of this implementation is ensuring that we can both add and remove text during the auto-indentation process. We also need to be able to place the cursor in the right position after the replacement.

The trigger vfunc is used to determine if an incoming keypress results in us potentially performing an indentation.

struct _GbSourceAutoIndenterClass
{
  GObjectClass parent_class;

  gchar    *(*format)     (GbSourceAutoIndenter *indenter,
                           GtkTextView          *view,
                           GtkTextBuffer        *buffer,
                           GtkTextIter          *begin,
                           GtkTextIter          *end,
                           gint                 *cursor_offset,
                           GdkEventKey          *trigger);

  gboolean  (*is_trigger) (GbSourceAutoIndenter *indenter,
                           GdkEventKey          *event);
};

2024-10-23 10:58