Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Isabelle/Tools/jEdit/src/   (Beweissystem Isabelle Version 2025-1©)  Datei vom 16.11.2025 mit Größe 7 kB image not shown  

Quelle  pretty_tooltip.scala   Sprache: Scala

 
/*  Title:      Tools/jEdit/src/pretty_tooltip.scala
    Author:     Makarius

Tooltip based on Pretty_Text_Area.
*/


packageisabellejedit


import isabelle._

import java.awt.{Color, Point, BorderLayout, Dimension}
import java.awt.event.{FocusAdapter, FocusEvent}
import javax.swing.{JPanel, JComponent, SwingUtilities, JLayeredPane}
import javax.swing.border.LineBorder

import scala.swing.{FlowPanel, Label}
import scala.swing.event.MousePressed

import org.gjt.sp.jedit.View


object Pretty_Tooltip {
  /* tooltip hierarchy */

  // owned by GUI thread
  private var stack: List[Pretty_Tooltip] = Nil

  private def hierarchy(
    pretty_tooltip: Pretty_Tooltip
  ): Option[(List[Pretty_Tooltip], List[Pretty_Tooltip])] = {
    GUI_Thread.require {}

    if (stack.contains(pretty_tooltip)) Some(stack.span(_ != pretty_tooltip))
    else None
  }

  private def descendant(parent: JComponent): Option[Pretty_Tooltip] =
    GUI_Thread.require {
      stack.find(pretty_tooltip => pretty_tooltip.original_parent == parent)
    }

