Re: Selecting a portion of text in editor pane

"Martin Půda (as mapuda at seznam dot cz)" <[email protected]>
Newsgroups gmane.lisp.lispworks.general
Message-ID <[email protected]>
Got it, I was able to reproduce that behaviour. Anyway, those are just some 
dummy points for testing, the important part is (setf (editor:variable-value
"Highlight Active Region" :buffer (capi:editor-pane-buffer my-editor)) t), 
so selected text is highlighted and reachable via capi:editor-pane-selected-
text. Replace select-some-text with this:




(defun select-some-text (editor-pane)

  (capi:apply-in-pane-process 

   editor-pane

   (lambda ()

     (let* ((buffer (capi:editor-pane-buffer editor-pane))

            (buffer-point (editor:buffer-point buffer))

            (start (editor:buffers-start buffer))

            (start-point (editor:copy-point start :temporary))

            (end-point (editor:copy-point start :temporary)))




       (editor:line-offset start-point 1 5)

       (editor:line-offset end-point 2 3)

         

       (editor:move-point buffer-point start-point)

       (editor:set-current-mark end-point)




       (print (capi:editor-pane-selected-text editor-pane))))))





But I noticed this: after calling select-some-text and pressing Delete, 
actual deleted area was between end-point and cursor... so maybe you will 
have to overwrite input-model for Delete to something like (editor:use-
buffer buffer

       (editor:delete-region-command nil)).


---------- Původní e-mail ----------
Od: Krupka Michal (as michal dot krupka at upol dot cz) <lisp-hug@lispworks.
com>
Komu: Martin Půda <[email protected]>
Kopie: [email protected] <[email protected]>
Datum: 22. 9. 2025 19:44:53
Předmět: Re: Selecting a portion of text in editor pane
"Well, if I break the test to parts like this: 

(setf my-editor (make-instance 'capi:editor-pane 
:text "This is the first line of text. 
This is the second line. 
And here is the third line. 
Finally, the fourth line of text." 
:visible-min-height 150 
:visible-min-width 400)) 

(capi:contain my-editor) 

(progn 
(setf (editor:variable-value "Highlight Active Region" :buffer (capi:editor-
pane-buffer my-editor)) t) 
(select-some-text my-editor)) 

then the last form doesn't always work for me. Just try to click to several 
places of text or select some parts of it and then evaluate the last form. 

Michal 

> 22. 9. 2025 v 10:37, Martin Půda (as mapuda at seznam dot cz) <lisp-hug@
lispworks.com>: 
> 
> Something like this? 
> 
> (defun select-some-text (editor-pane) 
> (capi:apply-in-pane-process 
> editor-pane 
> (lambda () 
> (let* ((buffer (capi:editor-pane-buffer editor-pane)) 
> (buffer-point (editor:buffer-point buffer)) 
> (start-point (editor:copy-point buffer-point :temporary)) 
> (end-point (editor:copy-point buffer-point :temporary))) 
> 
> (editor:line-offset start-point 1 5) 
> (editor:line-offset end-point 2 3) 
> (editor:move-point buffer-point start-point) 
> (editor:set-current-mark end-point) 
> 
> (print (capi:editor-pane-selected-text editor-pane)))))) 
> 
> (let ((my-editor (make-instance 'capi:editor-pane 
> :text "This is the first line of text. 
> This is the second line. 
> And here is the third line. 
> Finally, the fourth line of text." 
> :visible-min-height 150 
> :visible-min-width 400))) 
> (capi:contain my-editor) 
> (setf (editor:variable-value "Highlight Active Region" :buffer (capi:
editor-pane-buffer my-editor)) t) 
> (select-some-text my-editor)) 
> 
> 
> ---------- Původní e-mail ---------- 
> Od: Krupka Michal (as michal dot krupka at upol dot cz) <lisp-hug@
lispworks.com> 
> Komu: Lisp Hug Lispworks <[email protected]> 
> Datum: 21. 9. 2025 22:19:47 
> Předmět: Selecting a portion of text in editor pane 
> Hello, 
> 
> I need to select a part of text in capi:editor-pane given two buffer 
points. I tried this (inside a correct process) but it doesn't work 
correctly: 
> 
> (editor:use-buffer (capi:editor-pane-buffer my-pane) 
> (editor:move-point (editor:current-point) point-1) 
> (editor:set-current-mark point-2)) 
> 
> Any advice? Thanks. 
> 
> Michal 
> 
> _______________________________________________ 
> Lisp Hug - the mailing list for LispWorks users 
> [email protected] 
> http://www.lispworks.com/support/lisp-hug.html 


_______________________________________________ 
Lisp Hug - the mailing list for LispWorks users 
[email protected] 
http://www.lispworks.com/support/lisp-hug.html 
"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.