Skip to content
  • Christian Hergert's avatar
    This is a straightforward port of Builder's snippet system to GtkSourceView. · 76d5a1ff
    Christian Hergert authored
    A number of new objects are added as part of this commit to the
    GtkSourceView ABI.
    
     - GtkSourceSnippet provides an object representing a snippet to be inserted
       into a textview. Snippets are associated with a textview rather than a
       buffer because of incremental state that is necessary to interact with
       widgetry and event controllers. Additionally, it doesn't make sense to have
       this attached to the buffer when the view area could be different.
    
     - GtkSourceSnippetChunk is a single chunk of a snippet. A snippet contains
       zero or more chunks. A chunk can have a spec (which can be evaluated
       using variables) or text set (such as after typing in the editor). Also, a
       chunk can have a "focus-position" which allows the user to tab through the
       chunks of the snippet.
    
     - GtkSourceSnippetContext provides state which can be expanded as part of
       the snippet. This is useful to expand variables set by the application or
       filters to transform input text or other variables.
    
     - gtksourceview-snippets.c contains integration bits to be hooked into
       GtkSourceView. Keeping much of this outside of gtksourceview.c helps
       to keep things mostly self-contained but also ensures that we don't keep
       growing gtksourceview.c with complexity and size. Future additions to
       gtksourceview.c should be done this way when it makes sense (such as
       adding indenters).
    
     - GtkSourceSnippetBundle is used for multiple purposes because it is handy
       to do so without increasing the number of GObjects we need and because
       it flows naturally. It is used to parse new snippet files as well as
       merge multiple snippet files together. Furthermore, it serves as a
       GListModel with a filtered set of snippets when queried by the
       snippet manager. This type is private, however.
    
     - A completion provider is provided so that applications can use snippets
       provided by the snippet manager, however it still needs porting to the
       new completion engine.
    
     - Tabbing will expand the snippet based on the current word.
    
     - The classic style scheme has been adjusted to give us access to a focus
       position tag so that they are highlighted to the user. Style schemes
       bundled with GtkSourceView will want to implement this in a future commit.
    
     - Applications can insert snippets using gtk_source_view_push_snippet().
    
     - Using the mouse or touch input to move to another chunk will cause it to
       be focused (and selected). Moving between chunks manually will cause the
       snippet to be released.
    
     - A number of snippet variables are made available as seen in other snippet
       engines, notable textmate and Visual Studio Code.
    
     - You can toggle snippets on/off in test-widget using a checkbox. The
       snippets from data/snippets/ are available based on the current
       language.
    
     - Documentation for the file format and snippet text format is provided
       as part of the gtk-doc installation.
    
     - A snippets.rng file is provided to validate snippet files
    
     - Various style schemes have gotten "snippet-focus" styles that apply
       to the focus positions of the snippet.
    76d5a1ff