<br><br><div><span class="gmail_quote">On 5/20/06, <b class="gmail_sendername">Frank Goenninger</b> <<a href="mailto:fgoenninger@prion.de">fgoenninger@prion.de</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Am 20.05.2006 um 20:16 schrieb Frank Goenninger:<br><br>> Am 20.05.2006 um 18:24 schrieb Ken Tilton:<br>><br>>> Frank Goenninger wrote:<br>>><br>>>> Hi Kenny, hi all:<br>>>><br>>>> I do have a text widget which is created using mk-text-widget:
<br>>>><br>>>> (mk-text-widget :id :receive-window<br>>>> :state 'disabled<br>>>> :md-value (c?n "...")<br>>>> :height 10
<br>>>> :width 80<br>>>> :borderwidth 2<br>>>> :relief 'sunken<br>>>> :pady 5))<br>>>><br>>>> No matter what I do (even setting :state to 'enabled) I do get
<br>>>> anything printed in the text widget.<br>>>><br>>>> I actually execute a setf on md-value of the text widget:<br>>>><br>>>> (setf (md-value (fm-other :receive-window)) data)
<br>>>><br>>>><br>>>> Any idea? Thx!<br>>><br>>><br>>> Hmmm, looks like I did not finish implementing text widgets.<br>><br>> Yep, meanwhile I recognized that an observer is missing in file
<br>> entry.lisp.<br><br>Well, actually I had to do (in file entry.lisp):<br><br>;; Method CLEAR: clears a text widget to zero content<br><br>(defmethod clear ((self text-widget))<br> (tk-format `(:variable ,self) "~a delete
1.0 end" (^path)))<br><br>;; This observer puts text to the widget if md-value has been set<br>;; Also takes care of edge cases like initialization time and setting<br>;; strings of length 0...<br><br>(defobserver .md-value ((self text-widget))
<br> (trc "md-value output" self new-value)<br> (if (or (and (not old-value)<br> (string= new-value ""))<br> (not new-value))<br> (tk-format `(:variable ,self) "~a delete
1.0 end" (^path))<br> (if (> (length new-value) 0)<br> (tk-format `(:variable ,self) "~a insert end ~a" (^path) new-<br>value))))</blockquote><div><br>I took your stuff and whittled it down to:
<br><br>(defobserver .md-value ((self text-widget))<br> (trc "md-value output" self new-value)<br> (with-integrity (:client `(:variable ,self))<br> (tk-format-now "~a delete 1.0 end" (^path))<br> (when (plusp (length new-value))
<br> (tk-format-now "~a insert end ~s" (^path) new-value))))<br><br>That way two (setf (md-value self) "Hi mom") calls do not produce "Hi momHi mom".<br><br>I was not sure the API entry point CLEAR was needed elsewhere. I can see that it would be, though. Really, the more I look at the text widget the more I think it needs imperative processing by application code that has a clear idea of what it wants to do with all the capabilities of the widget.
<br><br>I also brought both commands within the same integrity bundle by skipping the tk-format syntactic sugar and open-coding with-integrity. That just saves one enqueue, no big deal. A bigger deal is that the sort done by tk-user-queue-handler was not (until just now <g>) a stable sort, so the delete could have been executed after the insert. Bringing both operations into the single integrity bundle also fixes that.
<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br><br>Now, whenever I do a<br><br>$ echo "Heya this is a test" > /Users/frgo/tmp/frgo-test
<br><br>the text gets displayed in the window.</blockquote><div><br>Isn't great when we get stuff like that working? Is there a universal law: any time the effect produced by your own code surprises you, you are probably onto something good. Programming never gets old.
<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>Fileevent to be put to Celtk CVS in a few days ... watch out.</blockquote>
<div><br>Thx. I am switching all my code to LLGPL now, btw. I think we settled on that for your stuff, yes?<br><br>kt<br><br></div></div>