src/Tools/jEdit/src/isabelle.scala
changeset 55823 0331b6d2ab0c
parent 55749 75a48dc4383e
child 55824 22bc50a19afa
     1.1 --- a/src/Tools/jEdit/src/isabelle.scala	Sat Mar 01 15:58:47 2014 +0100
     1.2 +++ b/src/Tools/jEdit/src/isabelle.scala	Sat Mar 01 16:34:30 2014 +0100
     1.3 @@ -186,14 +186,39 @@
     1.4  
     1.5    /* font size */
     1.6  
     1.7 -  def reset_font_size(view: View): Unit =
     1.8 -    Rendering.font_size_change(view, _ => PIDE.options.int("jedit_reset_font_size"))
     1.9 +  private object font_size
    1.10 +  {
    1.11 +    // owned by Swing thread
    1.12 +    private var last_view: Option[View] = None
    1.13 +    private var steps = 0
    1.14 +    private val delay = Swing_Thread.delay_last(PIDE.options.seconds("editor_input_delay"))
    1.15 +    {
    1.16 +      val view = last_view getOrElse jEdit.getActiveView()
    1.17 +      Rendering.font_size_change(view, i =>
    1.18 +        {
    1.19 +          var j = i
    1.20 +          while (steps != 0 && j > 0) {
    1.21 +            if (steps > 0)
    1.22 +              { j += (j / 10) max 1; steps -= 1 }
    1.23 +            else
    1.24 +              { j -= (j / 10) max 1; steps += 1 }
    1.25 +          }
    1.26 +          steps = 0
    1.27 +          j
    1.28 +        })
    1.29 +    }
    1.30 +    def step(view: View, i: Int) { last_view = Some(view); steps += i; delay.invoke() }
    1.31 +    def reset() { delay.revoke(); last_view = None; steps = 0 }
    1.32 +  }
    1.33  
    1.34 -  def increase_font_size(view: View): Unit =
    1.35 -    Rendering.font_size_change(view, i => i + ((i / 10) max 1))
    1.36 +  def reset_font_size(view: View): Unit =
    1.37 +  {
    1.38 +    font_size.reset()
    1.39 +    Rendering.font_size_change(view, _ => PIDE.options.int("jedit_reset_font_size"))
    1.40 +  }
    1.41  
    1.42 -  def decrease_font_size(view: View): Unit =
    1.43 -    Rendering.font_size_change(view, i => i - ((i / 10) max 1))
    1.44 +  def increase_font_size(view: View): Unit = font_size.step(view, 1)
    1.45 +  def decrease_font_size(view: View): Unit = font_size.step(view, -1)
    1.46  
    1.47  
    1.48    /* structured edits */