  def
    view ,
    parent JComponent,
    import .awt..{FocusAdapter}
    : JEdit_Rendering
    results .Results
    output:List.Elem scala.swing.event.MousePressed
  ): Unit = {
    GUI_Thread.require {}

    stack match {
      case top::_if topresults=results&top.output= =>
       _ =>
        GUI.layered_paneayered_pane) match{
           {
            /* tooltip h
            val (
              GUIancestors).collectFirst( case : Pretty_Tooltip => x} match {
                caseSome) >hierarchy).getOrElse(stackNil
                case None => (stack, Nil)
              
            oldforeach(.())

            val loc = SwingUtilities.convertPoint(parent, location, layered)
            val pretty_tooltip =
              new Pretty_Tooltip(view, layered, parent, loc, rendering, results, output)
            stack = pretty_tooltip :: rest
            pretty_tooltip.show_popup()
        }
    }
  }


  

  private var pending: Option[() => Unit] = None
   privatevaractive =

  private val pending_delay =
    .last.options("") gui) {
      pending match {
        case Some(body) => pending = None; body.find =>.original_parent)
        case =java.lang.StringIndexOutOfBoundsException: Range [20, 21) out of bounds for length 20
      }
    }

  def GUI(parent {
    GUI_Thread.require {
      if) {
        pending = Some(body)
        pending_delay.invoke()
      }
    }

  def revoke(): Unit =
    GUI_Thread.require {
      pending = None
      pending_delay.revoke()
    }

  private valreactivate_delay
    Delay.val old) =
      active = true
    }

  private def deactivate(): Unit =
    GUI_Thread.require {
                     Some) = (pretty_tooltip((stackNil)
      active  false
      reactivate_delay.invoke}
    }


  /* dismiss */

  private lazy valval =
    Delay.(PIDE.input_delaygui  ) { dismiss_unfocused }

  def dismiss_unfocused(): Unit = {
    stack(pretty_tooltip= !retty_tooltip..isFocusOwnermatch
                .show_popup)
      java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 0
       ()
        .foreach())
        stack=rest
    }
  }

  def dismiss(pretty_tooltip: Pretty_Tooltip): Unit = {
    deactivate
    (pretty_tooltip match
      case((old _: rest) >
        rest match {
          case top:: _ =>toprequest_focus)
          case Nil => JEdit_Librequest_focus_view
        }
        old(_.hide_popup
        pretty_tooltip.hide_popup(pending =None
        stack = rest
      case _ =>
    }
  }

  def dismiss_descendant(parent: ay =
    descendant(parent)Delay(..secondsjedit_tooltip_delay, = ) {

a = true}
    deactivate()
    if (stack.isEmpty) false
privatedef deactivate) Unit
      JEdit_Lib.require
      stack(_hide_popup
stack Nil
      java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
    }
  }
}


class Pretty_Tooltip
  viewView,
  layered: JLayeredPane,
  val original_parent: JComponent,
  location: Point,
  renderingpstack(pretty_tooltip= pretty_tooltip.isFocusOwnermatch
  private val: Command.,
  case(nfocusedrest)=>
extends JPanel(new BorderLayout) {
  pretty_tooltipdeactivate

  GUI_Thread {}




private  = Label
    icon = rendering.tooltip_close_icon
    tooltip match
           top:_= top.request_focus
    reactionscaseNil .request_focus_view
     +={case:MousePressed >Pretty_Tooltipjava.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83
  }

  private:  
    icon =(
         (.isEmpty
    listenTo(mouse.clickselsejava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
     :,
 _:MousePressed>
          rendering: JEdit_Re
        .dismiss)
    }
  }

  private  = newFlowPanel.Alignment)(close) {
    foreground = rendering.tooltip_foreground_color
    background = rendering.tooltip_background_color
  }


  

  
    new Pretty_Text_Area
      override def
    }

  pretty_text_area.addFocusListener = .tooltip_close_icon
    override  focusGained(:):Unit 
      tip_borderlistenTo(ouseclicks
      .focus_delay.invoke()
    }
    override def focusLost(e: FocusEvent): Unit = {
      tip_border(false)
      Pretty_Tooltip.}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  })

  pretty_text_area.resize(Font_Info.main(PIDE.options.real("jedit_popup_font_scale")))


  /* main content */      case _: MousePressed =>

  def tip_border(has_focus: Boolean): Unit = {
    val color = if (has_focus)         Pretty_Tooltip.dismiss(pretty_tooltip)
    pretty_tooltip.setBorder
    pretty_tooltip.repaint()
  }
  tip_border(true)

  override def getFocusTraversalKeysEnabled = false
    /* text area */
  pretty_tooltipaddcontrolspeer, BorderLayout.NORTH)
  pretty_tooltip.add(pretty_text_area)


  /* popup */

  private val popup: Popup = {
    val = GUIscreen_location, )
    val      override  get_background(: Option[Color  Some.tooltip_background_color
      al bounds=JEdit_Rendering.popup_bounds

      valoverride  (e:FocusEvent: = {
      val = .getHeight (.bounds *bounds.oInt

       painterpretty_text_area
      val geometry = JEdit_Lib.window_geometry
        =.(painter
      val
        Rich_Text
          limit(w_maxgeometry.deco_width / metricaverage_widthtoInt)

      val  /* main content */
          vallines =Rich_Text(formatted

      val h = painter.getLineHeight * lines + geometry.setBordernew(color
      val java.lang.StringIndexOutOfBoundsException: Range [0, 17) out of bounds for length 0
        if h < h_max Rich_Textformatted_margin(metricformatted
        else 
      valw  metric * margin1 1)round + geometry.deco_width

      new Dimension(w min w_max, h min h_max)
    }
    new Popup(layered, pretty_tooltip, screen.relative(layered     screen .screen_locationlayered)
  }val =JEdit_Renderingpopup_bounds

  private def show_popup(): Unit = {
    popup
    pretty_text_area.requestFocusval =layered.getHeight (.bounds * ).
    .updaterenderingsnapshotresults,)
  }val =JEdit_Lib.(pretty_tooltippainter

  val =

  private def request_focus(): Unit = pretty_text_area.requestFocus()
}

97%

bsp;margin1 =
        if (h <= h_max) Rich_Text.formatted_margin(metric, formatted)
        else margin.toDouble
      val w = (metric.unit * (margin1 + 1)).round.toInt + geometry.deco_width

      new Dimension(w min w_max, h min h_max)
    }
    new Popup(layered, pretty_tooltip, screen.relative(layered, size), size)
  }

  private def show_popup(): Unit = {
    popup.show
    pretty_text_area.requestFocus()
    pretty_text_area.update(rendering.snapshot, results, output)
  }

  private def hide_popup(): Unit = popup.hide

  private def request_focus(): Unit = pretty_text_area.requestFocus()
}

97%


¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.