diff --git a/.gitignore b/.gitignore index bb4465b..e0ac906 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ pasfile.csv poptest.sh what.sh .pasfile.csv +pasfile.csv.gpg diff --git a/CHANGELOG b/CHANGELOG index da40960..a51e70a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -30,4 +30,8 @@ · Major bug fixes: · Fixed 'help command' bug · Fixed 'password modify' bug - · Fixed bug with window resizing \ No newline at end of file + · Fixed bug with window resizing +- 1.03 + · Added --no-symkey-cache to gpg, you will now have to type your password everytime you open Steelbox + · Major bug fixes: + Fixed resising terminal bug, and made data handling logic work. \ No newline at end of file diff --git a/steelbox.py b/steelbox.py index cd61cee..e7272e3 100644 --- a/steelbox.py +++ b/steelbox.py @@ -38,8 +38,7 @@ curses.cbreak() stdscr.keypad(True) stdscr.clear() -def steelbox(): - reloadFiles() +def init(): # Initializes the main window global mainwin mainwin = curses.newwin(TERM_LINES -1, TERM_COLS, 0, 0) @@ -53,6 +52,13 @@ def steelbox(): statuswin.border() cleanWins() + + +# Main function +def steelbox(): + reloadFiles() + init() + while True: termGlobals() reloadFiles() @@ -60,6 +66,46 @@ def steelbox(): stdscr.move(0, 0) command() +# Displays the items on the screen properly +def displayItems(): + cleanWins() + global NROWS + global ITEM_CURSOR + # Creates a name list + global displayList + displayList = [] + # Appends the names in the CSV to display on the main window + for ps_name in files: + displayList.append(ps_name['service'][:15]) + + # Reset global necessities + LINE = 0 + COLUMN = 0 + currItem = 0 + NROWS = 0 + global highOpt + highOpt = () + # Defines what to display + startDisplay = (CURR_PAGE-1)*MAX_ITEMS + stopDisplay = CURR_PAGE*MAX_ITEMS + + for item in displayList[startDisplay:stopDisplay]: + # If the item is the one with the cursor, highlight it + if currItem == ITEM_CURSOR: + mode = curses.A_REVERSE + highOpt = mainwin.getyx() + else: + mode = curses.A_NORMAL + mainwin.addstr(1 + LINE, 1 + COLUMN, item, mode) + LINE+=1 + currItem+=1 + if LINE >= WINLIMIT: + LINE = 0 + COLUMN+=16 + NROWS+=1 + STATUS_MESSAGE = "(n)ew,(d|el),(c)opy,(m)odify,(h)elp,(q)uit" + displayStatus(STATUS_MESSAGE) + mainwin.refresh() # Defines global variables def globals(): @@ -190,6 +236,14 @@ def command(): rwin() elif c == ord('h'): sbhelp() + # This avoids the program crashing when resizing the terminal + elif c == curses.KEY_RESIZE: + y, x = stdscr.getmaxyx() + stdscr.clear() + curses.resize_term(y, x) + cleanWins() + globals() + init() def newFile(): @@ -371,6 +425,7 @@ def copy(): # Cleans the windows def cleanWins(): + stdscr.clear() mainwin.clear() statuswin.clear() mainwin.border() @@ -379,50 +434,6 @@ def cleanWins(): mainwin.refresh() statuswin.refresh() - - -# Displays the items on the screen properly -def displayItems(): - cleanWins() - global NROWS - global ITEM_CURSOR - # Creates a name list - global displayList - displayList = [] - # Appends the names in the CSV to display on the main window - for ps_name in files: - displayList.append(ps_name['service'][:15]) - - # Reset global necessities - LINE = 0 - COLUMN = 0 - currItem = 0 - NROWS = 0 - global highOpt - highOpt = () - # Defines what to display - startDisplay = (CURR_PAGE-1)*MAX_ITEMS - stopDisplay = CURR_PAGE*MAX_ITEMS - - for item in displayList[startDisplay:stopDisplay]: - # If the item is the one with the cursor, highlight it - if currItem == ITEM_CURSOR: - mode = curses.A_REVERSE - highOpt = mainwin.getyx() - else: - mode = curses.A_NORMAL - mainwin.addstr(1 + LINE, 1 + COLUMN, item, mode) - LINE+=1 - currItem+=1 - if LINE >= WINLIMIT: - LINE = 0 - COLUMN+=16 - NROWS+=1 - STATUS_MESSAGE = "(n)ew,(d|el),(c)opy,(m)odify,(h)elp,(q)uit" - displayStatus(STATUS_MESSAGE) - mainwin.refresh() - - # Displays on the status window def displayStatus(msg): statuswin.border() diff --git a/steelbox.sh b/steelbox.sh index 2077a31..2717992 100755 --- a/steelbox.sh +++ b/steelbox.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -version="1.02" +version="1.03" echo Steelbox V$version @@ -23,7 +23,7 @@ fi python3 /opt/steelbox.py $version -gpg -c --cipher-algo AES256 $HOME/.pasfile.csv +gpg -c --no-symkey-cache --cipher-algo AES256 $HOME/.pasfile.csv if [ $? -gt 0 ] then