My previous mail was probably the most unnecessary one I've sent in... oh hell, a few days I guess. :(
So here is the actual thing, namely the patch with all-too-hackish implementation of the search using a standard text input box. It's not what one would call "production code" so don't expect anything fancy. "Briefly" (so to speak) put, what I've learnt so far is the following: - When processing keystrokes the editor is in one of several modes, including SEARCH_MODE and REPLACE_MODE. - This modes are used from the scheme side in what seem to be overloaded versions of the function keyboard-press, in file generic_edit.scm. - This overloading is achieved by means of tm-define which does some magic I've not looked into. - Each keyboard-press does first some resolving of command keys. - These are defined elsewhere using hashes and aliasing of names in order to be able to redefine modifier keys among other things, I guess. - Depending on what the resolved command does/returns, either a regular key press is emitted or a special member of some of the C++ classes inheriting editor is called. For instance, the relevant scheme code while in search mode is: (tm-define (keyboard-press key time) (:mode search-mode?) (with cmd (key-press-command (string-append "search " key)) (cond (cmd (cmd)) ((key-press-search key) (noop)) (else (key-press key))))) - Whereby key-press-search is a wrapper for editor_replace::search_keypress() (i.e. one of those "glued" scheme functions (see build_glue and glue_*.scm). - This latter method accepts a string which is sort of encoded as a message from scheme using plain ascii text. The c++ code speaks for itself. - The actual search is performed inside editor_replace::test(), which requires SEARCH_MODE to be on, I think. I haven't really looked into the search algorithm but it looks like breadth-first in the document tree, using a secondary stack to keep track of results and be able to reuse what's already been done (otherwise incremental search would really suck). So, about the patch: - Defines a new method edit_replace::search_string(string s), as well as the matching scheme "glue function" search-string. - What the former does is simply use what's already in place, i.e. enter search mode and push the string into the search "queue". - The problem is that search mode alters the way text is input to the editor: the overloaded scheme keyboard-press is used which in turn calls the special editor_rep::search_keypress() which does weird things. - Ideally, when using this non-incremental search I would like to have all non search related keystrokes (i.e. regular ones, not "search next", etc.) exit search mode and continue editing. The first naive attempts at this resulted in lost keystrokes or worse. I guess one could either define a new (input) mode (there are too many things called "mode" in TeXmacs), and write another overloaded keyboard-press which did things right, or change the current "interactive input mode" (see?) altogether to use standard text input and forget about all what I did. - Of course there might be other solutions, ideas or wishes. Hence, this email. - (BTW: in the patch there are some unrelated, non-harmful things I didn't bother to remove as well as a couple of hackish "bug fixes" which rather substitute random rare bugs for insidious persistent ones (text_language.cpp, tm_server.cpp, edit_interface.cpp), so apply carefully and at your own risk) Best, ________________ Miguel de Benito. On Tue, Jul 19, 2011 at 11:41, Miguel de Benito Delgado < m.debenit...@gmail.com> wrote: > Sure! I'll post a patch later this afternoon when I'm at home. Or I might > commit it to the svn repository if I isolate the changes properly before. > Thanks. > ___________________ > Miguel de Benito. >
search_patch-against-r4245.patch
Description: Binary data
_______________________________________________ Texmacs-dev mailing list Texmacs-dev@gnu.org https://lists.gnu.org/mailman/listinfo/texmacs-dev