comparison mercurial/crecord.py @ 51384: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
comparison
equal deleted inserted replaced
51383:880740426a34 51384:6fb4d2dfa8e4
1886 return True 1886 return True
1887 for header in item: 1887 for header in item:
1888 if header.hunks: 1888 if header.hunks:
1889 return False 1889 return False
1890 return True 1890 return True
1891
1892 def handlesearch(self):
1893 win = curses.newwin(1, self.xscreensize, self.yscreensize - 1, 0)
1894 win.echochar("/")
1895
1896 curses.echo()
1897 curses.curs_set(1)
1898 self.regex = win.getstr() or None
1899 curses.noecho()
1900 curses.curs_set(0)
1901
1902 if not self.showsearch(self.regex):
1903 self.printstring(
1904 win,
1905 _(b"Pattern not found (press ENTER)"),
1906 pairname=b"legend",
1907 align=False,
1908 )
1909 while win.getkey() not in ["\n", "KEY_ENTER"]:
1910 pass
1911 del win
1912
1913 self.stdscr.clear()
1914 self.stdscr.refresh()
1891 1915
1892 def showsearch(self, regex, forward=True): 1916 def showsearch(self, regex, forward=True):
1893 if not regex: 1917 if not regex:
1894 return 1918 return
1895 1919