src/Tools/jEdit/src/info_dockable.scala
changeset 75393 87ebf5a50283
parent 73987 fc363a3b690a
child 75809 1dd5d4f4b69e
equal deleted inserted replaced
75388:b3ca4a6ed74b 75393:87ebf5a50283
    13 import java.awt.event.{ComponentEvent, ComponentAdapter, WindowFocusListener, WindowEvent}
    13 import java.awt.event.{ComponentEvent, ComponentAdapter, WindowFocusListener, WindowEvent}
    14 
    14 
    15 import org.gjt.sp.jedit.View
    15 import org.gjt.sp.jedit.View
    16 
    16 
    17 
    17 
    18 object Info_Dockable
    18 object Info_Dockable {
    19 {
       
    20   /* implicit arguments -- owned by GUI thread */
    19   /* implicit arguments -- owned by GUI thread */
    21 
    20 
    22   private var implicit_snapshot = Document.Snapshot.init
    21   private var implicit_snapshot = Document.Snapshot.init
    23   private var implicit_results = Command.Results.empty
    22   private var implicit_results = Command.Results.empty
    24   private var implicit_info: XML.Body = Nil
    23   private var implicit_info: XML.Body = Nil
    25 
    24 
    26   private def set_implicit(
    25   private def set_implicit(
    27     snapshot: Document.Snapshot, results: Command.Results, info: XML.Body): Unit =
    26     snapshot: Document.Snapshot,
    28   {
    27     results: Command.Results,
       
    28     info: XML.Body
       
    29   ): Unit = {
    29     GUI_Thread.require {}
    30     GUI_Thread.require {}
    30 
    31 
    31     implicit_snapshot = snapshot
    32     implicit_snapshot = snapshot
    32     implicit_results = results
    33     implicit_results = results
    33     implicit_info = info
    34     implicit_info = info
    35 
    36 
    36   private def reset_implicit(): Unit =
    37   private def reset_implicit(): Unit =
    37     set_implicit(Document.Snapshot.init, Command.Results.empty, Nil)
    38     set_implicit(Document.Snapshot.init, Command.Results.empty, Nil)
    38 
    39 
    39   def apply(
    40   def apply(
    40     view: View, snapshot: Document.Snapshot, results: Command.Results, info: XML.Body): Unit =
    41     view: View,
    41   {
    42     snapshot: Document.Snapshot,
       
    43     results: Command.Results,
       
    44     info: XML.Body
       
    45   ): Unit = {
    42     set_implicit(snapshot, results, info)
    46     set_implicit(snapshot, results, info)
    43     view.getDockableWindowManager.floatDockableWindow("isabelle-info")
    47     view.getDockableWindowManager.floatDockableWindow("isabelle-info")
    44   }
    48   }
    45 }
    49 }
    46 
    50 
    47 
    51 
    48 class Info_Dockable(view: View, position: String) extends Dockable(view, position)
    52 class Info_Dockable(view: View, position: String) extends Dockable(view, position) {
    49 {
       
    50   /* component state -- owned by GUI thread */
    53   /* component state -- owned by GUI thread */
    51 
    54 
    52   private val snapshot = Info_Dockable.implicit_snapshot
    55   private val snapshot = Info_Dockable.implicit_snapshot
    53   private val results = Info_Dockable.implicit_results
    56   private val results = Info_Dockable.implicit_results
    54   private val info = Info_Dockable.implicit_info
    57   private val info = Info_Dockable.implicit_info
    69 
    72 
    70   pretty_text_area.update(snapshot, results, info)
    73   pretty_text_area.update(snapshot, results, info)
    71 
    74 
    72   private val zoom = new Font_Info.Zoom_Box { def changed = handle_resize() }
    75   private val zoom = new Font_Info.Zoom_Box { def changed = handle_resize() }
    73 
    76 
    74   private def handle_resize(): Unit =
    77   private def handle_resize(): Unit = {
    75   {
       
    76     GUI_Thread.require {}
    78     GUI_Thread.require {}
    77 
    79 
    78     pretty_text_area.resize(
    80     pretty_text_area.resize(
    79       Font_Info.main(PIDE.options.real("jedit_font_scale") * zoom.factor / 100))
    81       Font_Info.main(PIDE.options.real("jedit_font_scale") * zoom.factor / 100))
    80   }
    82   }
   101   private val main =
   103   private val main =
   102     Session.Consumer[Session.Global_Options](getClass.getName) {
   104     Session.Consumer[Session.Global_Options](getClass.getName) {
   103       case _: Session.Global_Options => GUI_Thread.later { handle_resize() }
   105       case _: Session.Global_Options => GUI_Thread.later { handle_resize() }
   104     }
   106     }
   105 
   107 
   106   override def init(): Unit =
   108   override def init(): Unit = {
   107   {
       
   108     GUI.parent_window(this).map(_.addWindowFocusListener(window_focus_listener))
   109     GUI.parent_window(this).map(_.addWindowFocusListener(window_focus_listener))
   109     PIDE.session.global_options += main
   110     PIDE.session.global_options += main
   110     handle_resize()
   111     handle_resize()
   111   }
   112   }
   112 
   113 
   113   override def exit(): Unit =
   114   override def exit(): Unit = {
   114   {
       
   115     GUI.parent_window(this).map(_.removeWindowFocusListener(window_focus_listener))
   115     GUI.parent_window(this).map(_.removeWindowFocusListener(window_focus_listener))
   116     PIDE.session.global_options -= main
   116     PIDE.session.global_options -= main
   117     delay_resize.revoke()
   117     delay_resize.revoke()
   118   }
   118   }
   119 }
   119 }