Skip to content

Commit 241150b

Browse files
authored
Merge pull request #21 from cmang/dev
Merging dev changes into minor release 0.24.1
2 parents f7c9446 + 1e5d917 commit 241150b

File tree

7 files changed

+79
-29
lines changed

7 files changed

+79
-29
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Durdraw
55
_| |__ __ _____ __| |_____ _____ __ __ __
66
/ _ | | | __| _ | __| _ | | | |\
77
/_____|_____|__|__|_____|__|___\____|________| |
8-
\_____________________________________________\| v 0.24.0
8+
\_____________________________________________\| v 0.24.1
99

1010

1111
![durdraw-0 24 0-example](./assets/durdraw-0.24.0-example.gif)
@@ -353,6 +353,8 @@ Home page: http://durdraw.org
353353

354354
Development: https://github.com/cmang/durdraw
355355

356+
ANSI and ASCII artists: cmang, H7, LDA
357+
356358
### LEGAL
357359

358360
Durdraw is Copyright (c) 2009-2023 Sam Foster <samfoster@gmail.com>. All rights reserved.

durdraw/durdraw_movie.py

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -203,25 +203,31 @@ def shrinkCanvasWidth(self, shrinkage):
203203
self.opts.sizeY = self.opts.sizeY - shrinkage
204204
#self.width = self.width - shrinkage
205205

206+
def search_and_replace_color(self, old_color :int, new_color :int):
207+
found = False
208+
for frame in self.frames:
209+
line_num = 0
210+
for line in frame.newColorMap:
211+
for pair in line:
212+
if pair[0] == old_color:
213+
frame.newColorMap[line_num][0] = new_color
214+
found = True
215+
if pair[1] == old_color:
216+
frame.newColorMap[line_num][1] = new_color
217+
found = True
218+
line_num += 1
219+
206220
def search_and_replace(self, caller, search_str: str, replace_str: str):
207221
#search_list = list(search)
208222
found = False
209223

210-
# pad the right side of replace_str with spaces, so it lines up
211-
# if search_str is longer.
212-
#caller.notify(f"search string: '{search_str}'")
213-
#replace_str = replace_str.ljust(len(search_str), ' ')
214-
#caller.notify(f"replace string: '{replace_str}'")
215224
frame_num = 0
216225
line_num = 0
217226
for frame in self.frames:
218227
line_num = 0
219228
for line in frame.content:
220229
line_str = ''.join(line)
221-
#caller.notify(f"line is a type: {type(line)}")
222-
#caller.notify(f"line is: {line}")
223230
if search_str in line_str:
224-
#caller.notify(f"len(search_str): {len(search_str)}, len(replace_str): {len(replace_str)}")
225231
if len(search_str) < len(replace_str):
226232
line_str = line_str.replace(search_str.ljust(len(replace_str)), replace_str)
227233
else:
@@ -236,6 +242,26 @@ def search_and_replace(self, caller, search_str: str, replace_str: str):
236242
frame_num += 1
237243
return found
238244

245+
246+
def search_for_string(self, search_str: str, caller=None):
247+
#search_list = list(search)
248+
found = False
249+
frame_num = 0
250+
line_num = 0
251+
for frame in self.frames:
252+
line_num = 0
253+
for line in frame.content:
254+
line_str = ''.join(line)
255+
if search_str in line_str:
256+
column_num = line_str.index(search_str) + 1
257+
frame_num += 1
258+
found = True
259+
return {"line": line_num, "col": column_num, "frame": frame_num}
260+
line_num += 1
261+
frame_num += 1
262+
return found # should be false if execution reaches this point
263+
264+
239265
def change_palette_16_to_256(self):
240266
# Convert from blue to bright white by reducing their value by 1
241267
for frame in self.frames:
@@ -319,20 +345,6 @@ def change_palette_256_to_16(self):
319345
col_num += 1
320346

321347

322-
def search_and_replace_color(self, old_color :int, new_color :int):
323-
found = False
324-
for frame in self.frames:
325-
line_num = 0
326-
for line in frame.newColorMap:
327-
for pair in line:
328-
if pair[0] == old_color:
329-
frame.newColorMap[line_num][0] = new_color
330-
found = True
331-
if pair[1] == old_color:
332-
frame.newColorMap[line_num][1] = new_color
333-
found = True
334-
line_num += 1
335-
336348
def contains_high_colors(self):
337349
""" Returns True if any color above 16 is used, False otherwise """
338350
for frame in self.frames:

durdraw/durdraw_ui_curses.py

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def __init__(self, app):
101101
else:
102102
for button in self.statusBar.buttons:
103103
self.gui.add_button(button)
104-
self.setWindowTitle("Durdraw")
104+
#self.setWindowTitle("Durdraw")
105105

106106
# set a default drawing character
107107
self.appState.drawChar = chr(self.chMap['f4'])
@@ -187,6 +187,7 @@ def enableTransBackground(self):
187187
def setWindowTitle(self, title):
188188
title = f"Durdraw - {title}"
189189
sys.stdout.write(f"\x1b]2;{title}\x07")
190+
sys.stdout.flush()
190191

191192
def getPlaybackRange(self):
192193
""" ask for playback range presses cmd-r """
@@ -590,6 +591,27 @@ def clearCanvas(self, prompting = False):
590591
self.move_cursor_topleft()
591592
self.hardRefresh()
592593

