From a946025ab9907d9cc00018562da7cced3f62f0b5 Mon Sep 17 00:00:00 2001 From: Kamal Curi Date: Thu, 30 Dec 2021 00:51:04 -0300 Subject: [PATCH] FIX: Version 1.01 --- .gitignore | 1 + CHANGELOG | 7 ++++++- install.sh | 15 ++++++++++++++- steelbox.py | 25 ++++++++++++++++++------- steelbox.sh | 2 +- 5 files changed, 40 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 575af32..bb4465b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ test.py pasfile.csv poptest.sh what.sh +.pasfile.csv diff --git a/CHANGELOG b/CHANGELOG index e44b27e..6e8912d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -22,4 +22,9 @@ · Added 'help' command · Minor bug fixes: · ITEM_CURSOR and GLOBAL_CURSOR now behave properly under all(tested) circumstances - · Added random string to modify password \ No newline at end of file + · Added random string to modify password +- 1.01 + · Major bug fixes: + · Fixed 'help command' bug + · Fixed 'password modify' bug + · Fixed bug with window resizing \ No newline at end of file diff --git a/install.sh b/install.sh index 09ec5e7..144edb5 100755 --- a/install.sh +++ b/install.sh @@ -20,7 +20,16 @@ then sudo rm /opt/steelbox.sh exit 1 fi - +echo Copying Help file +sudo cp -f sbhelp /opt/sbhelp +if [ $? -gt 0 ] +then + echo COULD NOT COPY HELP FILE + echo QUITTING + sudo rm /opt/steelbox.sh + sudo rm /opt/steelbox.py + exit 1 +fi echo Setting up permissions sudo chmod +x /opt/steelbox.sh if [ $? -gt 0 ] @@ -29,6 +38,7 @@ then echo QUITTING sudo rm /opt/steelbox.sh sudo rm /opt/steelbox.py + sudo rm /opt/sbhelp exit 1 fi @@ -42,6 +52,7 @@ then echo QUITTING sudo rm /opt/steelbox.sh sudo rm /opt/steelbox.py + sudo rm /opt/sbhelp exit 1 fi fi @@ -57,6 +68,7 @@ then sudo rm /opt/steelbox.sh sudo rm /opt/steelbox.py sudo rm /usr/bin/steelbox + sudo rm /opt/sbhelp exit 1 fi echo Setting up password file @@ -82,6 +94,7 @@ then sudo rm /opt/steelbox.sh sudo rm /opt/steelbox.py sudo rm /usr/bin/steelbox + sudo rm /opt/sbhelp rm $HOME/.pasfile.csv exit 1 fi diff --git a/steelbox.py b/steelbox.py index edd7bb4..7df4270 100644 --- a/steelbox.py +++ b/steelbox.py @@ -22,7 +22,6 @@ fields = ["service", "user", "pswd"] HOMEDIR = os.environ['HOME'] PASFILE=HOMEDIR+"/.pasfile.csv" - def reloadFiles(): files.clear() with open(PASFILE, mode='r') as pasfile: @@ -55,9 +54,10 @@ def steelbox(): cleanWins() while True: + termGlobals() reloadFiles() displayItems() - stdscr.move(TERM_LINES, TERM_COLS) + stdscr.move(0, 0) command() @@ -120,6 +120,17 @@ def globals(): global PPSWD PPSWD = "" +# This makes sure that if anyone resizes the terminal window, it won't be smaller than the maximum size +def termGlobals(): + global TERM_LINES + TERM_LINES=curses.LINES - 1 + if TERM_LINES <= 20: + close("ERROR: Your terminal is too small!") + global TERM_COLS + TERM_COLS=curses.COLS - 1 + if TERM_COLS <=80: + close("ERROR: Your terminal is too small!") + # Gets user command def command(): # The GLOBAL_CURSOR points to the main files object, so that it gets the right file. @@ -266,15 +277,15 @@ def modFile(): # Gets the coordinates for the top left corner of said window nwCord = modWin.getbegyx() # Creates the fields in which the password will be edited - svWin = curses.newwin(1, 45, nwCord[0]+1, nwCord[1]+6) + svWin = curses.newwin(1, 46, nwCord[0]+1, nwCord[1]+6) svWin.addstr(0, 0, modFile['service']) svWin.move(0, 0) svBox = Textbox(svWin) - usWin = curses.newwin(1, 45, nwCord[0]+2, nwCord[1]+6) + usWin = curses.newwin(1, 46, nwCord[0]+2, nwCord[1]+6) usWin.addstr(0, 0, modFile['user']) usWin.move(0, 0) usBox = Textbox(usWin) - psWin = curses.newwin(1, 45, nwCord[0]+3, nwCord[1]+6) + psWin = curses.newwin(1, 46, nwCord[0]+3, nwCord[1]+6) psWin.addstr(0, 0, modFile['pswd']) psWin.move(0, 0) psBox = Textbox(psWin) @@ -403,7 +414,7 @@ def displayItems(): LINE = 0 COLUMN+=16 NROWS+=1 - STATUS_MESSAGE = "PrvPage(F1),NxtPage(F2),(d|el),(e)xamine,(n)ew,(c)opy,(m)odify,(r)andom,(q)uit" + STATUS_MESSAGE = "PrvPage(F1),NxtPage(F2),(d|el),(n)ew,(c)opy,(m)odify,(r)andom,(q)uit" displayStatus(STATUS_MESSAGE) mainwin.refresh() @@ -419,7 +430,7 @@ def sbhelp(): helpwin.border() helpwin.addstr(1, 1, "Steelbox V." + version) line = 2 - with open("sbhelp", mode='r') as sbhfile: + with open("/opt/sbhelp", mode='r') as sbhfile: sbh = sbhfile.readlines() for lines in sbh: helpwin.addstr(line, 1, lines) diff --git a/steelbox.sh b/steelbox.sh index e966cfa..7bdf846 100755 --- a/steelbox.sh +++ b/steelbox.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -version="1.0" +version="1.01" echo Steelbox V$version