[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

come changes to the deuce editor gadget



I've embedded the deuce editor (from FunO) in an application that I
have and have found an issue or error with the "find-string"
functionality.

In the "find-next-or-previous-string" function, if the search string
is not found, it generates a <command-error> stating something like
"string not found".  The problem is that the "string-search-dialog"
function does not handle this error, so all kinds of interesting
runtime errors get created.

As a solution (temmporary or not based upon an feedback from this
forum), I modified the "string-search-dialog" to wrap the call to
"find-next-or-previous-string" in a block and catch any
<command-error>s and then notify the user that the string wasn't
found.

As I had users waiting (impatiently) for the fix, I just caught the
error and called "notify-user" with a string.  I couldn't remember how
to just notify the user of the formated error message.

A question that comes to mind is; is this the proper place to catch
the <command-error> or should it be done further out (i.e. in the
gadget).

Several approachs come to mind;
(1) just catch the <command-error> like I did and report to the user.
(2) catch the <command-error>s further out, notify the user, and
re-start.
(3) even cleverer approaches ...

Anyway, my fix works for me right now.  Here's a code snippet from
inside "string-search-dialog" method:

=====================================================
    :
    let next-button
      = make(<push-button>,
	     label: "&Find Next",
	     activate-callback:
	       method (b)
		 ignore(b);
		 with-editor-state-bound (window)
                   block()
                     find-next-or-previous-string(frame);
                   exception(e :: <command-error>)
                     notify-user("string not found");
                   end block;
		   redisplay-window(window)
		 end
	       end method);
    :
=====================================================

Ron Franke-Polz
ronaldfp@nc.rr.com