|
|
|
@ -72,12 +72,20 @@ def main(stdscr):
|
|
|
|
|
# Defines the amount of pages needed to house all files within the terminal space
|
|
|
|
|
global MAX_PAGES
|
|
|
|
|
MAX_PAGES = int(len(files)/MAX_ITEMS)
|
|
|
|
|
# In case there are less passwords than the amount available in the first page
|
|
|
|
|
if MAX_PAGES < 1: MAX_PAGES = 1
|
|
|
|
|
# Status bar message
|
|
|
|
|
global STATUS_MESSAGE
|
|
|
|
|
STATUS_MESSAGE = ""
|
|
|
|
|
# Global pointer for the cursor's item
|
|
|
|
|
global GLOBAL_CURSOR
|
|
|
|
|
GLOBAL_CURSOR = 0
|
|
|
|
|
# How many rows are displayed in the window
|
|
|
|
|
global NROWS
|
|
|
|
|
NROWS = 0
|
|
|
|
|
# What row the cursor is in
|
|
|
|
|
global CUROW
|
|
|
|
|
CUROW = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -99,11 +107,9 @@ def main(stdscr):
|
|
|
|
|
# Creates a name list
|
|
|
|
|
displayList = []
|
|
|
|
|
|
|
|
|
|
# This makes sure the cursor stays on the screen
|
|
|
|
|
# This makes sure the cursor stays on the screen TODO: delete this
|
|
|
|
|
if ITEM_CURSOR < 0: ITEM_CURSOR = 0
|
|
|
|
|
if ITEM_CURSOR > MAX_ITEMS or ITEM_CURSOR > len(files)-1: ITEM_CURSOR = 0
|
|
|
|
|
if CURR_PAGE < 1: CURR_PAGE = 1
|
|
|
|
|
if CURR_PAGE > MAX_PAGES: CURR_PAGE = MAX_PAGES
|
|
|
|
|
|
|
|
|
|
# Makes sure the windows are properly clean
|
|
|
|
|
mainwin.clear()
|
|
|
|
@ -137,6 +143,7 @@ def main(stdscr):
|
|
|
|
|
if LINE >= WINLIMIT:
|
|
|
|
|
LINE = 0
|
|
|
|
|
COLUMN+=16
|
|
|
|
|
NROWS+=1
|
|
|
|
|
mainwin.refresh()
|
|
|
|
|
STATUS_MESSAGE = "cmds: PrvPage(F1),NxtPage(F2),(q)uit,(e)xmn,(n)ew"
|
|
|
|
|
statusWin.addstr(0,0, STATUS_MESSAGE)
|
|
|
|
@ -150,23 +157,32 @@ def main(stdscr):
|
|
|
|
|
if c == ord('q'):
|
|
|
|
|
return(0)
|
|
|
|
|
elif c == curses.KEY_DOWN:
|
|
|
|
|
ITEM_CURSOR+=1
|
|
|
|
|
GLOBAL_CURSOR+=1
|
|
|
|
|
if GLOBAL_CURSOR < len(files):
|
|
|
|
|
ITEM_CURSOR+=1
|
|
|
|
|
GLOBAL_CURSOR+=1
|
|
|
|
|
elif c == curses.KEY_UP:
|
|
|
|
|
ITEM_CURSOR-=1
|
|
|
|
|
GLOBAL_CURSOR-=1
|
|
|
|
|
if GLOBAL_CURSOR > 0:
|
|
|
|
|
ITEM_CURSOR-=1
|
|
|
|
|
GLOBAL_CURSOR-=1
|
|
|
|
|
elif c == curses.KEY_RIGHT:
|
|
|
|
|
ITEM_CURSOR+=MAX_LINES - 1
|
|
|
|
|
GLOBAL_CURSOR+=MAX_LINES - 1
|
|
|
|
|
if CUROW < NROWS:
|
|
|
|
|
ITEM_CURSOR+=MAX_LINES - 1
|
|
|
|
|
GLOBAL_CURSOR+=MAX_LINES - 1
|
|
|
|
|
CUROW+=1
|
|
|
|
|
elif c == curses.KEY_LEFT:
|
|
|
|
|
ITEM_CURSOR-=MAX_LINES - 1
|
|
|
|
|
GLOBAL_CURSOR-=MAX_LINES - 1
|
|
|
|
|
if CUROW > 0:
|
|
|
|
|
ITEM_CURSOR-=MAX_LINES - 1
|
|
|
|
|
GLOBAL_CURSOR-=MAX_LINES - 1
|
|
|
|
|
CUROW-=1
|
|
|
|
|
elif c == curses.KEY_F1 or c == curses.KEY_PPAGE:
|
|
|
|
|
CURR_PAGE-=1
|
|
|
|
|
GLOBAL_CURSOR-=MAX_ITEMS
|
|
|
|
|
# The next two IF statements are here to avoid unintended GLOBAL_CURSOR changes
|
|
|
|
|
if CURR_PAGE > 1:
|
|
|
|
|
CURR_PAGE-=1
|
|
|
|
|
GLOBAL_CURSOR-=MAX_ITEMS
|
|
|
|
|
elif c == curses.KEY_F2 or c == curses.KEY_NPAGE:
|
|
|
|
|
CURR_PAGE+=1
|
|
|
|
|
GLOBAL_CURSOR+=MAX_ITEMS
|
|
|
|
|
if CURR_PAGE < MAX_PAGES:
|
|
|
|
|
CURR_PAGE+=1
|
|
|
|
|
GLOBAL_CURSOR+=MAX_ITEMS
|
|
|
|
|
|
|
|
|
|
# For some reason, KEY_UP is 10, instead of the 343 the debbuger flags... Welp ¯\_(ツ)_/¯
|
|
|
|
|
elif c == 10 or c == curses.KEY_ENTER or c == ord('e'):
|
|
|
|
|