src/Tools/jEdit/src/jedit_options.scala
author wenzelm
Tue, 06 Dec 2022 14:41:13 +0100
changeset 76577 c662a56e77a8
parent 76392 3fa81de0b6c5
child 76578 06b001094ddb
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49245
cb70157293c0 manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff changeset
     1
/*  Title:      Tools/jEdit/src/jedit_options.scala
cb70157293c0 manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
cb70157293c0 manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff changeset
     3
cb70157293c0 manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff changeset
     4
Options for Isabelle/jEdit.
cb70157293c0 manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff changeset
     5
*/
cb70157293c0 manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff changeset
     6
cb70157293c0 manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff changeset
     7
package isabelle.jedit
cb70157293c0 manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff changeset
     8
cb70157293c0 manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff changeset
     9
cb70157293c0 manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff changeset
    10
import isabelle._
cb70157293c0 manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff changeset
    11
61607
a99125aa964f prefer static Font -- evade spontaneous change of TextField.font seen with Metal L&F in Plugin Options / Isabelle / General / Apply;
wenzelm
parents: 60844
diff changeset
    12
import java.awt.{Font, Color}
49252
9e10481dd3c4 prefer global default font over IsabelleText of jEdit TextArea;
wenzelm
parents: 49248
diff changeset
    13
import javax.swing.{InputVerifier, JComponent, UIManager}
49246
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
    14
import javax.swing.text.JTextComponent
49252
9e10481dd3c4 prefer global default font over IsabelleText of jEdit TextArea;
wenzelm
parents: 49248
diff changeset
    15
49246
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
    16
import scala.swing.{Component, CheckBox, TextArea}
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
    17
49296
313369027391 some GUI support for color options;
wenzelm
parents: 49289
diff changeset
    18
import org.gjt.sp.jedit.gui.ColorWellButton
76390
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    19
import org.gjt.sp.jedit.{jEdit, AbstractOptionPane}
49296
313369027391 some GUI support for color options;
wenzelm
parents: 49289
diff changeset
    20
49246
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
    21
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73340
diff changeset
    22
