Author terry.reedy
Recipients BreamoreBoy, roger.serwy, terry.reedy
Date 2014-08-16.01:33:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1408152811.08.0.0859126034495.issue22179@psf.upfronthosting.co.za>
In-reply-to
Content
The focus *should* stay on the dialog, #17511, but the found text should be highlighted with the 'found' highlight, as it is for Replace in Editor (but not Output) windows.  The issue is that found text on Windows is not hightlighted in any way.  It apparently is on other platforms, though I am not sure which way (but probably as 'selected' rather than 'found').  Hence the title change.

There must be some difference between the Find Next code in Search dialog and the Find code in Replace. The relevant code for Find Next is SearchDialog.SearchDialog.find_again, after 'if res:' (if pattern found). The corresponding code in Find is ReplaceDialog.ReplaceDialog.do_find after the 'if not res:' block.

I believe I found the crucial difference. Do_find is similar to find_again except for putting the tag and show code in a separate .show_hit method.  Show_hit has code to clear and then set a 'hit' tag. The hit tag is associated with the hit (found) highlight in ColorDelegator.LoadTagDefs and config_colors.
            # The following is used by ReplaceDialog:
            "hit": idleConf.GetHighlight(theme, "hit"),
and          self.tag_configure(tag, **cnf)

The fix is to use 'hit' in SearchDialog also. I believe the show_hit slightly modified could be moved to SearchDialogBase and used in find_again.

For output windows, Search is active but ColorDelegator is not. ColorDelegator does not use 'hit'. The tag_configure for 'hit' can and should be moved to SearchDialogBase.  (I either have or will moved 'break' confiuration away.)

A note on selection highlighting. When Debugger is running with [x]Source, source lines are marked with the 'selected; highlight. Debugger.Debugger.show_source calls Debugger.sync_source_line which calls self.flist.gotofileline(filename, lineno) which selects the line in the file.

In msg186609 of #17511, which was about keeping the dialog open after Find Next, Roger claimed that the patch for #14146, which was about highlighting source (as selected) when debugger is open, would also fix highlighting found source when Find is open. The patch, b56ae3f878cb (for 3.4) adds a Windows-specific "def _highlight_workaround(self)" to EditorWindow. But is does not cause select highlighting in either Search or Replace windows. I believe it works for Debugger because gotofileline temporarily changes focus to the editor window containing the file, raising it to the top, before focus shifts back to Debugger, putting it back on top of the editor (usually) if there is overlap. The highlight workaround highlights the sel_fix tag (a substitute for sel) as focus leaves the editor. 

To mark found text with the 'selected' highlight, we would have to shift focus temporarily to the editor by some other means. But 1. the 'experimental' debugger is temperamental and sometimes freezes Idle, and I don't know if the focus shifting has anything to do with that; 2. I think consistently using the 'found' highlight for both search dialog is better anyway.
History
Date User Action Args
2014-08-16 01:33:31terry.reedysetrecipients: + terry.reedy, roger.serwy, BreamoreBoy
2014-08-16 01:33:31terry.reedysetmessageid: <1408152811.08.0.0859126034495.issue22179@psf.upfronthosting.co.za>
2014-08-16 01:33:31terry.reedylinkissue22179 messages
2014-08-16 01:33:29terry.reedycreate