crecord: add a handlesearch function
authorJordi Gutiérrez Hermoso <jordigh@octave.org>
Wed, 14 Feb 2024 22:50:00 -0500
changeset 51386 6fb4d2dfa8e4
parent 51385 880740426a34
child 51387 47c74c120205
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.
mercurial/crecord.py
--- 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