object JEdit_Options {
75855
9ce4cb8e3f77 tuned comments;
wenzelm
parents: 75854
diff changeset
    23
  /* typed access and GUI components */
75849
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    24
75847
93436389db1c clarified signature: more explicit types;
wenzelm
parents: 75841
diff changeset
    25
  class Access[A](access: Options.Access_Variable[A], val name: String) {
93436389db1c clarified signature: more explicit types;
wenzelm
parents: 75841
diff changeset
    26
    def apply(): A = access.apply(name)
93436389db1c clarified signature: more explicit types;
wenzelm
parents: 75841
diff changeset
    27
    def update(x: A): Unit = change(_ => x)
93436389db1c clarified signature: more explicit types;
wenzelm
parents: 75841
diff changeset
    28
    def change(f: A => A): Unit = {
93436389db1c clarified signature: more explicit types;
wenzelm
parents: 75841
diff changeset
    29
      val x0 = apply()
93436389db1c clarified signature: more explicit types;
wenzelm
parents: 75841
diff changeset
    30
      access.change(name, f)
93436389db1c clarified signature: more explicit types;
wenzelm
parents: 75841
diff changeset
    31
      val x1 = apply()
93436389db1c clarified signature: more explicit types;
wenzelm
parents: 75841
diff changeset
    32
      if (x0 != x1) changed()
93436389db1c clarified signature: more explicit types;
wenzelm
parents: 75841
diff changeset
    33
    }
93436389db1c clarified signature: more explicit types;
wenzelm
parents: 75841
diff changeset
    34
    def changed(): Unit = GUI_Thread.require { PIDE.session.update_options(access.options.value) }
93436389db1c clarified signature: more explicit types;
wenzelm
parents: 75841
diff changeset
    35
  }
75848
9e4c0aaa30aa clarified signature;
wenzelm
parents: 75847
diff changeset
    36
9e4c0aaa30aa clarified signature;
wenzelm
parents: 75847
diff changeset
    37
  class Bool_Access(name: String) extends Access(PIDE.options.bool, name) {
9e4c0aaa30aa clarified signature;
wenzelm
parents: 75847
diff changeset
    38
    def set(): Unit = update(true)
9e4c0aaa30aa clarified signature;
wenzelm
parents: 75847
diff changeset
    39
    def reset(): Unit = update(false)
9e4c0aaa30aa clarified signature;
wenzelm
parents: 75847
diff changeset
    40
    def toggle(): Unit = change(b => !b)
9e4c0aaa30aa clarified signature;
wenzelm
parents: 75847
diff changeset
    41
  }
75849
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    42
75852
fcc25bb49def clarified signature;
wenzelm
parents: 75851
diff changeset
    43
  class Bool_GUI(access: Bool_Access, label: String)
75854
2163772eeaf2 tuned signature;
wenzelm
parents: 75852
diff changeset
    44
  extends GUI.Check(label, init = access()) {
75851
56f3032f0747 clarified signature;
wenzelm
parents: 75849
diff changeset
    45
    def load(): Unit = { selected = access() }
75852
fcc25bb49def clarified signature;
wenzelm
parents: 75851
diff changeset
    46
    override def clicked(state: Boolean): Unit = access.update(state)
75851
56f3032f0747 clarified signature;
wenzelm
parents: 75849
diff changeset
    47
  }
56f3032f0747 clarified signature;
wenzelm
parents: 75849
diff changeset
    48
56f3032f0747 clarified signature;
wenzelm
parents: 75849
diff changeset
    49
75849
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    50
  /* specific options */
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    51
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    52
  object continuous_checking extends Bool_Access("editor_continuous_checking") {
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    53
    override def changed(): Unit = {
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    54
      super.changed()
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    55
      PIDE.plugin.deps_changed()
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    56
    }
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    57
75852
fcc25bb49def clarified signature;
wenzelm
parents: 75851
diff changeset
    58
    class GUI extends Bool_GUI(this, "Continuous checking") {
fcc25bb49def clarified signature;
wenzelm
parents: 75851
diff changeset
    59
      tooltip = "Continuous checking of proof document (visible and required parts)"
fcc25bb49def clarified signature;
wenzelm
parents: 75851
diff changeset
    60
    }
75849
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    61
  }
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    62
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    63
  object output_state extends Bool_Access("editor_output_state") {
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    64
    override def changed(): Unit = GUI_Thread.require {
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    65
      super.changed()
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    66
      PIDE.editor.flush_edits(hidden = true)
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    67
      PIDE.editor.flush()
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    68
    }
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    69
75852
fcc25bb49def clarified signature;
wenzelm
parents: 75851
diff changeset
    70
    class GUI extends Bool_GUI(this, "Proof state") {
fcc25bb49def clarified signature;
wenzelm
parents: 75851
diff changeset
    71
      tooltip = "Output of proof state (normally shown on State panel)"
fcc25bb49def clarified signature;
wenzelm
parents: 75851
diff changeset
    72
    }
75849
dfedac6525d4 clarified modules;
wenzelm
parents: 75848
diff changeset
    73
  }
76390
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    74
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    75
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    76
  /* editor pane for plugin options */
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    77
76391
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
    78
  trait Entry extends Component {
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
    79
    val title: String
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
    80
    def load(): Unit
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
    81
    def save(): Unit
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
    82
  }
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
    83
76390
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    84
  abstract class Isabelle_Options(name: String) extends AbstractOptionPane(name) {
76391
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
    85
    protected val components: List[(String, List[Entry])]
76390
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    86
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    87
    override def _init(): Unit = {
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    88
      val dummy_property = "options.isabelle.dummy"
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    89
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    90
      for ((s, cs) <- components) {
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    91
        if (s.nonEmpty) {
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    92
          jEdit.setProperty(dummy_property, s)
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    93
          addSeparator(dummy_property)
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    94
          jEdit.setProperty(dummy_property, null)
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    95
        }
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    96
        for (c <- cs) addComponent(c.title, c.peer)
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    97
      }
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    98
    }
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
    99
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   100
    override def _save(): Unit = {
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   101
      for ((_, cs) <- components; c <- cs) c.save()
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   102
    }
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   103
  }
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   104
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   105
  class Isabelle_General_Options extends Isabelle_Options("isabelle-general") {
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   106
    val options: JEdit_Options = PIDE.options
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   107
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   108
    private val predefined =
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   109
      List(JEdit_Sessions.logic_selector(options),
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   110
        JEdit_Spell_Checker.dictionaries_selector())
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   111
76391
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
   112
    protected val components: List[(String, List[Entry])] =
76390
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   113
      options.make_components(predefined,
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   114
        (for ((name, opt) <- options.value.opt_iterator if opt.public) yield name).toSet)
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   115
  }
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   116
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   117
  class Isabelle_Rendering_Options extends Isabelle_Options("isabelle-rendering") {
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   118
    private val predefined =
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   119
      (for {
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   120
        (name, opt) <- PIDE.options.value.opt_iterator
76392
wenzelm
parents: 76391
diff changeset
   121
        if name.endsWith("_color") && opt.section == "Rendering of Document Content"
76390
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   122
      } yield PIDE.options.make_color_component(opt)).toList
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   123
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   124
    assert(predefined.nonEmpty)
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   125
76391
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
   126
    protected val components: List[(String, List[Entry])] =
76390
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   127
      PIDE.options.make_components(predefined, _ => false)
5309f1283d93 clarified modules;
wenzelm
parents: 75855
diff changeset
   128
  }
52065
78f2475aa126 explicit notion of public options, which are shown in the editor options dialog;
wenzelm
parents: 51616
diff changeset
   129
}
78f2475aa126 explicit notion of public options, which are shown in the editor options dialog;
wenzelm
parents: 51616
diff changeset
   130
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73340
diff changeset
   131
