MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / action_for_note

Function action_for_note

Scripts/Developer Base/Smart Notes.py:437–478  ·  view source on GitHub ↗
(stdscr, key, notes)

Source from the content-addressed store, hash-verified

435
436# Actions for note
437def action_for_note(stdscr, key, notes):
438 try:
439 h,w = stdscr.getmaxyx()
440 while True:
441 stdscr.erase()
442 centered_addstr(stdscr, 1, f' Note: {key} ')
443 content = notes.get(key, '')
444 if not isinstance(content, str):
445 try:
446 preview_text = json.dumps(content, indent=2, ensure_ascii=False)
447 except Exception:
448 preview_text = str(content)
449 else:
450 preview_text = content
451 preview = preview_text.split('\n')[:10]
452 for i,line in enumerate(preview):
453 try:
454 stdscr.addstr(3+i, 2, line[:w-4])
455 except Exception:
456 pass
457 centered_addstr(stdscr, h-4, 'V: View E: Edit D: Delete B: Back')
458 stdscr.refresh()
459 ch = stdscr.getch()
460 if ch in (ord('v'), ord('V')):
461 view_note_curses(stdscr, key, content)
462 elif ch in (ord('e'), ord('E')):
463 initial = preview_text if isinstance(content, (dict, list)) else str(content)
464 new = curses_editor(stdscr, initial)
465 if new is not None:
466 notes[key] = new
467 save_notes(notes)
468 elif ch in (ord('d'), ord('D')):
469 confirmed = confirm_dialog(stdscr, f'Delete note "{key}"?')
470 if confirmed:
471 notes.pop(key, None)
472 save_notes(notes)
473 return
474 elif ch in (ord('b'), ord('B'), 27):
475 return
476 except Exception as e:
477 log_exception(e)
478 error_dialog(stdscr, 'Note action error', traceback.format_exc())
479
480# Add note (curses)
481def add_note_curses(stdscr):

Callers 1

main_menuFunction · 0.70

Calls 6

centered_addstrFunction · 0.70
view_note_cursesFunction · 0.70
curses_editorFunction · 0.70
save_notesFunction · 0.70
confirm_dialogFunction · 0.70
log_exceptionFunction · 0.70

Tested by

no test coverage detected