(defvar use-timeout 1)
(defvar start-text 0)
(defvar end-text 1)
(defvar draw-message "Hello world! This is the start and end test")
(defvar font)
(defun draw-hello (drawable g-context x y text &key start end)
(let ((draw-part (subseq text start end)))
(xlib:draw-glyphs drawable g-context x y draw-part )
)
)
thank you for your bug report.
the bug has been fixed in the CVS tree.
you can either wait for the next release (recommended)
or check out the current CVS tree (see http://clisp.cons.org\)
and build CLISP from the sources (be advised that between
releases the CVS tree is very unstable and may not even build
on your platform).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
fix general_draw_text behavior
thanks for the patch.
you are not testing whether the :start/:stop parameters are actually valid, aren't you?
I suppose that the :start and :end parameters are natural numbers.
They will be truncated quiet up to the string length.
That kind of other validity cheks will be suitable?
see test_vector_limits()
Attemt to use 'test_vector_limits'. Seems to work.
Somebody, look at my second patch, please.
looks good. now, we need a test case and the patch will be complete.
(require "clx")
(defvar use-timeout 1)
(defvar start-text 0)
(defvar end-text 1)
(defvar draw-message "Hello world! This is the start and end test")
(defvar font)
(defun draw-hello (drawable g-context x y text &key start end)
(let ((draw-part (subseq text start end)))
(xlib:draw-glyphs drawable g-context x y draw-part )
)
)
(defun events (&rest event-data &key display
event-key
send-event-p
window
&allow-other-keys)
(when (eq event-key :exposure)
(let ((gc (xlib:create-gcontext :drawable window :foreground 0 :font font)))
(draw-hello window gc 10 10 draw-message
:start start-text :end end-text)
(xlib:draw-glyphs window gc 10 30 draw-message
:start start-text :end end-text)
)
)
)
(let* ((dpy (xlib:open-display ""))
(top-win (xlib:create-window
:parent (xlib:screen-root (first (xlib:display-roots dpy) ))
:x 100 :y 100
:width 250
:height 250
:bit-gravity :north-west
:background 1617116666
:event-mask (xlib:MAKE-EVENT-MASK :exposure)))
(font (xlib:open-font dpy "fixed"))
)
(xlib:map-window top-win)
(xlib:display-force-output dpy)
(loop
(xlib:process-event dpy :handler #'events :timeout use-timeout :discard-p t)
(incf end-text)
(if (> end-text (length draw-message)) (setf end-text 1))
(xlib:clear-area top-win :exposures-p t)
)
)
thanks - next time please supply the test case in a form suitable for new-clx/test.tst
as indicated by this test, your patch does not work:
(xlib:with-open-display (dpy)
(let* ((top-win (xlib:create-window
:parent (xlib:screen-root (first (xlib:display-roots dpy)))
:x 300 :y 300 :width 300 :height 70
:bit-gravity :north-west :background 1617116666
:event-mask (xlib:make-event-mask :exposure)))
(font (xlib:open-font dpy "fixed"))
(timeout 0.1) (start 0) (end 1)
(message "these three lines should grow together in sync")
(m1 (make-array (length message) :element-type 'character
:displaced-to (ext:string-concat #1="abazonk" message)
:displaced-index-offset (length #1#))))
(assert (string= message m1))
(flet ((events (&rest event-data
&key display event-key send-event-p window
&allow-other-keys)
(when (eq event-key :exposure)
(let ((gc (xlib:create-gcontext
:drawable window :foreground 0 :font font)))
(xlib:draw-glyphs window gc 10 10
(subseq message start end))
(xlib:draw-glyphs window gc 10 30
message :start start :end end)
(xlib:draw-glyphs window gc 10 30
m1 :start start :end end)
))))
(xlib:map-window top-win)
(xlib:display-force-output dpy)
(loop
(xlib:process-event dpy :handler #'events :timeout timeout :discard-p t)
(incf end)
(if (> end (length message)) (return))
(xlib:clear-area top-win :exposures-p t)))))
in fact, there is more bad :START/:END code in clx.f, I will fix it in a uniform way.
thank you for your bug report.
the bug has been fixed in the CVS tree.
you can either wait for the next release (recommended)
or check out the current CVS tree (see http://clisp.cons.org\)
and build CLISP from the sources (be advised that between
releases the CVS tree is very unstable and may not even build
on your platform).
The displased arrays it's an other history. It's too deep for me, now.
please test cvs head.
thanks for your report and the excellent test case.
IMHO timeout = 0.1 secs it's too quickly, for understanding something I changed it to 0,5.