class JEdit_Options(init_options: Options) extends Options_Variable(init_options) {
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49317
diff changeset
   132
  def color_value(s: String): Color = Color_Value(string(s))
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49317
diff changeset
   133
76391
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
   134
  def make_color_component(opt: Options.Opt): JEdit_Options.Entry = {
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 56752
diff changeset
   135
    GUI_Thread.require {}
49296
313369027391 some GUI support for color options;
wenzelm
parents: 49289
diff changeset
   136
313369027391 some GUI support for color options;
wenzelm
parents: 49289
diff changeset
   137
    val opt_name = opt.name
313369027391 some GUI support for color options;
wenzelm
parents: 49289
diff changeset
   138
    val opt_title = opt.title("jedit")
313369027391 some GUI support for color options;
wenzelm
parents: 49289
diff changeset
   139
313369027391 some GUI support for color options;
wenzelm
parents: 49289
diff changeset
   140
    val button = new ColorWellButton(Color_Value(opt.value))
76391
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
   141
    val component =
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
   142
      new Component with JEdit_Options.Entry {
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
   143
        override lazy val peer: JComponent = button
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
   144
        name = opt_name
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
   145
        val title: String = opt_title
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
   146
        def load(): Unit = button.setSelectedColor(Color_Value(string(opt_name)))
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
   147
        def save(): Unit = string(opt_name) = Color_Value.print(button.getSelectedColor)
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
   148
      }
56622
891d1b8b64fb clarified tooltip_lines: HTML.encode already takes care of newline (but not space);
wenzelm
parents: 56611
diff changeset
   149
    component.tooltip = GUI.tooltip_lines(opt.print_default)
49296
313369027391 some GUI support for color options;
wenzelm
parents: 49289
diff changeset
   150
    component
313369027391 some GUI support for color options;
wenzelm
parents: 49289
diff changeset
   151
  }
313369027391 some GUI support for color options;
wenzelm
parents: 49289
diff changeset
   152
76391
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
   153
  def make_component(opt: Options.Opt): JEdit_Options.Entry = {
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 56752
diff changeset
   154
    GUI_Thread.require {}
49246
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
   155
49270
e5d162d15867 some support to organize options in sections;
wenzelm
parents: 49252
diff changeset
   156
    val opt_name = opt.name
e5d162d15867 some support to organize options in sections;
wenzelm
parents: 49252
diff changeset
   157
    val opt_title = opt.title("jedit")
49246
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
   158
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
   159
    val component =
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
   160
      if (opt.typ == Options.Bool)
76391
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
   161
        new CheckBox with JEdit_Options.Entry {
49270
e5d162d15867 some support to organize options in sections;
wenzelm
parents: 49252
diff changeset
   162
          name = opt_name
75827
4920ebbde486 tuned, following hints by IntelliJ IDEA;
wenzelm
parents: 75393
diff changeset
   163
          val title: String = opt_title
73337
0af9e7e4476f tuned --- fewer warnings;
wenzelm
parents: 71601
diff changeset
   164
          def load(): Unit = selected = bool(opt_name)
0af9e7e4476f tuned --- fewer warnings;
wenzelm
parents: 71601
diff changeset
   165
          def save(): Unit = bool(opt_name) = selected
49246
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
   166
        }
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
   167
      else {
61742
fd3b214b0979 clarified font: GUI defaults might change dynamically;
wenzelm
parents: 61607
diff changeset
   168
        val default_font = GUI.copy_font(UIManager.getFont("TextField.font"))
49246
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
   169
        val text_area =
76391
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
   170
          new TextArea with JEdit_Options.Entry {
61742
fd3b214b0979 clarified font: GUI defaults might change dynamically;
wenzelm
parents: 61607
diff changeset
   171
            if (default_font != null) font = default_font
49270
e5d162d15867 some support to organize options in sections;
wenzelm
parents: 49252
diff changeset
   172
            name = opt_name
75827
4920ebbde486 tuned, following hints by IntelliJ IDEA;
wenzelm
parents: 75393
diff changeset
   173
            val title: String = opt_title
73337
0af9e7e4476f tuned --- fewer warnings;
wenzelm
parents: 71601
diff changeset
   174
            def load(): Unit = text = value.check_name(opt_name).value
0af9e7e4476f tuned --- fewer warnings;
wenzelm
parents: 71601
diff changeset
   175
            def save(): Unit =
65236
4fa82bbb394e afford early initialization of JEdit_Options, but it may lead to messy exception trace for malformed etc/preferences (see also 6eeaaefcea56);
wenzelm
parents: 62227
diff changeset
   176
              try { JEdit_Options.this += (opt_name, text) }
49317
5eff42e69edb tuned error;
wenzelm
parents: 49296
diff changeset
   177
              catch {
5eff42e69edb tuned error;
wenzelm
parents: 49296
diff changeset
   178
                case ERROR(msg) =>
51616
949e2cf02a3d tuned signature -- concentrate GUI tools;
wenzelm
parents: 49701
diff changeset
   179
                  GUI.error_dialog(this.peer, "Failed to update options",
949e2cf02a3d tuned signature -- concentrate GUI tools;
wenzelm
parents: 49701
diff changeset
   180
                    GUI.scrollable_text(msg))
49317
5eff42e69edb tuned error;
wenzelm
parents: 49296
diff changeset
   181
              }
49246
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
   182
          }
75827
4920ebbde486 tuned, following hints by IntelliJ IDEA;
wenzelm
parents: 75393
diff changeset
   183
        text_area.peer.setInputVerifier({
4920ebbde486 tuned, following hints by IntelliJ IDEA;
wenzelm
parents: 75393
diff changeset
   184
            case text: JTextComponent =>
4920ebbde486 tuned, following hints by IntelliJ IDEA;
wenzelm
parents: 75393
diff changeset
   185
              try { value + (opt_name, text.getText); true }
4920ebbde486 tuned, following hints by IntelliJ IDEA;
wenzelm
parents: 75393
diff changeset
   186
              catch { case ERROR(_) => false }
4920ebbde486 tuned, following hints by IntelliJ IDEA;
wenzelm
parents: 75393
diff changeset
   187
            case _ => true
49246
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
   188
          })
56752
72b4205f4de9 uniform focus traversal via TAB / Shift-TAB for all fields, in contrast to Java defaults, but in accordance to occasional jEdit practice;
wenzelm
parents: 56662
diff changeset
   189
        GUI.plain_focus_traversal(text_area.peer)
49246
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
   190
        text_area
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
   191
      }
49247
ffd9ad9dc35b more detailed option tooltip;
wenzelm
parents: 49246
diff changeset
   192
    component.load()
56622
891d1b8b64fb clarified tooltip_lines: HTML.encode already takes care of newline (but not space);
wenzelm
parents: 56611
diff changeset
   193
    component.tooltip = GUI.tooltip_lines(opt.print_default)
49246
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
   194
    component
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
   195
  }
49270
e5d162d15867 some support to organize options in sections;
wenzelm
parents: 49252
diff changeset
   196
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73340
diff changeset
   197
  def make_components(
76391
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
   198
    predefined: List[JEdit_Options.Entry],
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73340
diff changeset
   199
    filter: String => Boolean
76391
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
   200
  ) : List[(String, List[JEdit_Options.Entry])] = {
6129e8cb140d tuned signature;
wenzelm
parents: 76390
diff changeset
   201
    def mk_component(opt: Options.Opt): List[JEdit_Options.Entry] =
49270
e5d162d15867 some support to organize options in sections;
wenzelm
parents: 49252
diff changeset
   202
      predefined.find(opt.name == _.name) match {
e5d162d15867 some support to organize options in sections;
wenzelm
parents: 49252
diff changeset
   203
        case Some(c) => List(c)
e5d162d15867 some support to organize options in sections;
wenzelm
parents: 49252
diff changeset
   204
        case None => if (filter(opt.name)) List(make_component(opt)) else Nil
e5d162d15867 some support to organize options in sections;
wenzelm
parents: 49252
diff changeset
   205
      }
e5d162d15867 some support to organize options in sections;
wenzelm
parents: 49252
diff changeset
   206
    value.sections.sortBy(_._1).map(
71601
97ccf48c2f0c misc tuning based on hints by IntelliJ IDEA;
wenzelm
parents: 65236
diff changeset
   207
        { case (a, opts) => (a, opts.sortBy(_.title("jedit")).flatMap(mk_component)) })
49270
e5d162d15867 some support to organize options in sections;
wenzelm
parents: 49252
diff changeset
   208
      .filterNot(_._2.isEmpty)
e5d162d15867 some support to organize options in sections;
wenzelm
parents: 49252
diff changeset
   209
  }
49245
cb70157293c0 manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents:
diff changeset
   210
}