changeset 51386:6fb4d2dfa8e4

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.
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Wed, 14 Feb 2024 22:50:00 -0500
parents 880740426a34
children 47c74c120205
files mercurial/crecord.py
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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