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

Function curses_reminders_menu

Scripts/Developer Base/Smart Notes.py:583–657  ·  view source on GitHub ↗
(stdscr)

Source from the content-addressed store, hash-verified

581
582# Reminders menu
583def curses_reminders_menu(stdscr):
584 try:
585 notes = load_notes()
586 reminders = notes.get('_reminders', [])
587 idx = 0
588 options = ['Add reminder','List reminders','Delete reminder','Back']
589 while True:
590 stdscr.erase()
591 h,w = stdscr.getmaxyx()
592 centered_addstr(stdscr, 1, ' Calendar / Reminders ')
593 total_h = len(options) * 2
594 start_y = max(3, (h - total_h) // 2)
595 for i,opt in enumerate(options):
596 centered_addstr(stdscr, start_y + i*2, f" {opt} ", curses.A_REVERSE if i==idx else 0)
597 stdscr.refresh()
598 ch = stdscr.getch()
599 if ch == curses.KEY_UP:
600 idx = (idx - 1) % len(options)
601 elif ch == curses.KEY_DOWN:
602 idx = (idx + 1) % len(options)
603 elif ch in (10,13):
604 choice = options[idx]
605 if choice == 'Add reminder':
606 title = curses_input(stdscr, 'Reminder title:')
607 if title is None:
608 continue
609 title = title.strip()
610 dt = curses_date_picker(stdscr)
611 if dt is None:
612 continue
613 note_text = curses_editor(stdscr, '')
614 if note_text is None:
615 note_text = ''
616 reminders.append({'title': title, 'datetime': dt.isoformat(), 'text': note_text})
617 notes['_reminders'] = reminders
618 save_notes(notes)
619 scheduled = schedule_termux_notification(title, dt, note_text)
620 stdscr.erase()
621 centered_addstr(stdscr, h//2, 'Reminder saved.' + (' Scheduled.' if scheduled else ' Saved (not scheduled).'))
622 stdscr.refresh()
623 time.sleep(1.2)
624 elif choice == 'List reminders':
625 stdscr.erase()
626 centered_addstr(stdscr, 1, ' Scheduled reminders ')
627 if not reminders:
628 centered_addstr(stdscr, h//2, 'No reminders')
629 else:
630 for i,r in enumerate(reminders[:h-6]):
631 centered_addstr(stdscr, 3+i, f"{i+1}) {r['title']} at {r['datetime']}")
632 centered_addstr(stdscr, h-2, 'Press any key to continue')
633 stdscr.refresh()
634 stdscr.getch()
635 elif choice == 'Delete reminder':
636 if not reminders:
637 stdscr.erase()
638 centered_addstr(stdscr, h//2, 'No reminders to delete')
639 stdscr.refresh()
640 time.sleep(1.0)

Callers 1

main_menuFunction · 0.70

Calls 10

load_notesFunction · 0.70
centered_addstrFunction · 0.70
curses_inputFunction · 0.70
curses_date_pickerFunction · 0.70
curses_editorFunction · 0.70
save_notesFunction · 0.70
curses_select_from_listFunction · 0.70
confirm_dialogFunction · 0.70
log_exceptionFunction · 0.70

Tested by

no test coverage detected