Skip to content

Commit

Permalink
Merge pull request martijnvanbrummelen#263 from PartialVolume/Warn_us…
Browse files Browse the repository at this point in the history
…er_if_the_press_lower_case_s

Warn user if they press 's' instead of 'S'
  • Loading branch information
PartialVolume authored Apr 15, 2020
2 parents 7d93a44 + a4d5164 commit 082a4e5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ other items in 0.29 are proposed and yet to be implemented.
- [DONE] Improve visibility of failure messages with red text on white background. (Thanks PartialVolume)
- [DONE] Add NVME and VIRT (loop etc) devices to device type table for display in GUI and logs. NVME devices now show up as NVME devices rather than UNK (Thanks PartialVolume)
- [DONE] Fix very obscure segmentation fault going back to at least 0.24 in drive selection window when resizing terminal vertical axis while drive focus symbol '>' is pointing to the last drive of a multi drive selection window. See [#248](https://github.com/martijnvanbrummelen/nwipe/pull/248) for further details (Thanks PartialVolume)
- [DONE] Warn the user if they are incorrectly typing a lower case s to start a wipe, when they should be typing a capital S [#262](https://github.com/martijnvanbrummelen/nwipe/issues/262) (Thanks PartialVolume)
- Add enhancement fibre channel wiping of non 512 bytes/sector drives such as 524/528 bytes/sector etc (work in progress by PartialVolume)
- HPA/DCO detection and adjustment to wipe full drive. (work in progress by PartialVolume)

Expand Down
31 changes: 31 additions & 0 deletions src/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ const char* stats_title = " Statistics ";

/* Footer labels. */
const char* main_window_footer = "S=Start M=Method P=PRNG V=Verify R=Rounds B=Blanking Space=Select Ctrl-C=Quit";
const char* main_window_footer_warning_lower_case_s =
" WARNING: To start the wipe press capital S, you pressed lower case s ";
const char* selection_footer = "J=Down K=Up Space=Select Backspace=Cancel Ctrl-C=Quit";
const char* end_wipe_footer = "B=Blank screen Ctrl-C=Quit";
const char* rounds_footer = "Left=Erase Esc=Cancel Ctrl-C=Quit";
Expand Down Expand Up @@ -225,6 +227,9 @@ void nwipe_gui_init( void )
/* Set green on blue for reverse bold error messages */
init_pair( 9, COLOR_RED, COLOR_WHITE );

/* Set black on yellow for warning messages */
init_pair( 10, COLOR_BLACK, COLOR_YELLOW );

/* Set the background style. */
wbkgdset( stdscr, COLOR_PAIR( 1 ) | ' ' );
}
Expand Down Expand Up @@ -958,6 +963,32 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
validkeyhit = 1;
break;

case 's':

/* user has mistakenly hit the lower case 's' instead of capital 'S' */

/* Warn the user about their mistake */
wattron( footer_window, COLOR_PAIR( 10 ) );
nwipe_gui_amend_footer_window( main_window_footer_warning_lower_case_s );
doupdate();
sleep( 2 );
wattroff( footer_window, COLOR_PAIR( 10 ) );

/* After the delay return footer text back to key help */
nwipe_gui_amend_footer_window( main_window_footer );
doupdate();

/* if user insists on holding the s key down, without this the gui would hang
* for a period of time, i.e sleep above x number of repeated 's' keystrokes
* which could run into minutes */
do
{
timeout( 250 ); // block getch() for 250ms.
keystroke = getch(); // Get user input.
timeout( -1 ); // Switch back to blocking mode.
} while( keystroke == 's' );
break;

} /* keystroke switch */

/* Check the terminal size, if the user has changed it the while loop checks for
Expand Down

0 comments on commit 082a4e5

Please sign in to comment.