From 26a3775d24a00153f566ef6263fd00f4b87bb204 Mon Sep 17 00:00:00 2001
From: Andreas Fuchs <afuchs@franz.com>
Date: Mon, 18 Apr 2011 14:04:43 -0700
Subject: [PATCH] spr38038: Allow setting point in motif text boxes

The windows version of clim has long had a method called
silica::set-selection (not exported or documented), that lets users
set selection / point position in text entry fields and text edit
boxes. Add this method for Motif as well.

Are there user visible changes in this commit?  no
Is bootstrapping needed?                        no
Are tests included for new features?  Possible answers:
   no tests for new features
Tests run:  tested manually by customer

Change-Id: I0679f4f653fb4d799f4ba63c105dcffbe8f56ee9
---
 tk-silica/xm-gadgets.lisp | 7 +++++++
 tk/xm-funs.lisp           | 9 +++++++++
 2 files changed, 16 insertions(+)

diff --git a/tk-silica/xm-gadgets.lisp b/tk-silica/xm-gadgets.lisp
index 977db018..f1435017 100644
--- a/tk-silica/xm-gadgets.lisp
+++ b/tk-silica/xm-gadgets.lisp
@@ -1020,6 +1020,13 @@
 	   (and (not (zerop x))
 		(values (excl:native-to-string x)))))))
 
+(defmethod silica::set-selection ((tf motif-text-editor) startpos endpos)
+  (let ((m (sheet-direct-mirror tf)))
+    (when m
+      (let* ((display (port-display (port tf)))
+             (time (tk::xt-last-timestamp-processed display)))
+        (tk::xm_text_set_selection m startpos endpos time)))))
+
 (defmethod compose-space ((te motif-text-editor) &key width height)
   (declare (ignore width height))
   (make-space-requirement :width (process-width-specification te`(,(gadget-columns te) :character))
diff --git a/tk/xm-funs.lisp b/tk/xm-funs.lisp
index 08598736..c6ed5539 100644
--- a/tk/xm-funs.lisp
+++ b/tk/xm-funs.lisp
@@ -244,6 +244,15 @@
   :call-direct t
   :arg-checking nil)
 
+(def-foreign-call (xm_text_set_selection "XmTextSetSelection")
+    ((x :foreign-address)
+     (first :long)
+     (last :long)
+     (time :foreign-address))
+  :returning :void
+  :call-direct t
+  :arg-checking nil)
+
 (def-foreign-call (xm_scale_set_value "XmScaleSetValue")
     ((x :foreign-address) (y :int fixnum))
   :returning :void
-- 
GitLab