changeset 51385:47c74c120205

crecord: add a searchdirection function If a regex has already been previously set, this function handles the UI elements of searching again forward or backward.
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Wed, 14 Feb 2024 22:53:58 -0500
parents 6fb4d2dfa8e4
children d0f6b96d1fb8
files mercurial/crecord.py
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/crecord.py	Wed Feb 14 22:50:00 2024 -0500
+++ b/mercurial/crecord.py	Wed Feb 14 22:53:58 2024 -0500
@@ -1939,6 +1939,20 @@
 
         return matches
 
+    def searchdirection(self, failuremsg, forward=True):
+        if not self.regex:
+            return
+
+        if not self.showsearch(self.regex, forward=forward):
+            win = curses.newwin(1, self.xscreensize, self.yscreensize - 1, 0)
+            self.printstring(win, failuremsg, pairname=b"legend", align=False)
+            while win.getkey() not in ["\n", "KEY_ENTER"]:
+                pass
+            del win
+
+            self.stdscr.clear()
+            self.stdscr.refresh()
+
     def handlekeypressed(self, keypressed, test=False):
         """
         Perform actions based on pressed keys.