more ambitious mouse handler: double-click selects highlight_area;
authorwenzelm
Wed, 13 Nov 2024 15:14:48 +0100
changeset 81437 8d2d68c8c051
parent 81436 7436cdef0f14
child 81438 95c9af7483b1
more ambitious mouse handler: double-click selects highlight_area;
src/Tools/jEdit/src/rich_text_area.scala
--- a/src/Tools/jEdit/src/rich_text_area.scala	Wed Nov 13 14:54:08 2024 +0100
+++ b/src/Tools/jEdit/src/rich_text_area.scala	Wed Nov 13 15:14:48 2024 +0100
@@ -23,7 +23,7 @@
 import org.gjt.sp.util.Log
 import org.gjt.sp.jedit.View
 import org.gjt.sp.jedit.syntax.{Chunk => JEditChunk, SyntaxStyle}
-import org.gjt.sp.jedit.textarea.{TextAreaExtension, TextAreaPainter, TextArea}
+import org.gjt.sp.jedit.textarea.{TextAreaExtension, TextAreaPainter, TextArea, Selection}
 
 
 class Rich_Text_Area(
@@ -218,7 +218,8 @@
   private val mouse_listener = new MouseAdapter {
     override def mouseClicked(e: MouseEvent): Unit = {
       robust_body(()) {
-        if (e.getClickCount == 1) {
+        val clicks = e.getClickCount
+        if (clicks == 1) {
           hyperlink_area.info match {
             case Some(Text.Info(range, link)) =>
               if (!link.external) {
@@ -241,6 +242,15 @@
             case None =>
           }
         }
+        else if (clicks == 2) {
+          highlight_area.info match {
+            case Some(Text.Info(r, _)) =>
+              text_area.selectNone()
+              text_area.addToSelection(new Selection.Range(r.start, r.stop))
+              e.consume()
+            case None =>
+          }
+        }
       }
     }
   }