aboutsummaryrefslogtreecommitdiff
path: root/gui/internal/ui/rules.go
diff options
context:
space:
mode:
Diffstat (limited to 'gui/internal/ui/rules.go')
-rw-r--r--gui/internal/ui/rules.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/gui/internal/ui/rules.go b/gui/internal/ui/rules.go
index 0a10996..97f3dcd 100644
--- a/gui/internal/ui/rules.go
+++ b/gui/internal/ui/rules.go
@@ -44,6 +44,7 @@ type rulesView struct {
testGo *gtk.Button
out *gtk.TextView
+ colours *highlighter
sub *gtk.Notebook
forms *formsView
rules *model.Rules
@@ -93,6 +94,7 @@ func newRulesView(w *Window) *rulesView {
r.view.SetRightMargin(8)
r.view.SetTopMargin(6)
r.buf = r.view.Buffer()
+ r.colours = newHighlighter(r.buf)
// Line numbers: their own view beside the editor, in the same scrolled
// window so the two always line up. The editor does not wrap, so one
@@ -225,6 +227,23 @@ func newRulesView(w *Window) *rulesView {
return r
}
+// applyPrefs sets the editor's font and whether the text is coloured.
+func (r *rulesView) applyPrefs(p model.Prefs) {
+ r.colours.setEnabled(p.Colours)
+ if r.rules != nil && p.Colours {
+ r.colours.paint(r.rules.Text)
+ }
+ css := gtk.NewCSSProvider()
+ if p.FontSize > 0 {
+ css.LoadFromData(fmt.Sprintf("textview { font-size: %dpt; }", p.FontSize))
+ } else {
+ css.LoadFromData("")
+ }
+ for _, v := range []*gtk.TextView{r.view, r.nums, r.out} {
+ v.StyleContext().AddProvider(css, 800)
+ }
+}
+
// formsOf is the forms of the text in the editor, for the Forms sub-tab.
func (r *rulesView) formsOf() ([]model.Form, error) {
if r.rules == nil {
@@ -383,6 +402,7 @@ func (r *rulesView) runCheck() {
r.save.SetTooltipText("nothing to save: the file matches what is on disk")
}
r.updateLineNumbers()
+ r.colours.paint(r.rules.Text)
}
// updateLineNumbers refills the gutter when the number of lines changes.