crecord: add a handlesearch function
This function sets up some of the UI, such as getting the search
string from the user and displaying results or their absence.
--- a/mercurial/crecord.py Wed Feb 14 22:48:09 2024 -0500
+++ b/mercurial/crecord.py Wed Feb 14 22:50:00 2024 -0500
@@ -1889,6 +1889,30 @@
return False
return True
+ def handlesearch(self):
+ win = curses.newwin(1, self.xscreensize, self.yscreensize - 1, 0)
+ win.echochar("/")
+
+ curses.echo()
+ curses.curs_set(1)
+ self.regex = win.getstr() or None
+ curses.noecho()
+ curses.curs_set(0)
+
+ if not self.showsearch(self.regex):
+ self.printstring(
+ win,
+ _(b"Pattern not found (press ENTER)"),
+ pairname=b"legend",
+ align=False,
+ )
+ while win.getkey() not in ["\n", "KEY_ENTER"]:
+ pass
+ del win
+
+ self.stdscr.clear()
+ self.stdscr.refresh()
+
def showsearch(self, regex, forward=True):
if not regex:
return