Auto Indentation
Simply writing code by automatically indenting the source code as you type.
Status
Needs design
Design in progress
Needs implementation
Implementation in progress
Stable
Goals
- Be able to undo with Control+Z if it wasn't correct
- C
- Support for GLib/GNU style C89 C code.
- Auto-format parameters
- Python
- PEP8
- Auto indent when scope dictates
- Auto unindent upon keywords dictating scope has ended (return, pass, etc)
- XML
- Auto indent when opening a new element
- Auto unindent when closing an element
- Skip past CDATA
Non Goals
Reformatting existing code similar to VIM's gq
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); };