src/Tools/jEdit/src/pretty_tooltip.scala
changeset 71601 97ccf48c2f0c
parent 67547 aefe7a7b330a
child 71704 b9a5eb0f3b43
equal deleted inserted replaced
71600:64aad1e46f98 71601:97ccf48c2f0c
   144       case _ =>
   144       case _ =>
   145     }
   145     }
   146   }
   146   }
   147 
   147 
   148   def dismiss_descendant(parent: JComponent): Unit =
   148   def dismiss_descendant(parent: JComponent): Unit =
   149     descendant(parent).foreach(dismiss(_))
   149     descendant(parent).foreach(dismiss)
   150 
   150 
   151   def dismissed_all(): Boolean =
   151   def dismissed_all(): Boolean =
   152   {
   152   {
   153     deactivate()
   153     deactivate()
   154     if (stack.isEmpty) false
   154     if (stack.isEmpty) false
   201   }
   201   }
   202 
   202 
   203 
   203 
   204   /* text area */
   204   /* text area */
   205 
   205 
   206   val pretty_text_area =
   206   val pretty_text_area: Pretty_Text_Area =
   207     new Pretty_Text_Area(view, () => Pretty_Tooltip.dismiss(tip), true) {
   207     new Pretty_Text_Area(view, () => Pretty_Tooltip.dismiss(tip), true) {
   208       override def get_background() = Some(rendering.tooltip_color)
   208       override def get_background() = Some(rendering.tooltip_color)
   209     }
   209     }
   210 
   210 
   211   pretty_text_area.addFocusListener(new FocusAdapter {
   211   pretty_text_area.addFocusListener(new FocusAdapter {
   260           ((w_max - geometry.deco_width) / metric.unit).toInt) max 20
   260           ((w_max - geometry.deco_width) / metric.unit).toInt) max 20
   261 
   261 
   262       val formatted = Pretty.formatted(info.info, margin = margin, metric = metric)
   262       val formatted = Pretty.formatted(info.info, margin = margin, metric = metric)
   263       val lines =
   263       val lines =
   264         XML.traverse_text(formatted)(if (XML.text_length(formatted) == 0) 0 else 1)(
   264         XML.traverse_text(formatted)(if (XML.text_length(formatted) == 0) 0 else 1)(
   265           (n: Int, s: String) => n + s.iterator.filter(_ == '\n').length)
   265           (n: Int, s: String) => n + s.iterator.count(_ == '\n'))
   266 
   266 
   267       val h = painter.getLineHeight * lines + geometry.deco_height
   267       val h = painter.getLineHeight * lines + geometry.deco_height
   268       val margin1 =
   268       val margin1 =
   269         if (h <= h_max)
   269         if (h <= h_max)
   270           (0.0 /: split_lines(XML.content(formatted)))({ case (m, line) => m max metric(line) })
   270           (0.0 /: split_lines(XML.content(formatted)))({ case (m, line) => m max metric(line) })