1. 30 Jan, 2020 3 commits
    • Christian Hergert's avatar
      snippet: implement snippet engine · 736d0876
      Christian Hergert authored
      This is a straightforward port of Builder's snippet system to GtkSourceView.
      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.
      
       - 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.
      
       - Snippet files can override snippets from lower precedent files by using
         the <removed trigger="word" languages="c;chdr;"/> syntax.
      736d0876
    • Christian Hergert's avatar
      fonts: bundle BuilderBlocks · dea4afe2
      Christian Hergert authored
      If we have fontconfig and pangoft2, we can override the font that is used
      within the GtkSourceMap to be our "block" font. This is much more readable
      than the scaled down 1pt font we fallback to. It is also faster to raster.
      
      This, in practice, will only work where those libraries are available but
      certainly covers Linux and BSD. Possibly covers Mac (needs testing) and
      optionally covers Windows.
      
      Other font loaders would be happily accepted.
      dea4afe2
    • Christian Hergert's avatar
      style: fix css selector for carets · 03eda7f0
      Christian Hergert authored
      You no longer need "textview text" for caret styling, as it can be done
      with just "textview" now. Fixes the caret color for style schemes which
      were not getting the proper coloring.
      03eda7f0
  2. 29 Jan, 2020 37 commits