594+
def searchForStringPrompt(self):
595+
self.stdscr.nodelay(0) # wait for input when calling getch
596+
self.promptPrint("Enter string to search: ")
597+
curses.echo()
598+
search_string = self.stdscr.getstr().decode('utf-8')
599+
curses.noecho()
600+
601+
search_result = self.mov.search_for_string(search_string)
602+
if search_result == False:
603+
self.notify("No results found.")
604+
else:
605+
line = search_result["line"]
606+
column = search_result["col"]
607+
frame_num = search_result["frame"]
608+
self.mov.gotoFrame(frame_num)
609+
self.move_cursor_to_line_and_column(line, column)
610+
611+
if self.playing:
612+
elf.stdscr.nodelay(1)
613+
614+
593615
def showCharInspector(self):
594616
line = self.xy[0]
595617
col = self.xy[1] - 1
@@ -920,6 +942,7 @@ def startPlaying(self):
920942
self.appState.sideBarShowing = False
921943
self.statusBar.hide()
922944
self.cursorOff()
945+
self.setWindowTitle(self.appState.curOpenFileName)
923946
self.playing = True
924947
self.metaKey = 0
925948
if self.appState.playOnlyMode:
@@ -1405,6 +1428,10 @@ def resizeHandler(self):
14051428
def drawStatusBar(self):
14061429
if self.statusBar.hidden:
14071430
return False
1431+
1432+
1433+
self.setWindowTitle(self.appState.curOpenFileName)
1434+
14081435
mainColor = self.appState.theme['mainColor']
14091436
clickColor = self.appState.theme['clickColor']
14101437

@@ -1794,6 +1821,8 @@ def mainLoop(self):
17941821
self.clickedUndo()
17951822
elif c == 114: # alt-r = redo
17961823
self.clickedRedo()
1824+
elif c == ord('F'): # alt-F, find/search
1825+
self.searchForStringPrompt()
17971826
elif c == 118: # alt-v - paste
17981827
# Paste from the clipboard
17991828
if self.clipBoard: # If there is something in the clipboard
@@ -2131,6 +2160,8 @@ def enterViewMode(self):
21312160
oldDrawBorders = self.appState.drawBorders # to turn back on when done
21322161
self.appState.playOnlyMode = True
21332162
self.startPlaying()
2163+
2164+
# Return to normal when done
21342165
self.appState.playOnlyMode = False
21352166
self.appState.topLine = old_top_line
21362167
self.statusBar.show()
@@ -2213,6 +2244,10 @@ def move_cursor_home(self):
22132244
def move_cursor_end(self):
22142245
self.xy[1] = self.mov.sizeX
22152246

2247+
def move_cursor_to_line_and_column(self, line, col):
2248+
self.xy[0] = line
2249+
self.xy[1] = col
2250+
22162251
def getDelayValue(self):
22172252
""" Ask the user for the delay value to set for current frame, then
22182253
set it """
@@ -3213,7 +3248,7 @@ def loadFromFile(self, shortfile, loadFormat): # shortfile = non full path file
32133248
if self.appState.debug: self.notify(f"Finished loading JSON dur file")
32143249
self.appState.curOpenFileName = os.path.basename(filename)
32153250
self.appState.modified = False
3216-
self.setWindowTitle(shortfile)
3251+
#self.setWindowTitle(shortfile)
32173252
self.convertToCurrentFormat(fileColorMode = fileColorMode)
32183253

32193254
# Convert palettes as necessary
@@ -3272,7 +3307,7 @@ def loadFromFile(self, shortfile, loadFormat): # shortfile = non full path file
32723307
if loadFormat == 'ascii': # loading as dur failed, so load as ascii instead.
32733308
self.loadFromFile(shortfile, loadFormat)
32743309
self.appState.modified = False
3275-
self.setWindowTitle(shortfile)
3310+
#self.setWindowTitle(shortfile)
32763311
self.mov.gotoFrame(1)
32773312
self.hardRefresh()
32783313

@@ -3437,7 +3472,7 @@ def save(self):
34373472
self.appState.curOpenFileName = os.path.basename(filename)
34383473
self.appState.modified = False
34393474
self.undo.modifications = 0
3440-
self.setWindowTitle(self.appState.curOpenFileName)
3475+
#self.setWindowTitle(self.appState.curOpenFileName)
34413476
elif not saved:
34423477
self.notify("Save failed.")
34433478

durdraw/durdraw_ui_widgets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ def __init__(self, caller, x=0, y=0, appState=None):
419419
#mainMenu.add_item("Transform", caller.showTransformer, "t")
420420
mainMenu.add_item("Info/Sauce", caller.showFileInformation, "i", shortcut="esc-i")
421421
mainMenu.add_item("Viewer Mode", caller.enterViewMode, "v", shortcut="esc-V")
422+
mainMenu.add_item("Find /", caller.searchForStringPrompt, "/", shortcut="esc-F")
422423
mainMenu.add_item("Settings", caller.openSettingsMenu, "t", has_submenu=True)
423424
mainMenu.add_item("Help", caller.showHelp, "h", shortcut="esc-h")
424425
mainMenu.add_item("Quit", caller.safeQuit, "q", shortcut="esc-q")

durdraw/help/durhelp-16-long.dur

5.3 KB
Binary file not shown.

durdraw/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def undosize(size_s):
2626
raise argparse.ArgumentTypeError("Undo size must be between 1 and 1000.")
2727

2828
def main():
29-
DUR_VER = '0.24.0'
29+
DUR_VER = '0.24.1'
3030
DUR_FILE_VER = 7
3131
DEBUG_MODE = False # debug = makes debug_write available, sends verbose notifications
3232
durlogo = '''

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name='durdraw',
9-
version='0.24.0',
9+
version='0.24.1',
1010
author='Sam Foster',
1111
author_email='samfoster@gmail.com',
1212
description='Animated Color ASCII and Unicode Art Editor',

0 commit comments

Comments
 (0)