Skip to content

Commit 65995c1

Browse files
committed
Show version number, color mode and character mode in new help screen
1 parent 2aab483 commit 65995c1

File tree

2 files changed

+44
-10
lines changed

2 files changed

+44
-10
lines changed

durdraw/durdraw_movie.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,39 @@ def shrinkCanvasWidth(self, shrinkage):
187187
self.opts.sizeY = self.opts.sizeY - shrinkage
188188
#self.width = self.width - shrinkage
189189

190+
def search_and_replace(self, caller, search_str: str, replace_str: str):
191+
#search_list = list(search)
192+
found = False
193+
194+
# pad the right side of replace_str with spaces, so it lines up
195+
# if search_str is longer.
196+
#caller.notify(f"search string: '{search_str}'")
197+
#replace_str = replace_str.ljust(len(search_str), ' ')
198+
#caller.notify(f"replace string: '{replace_str}'")
199+
frame_num = 0
200+
line_num = 0
201+
for frame in self.frames:
202+
line_num = 0
203+
for line in frame.content:
204+
line_str = ''.join(line)
205+
#caller.notify(f"line is a type: {type(line)}")
206+
#caller.notify(f"line is: {line}")
207+
if search_str in line_str:
208+
#caller.notify(f"len(search_str): {len(search_str)}, len(replace_str): {len(replace_str)}")
209+
if len(search_str) < len(replace_str):
210+
line_str = line_str.replace(search_str.ljust(len(replace_str)), replace_str)
211+
else:
212+
line_str = line_str.replace(search_str, replace_str.ljust(len(search_str)))
213+
#caller.notify(f"found {search_str} in line:")
214+
#caller.notify(f"{line_str}")
215+
# inject modified line back into frame
216+
line = list(line_str)
217+
frame.content[line_num] = line
218+
found = True
219+
line_num += 1
220+
frame_num += 1
221+
return found
222+
190223
def contains_high_colors(self):
191224
""" Returns True if any color above 16 is used, False otherwise """
192225
for frame in self.frames:

durdraw/durdraw_ui_curses.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -664,26 +664,27 @@ def showScrollingHelpScreen(self):
664664
helpMov.gotoFrame(1)
665665
self.stdscr.clear()
666666
self.clearStatusLine()
667-
self.promptPrint("* Press the any key (or click) to continue *")
667+
#self.promptPrint("* Press the any key (or click) to continue *")
668668
clickColor = self.appState.theme['clickColor']
669669
promptColor = self.appState.theme['promptColor']
670-
self.addstr(self.statusBarLineNum - 1, 0, "You can use ALT or META instead of ESC. Everything this color is clickable", curses.color_pair(promptColor))
671-
self.addstr(self.statusBarLineNum - 1, 51, "this color", curses.color_pair(clickColor) | curses.A_BOLD)
672-
self.addstr(self.statusBarLineNum - 1, 65, "clickable", curses.color_pair(clickColor) | curses.A_BOLD)
670+
#self.addstr(self.statusBarLineNum - 1, 0, "You can use ALT or META instead of ESC. Everything this color is clickable", curses.color_pair(promptColor))
671+
#self.addstr(self.statusBarLineNum - 1, 51, "this color", curses.color_pair(clickColor) | curses.A_BOLD)
672+
#self.addstr(self.statusBarLineNum - 1, 65, "clickable", curses.color_pair(clickColor) | curses.A_BOLD)
673+
674+
helpMov.search_and_replace(self, '{ver}', f"{self.appState.durVer}")
675+
helpMov.search_and_replace(self, '{colormode}', f"{self.appState.colorMode}")
676+
helpMov.search_and_replace(self, "{charmode}", f"{self.appState.charEncoding}")
677+
673678
while self.playingHelpScreen:
674679
self.move(self.xy[0], self.xy[1])
675680
self.refresh()
681+
self.addstr(self.statusBarLineNum + 1, 0, "Up/Down, Pgup/Pgdown, Home/End or Mouse Wheel to scroll. Enter or Esc to exit.", curses.color_pair(promptColor))
682+
#self.addstr(self.statusBarLineNum - 1, 51, "this color", curses.color_pair(clickColor) | curses.A_BOLD)
676683
mouseState = False
677-
# Instead, search and replace the darwing for durVer, colorMode etc
678-
#if page == 2:
679-
# self.addstr(12, 51, f"{self.appState.durVer}", curses.color_pair(promptColor))
680-
# self.addstr(13, 54, f"{self.appState.colorMode}", curses.color_pair(promptColor))
681-
# self.addstr(14, 62, f"{self.appState.charEncoding}", curses.color_pair(promptColor))
682684
c = self.stdscr.getch()
683685
if c == curses.KEY_MOUSE: # get some mouse input if available
684686
try:
685687
_, mouseX, mouseY, _, mouseState = curses.getmouse()
686-
#pdb.set_trace()
687688
except:
688689
pass
689690

0 commit comments

Comments
 (0)