Skip to content

Commit

Permalink
ShredOS specific patch to toggle font size
Browse files Browse the repository at this point in the history
This is only relevant to ShredOS and is disabled
for other distros, as doubling font size is controlled
within the terminal or window manaegment of the distro.

When nwipe detects ShredOS it makes an additional
command available to the GUI in the drive selection window and
progress window (after the wipe has started) This command
is 'f'. Pressing the f key whether in drive selection or
progress windows will double the size of the font. Pressing 'f'
again will toggle the font size back to it's original size.

In addition and depending on whether ShredOS is detected it will
add an additional item to the help footer of both the
drive selection and progress windows. e.g. f=Font size
  • Loading branch information
PartialVolume committed Jan 4, 2025
1 parent 618a8d6 commit 270d643
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 18 deletions.
64 changes: 48 additions & 16 deletions src/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ 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 c=Config CTRL+C=Quit";
const char* shredos_main_window_footer =
"S=Start m=Method p=PRNG v=Verify r=Rounds b=Blanking Space=Select f=Font size c=Config CTRL+C=Quit";
char** p_main_window_footer;
const char* main_window_footer_warning_lower_case_s = " WARNING: To start the wipe press SHIFT+S (uppercase S) ";

const char* main_window_footer_warning_no_blanking_with_ops2 =
Expand All @@ -166,10 +169,15 @@ const char* selection_footer_preview_prior_to_drive_selection =
"A=Accept & display drives J=Down K=Up Space=Select Backspace=Cancel Ctrl+C=Quit";
const char* selection_footer_add_customer = "S=Save J=Down K=Up Space=Select Backspace=Cancel Ctrl+C=Quit";
const char* selection_footer_add_customer_yes_no = "Save Customer Details Y/N";
char** p_end_wipe_footer; /* Contains a pointer to either end_wipe_footer or shredos_end_wipe_footer */
const char* end_wipe_footer = "B=[Toggle between dark\\blank\\blue screen] Ctrl+C=Quit";
const char* shredos_end_wipe_footer = "b=[Toggle dark\\blank\\blue screen] f=Font size Ctrl+C=Quit";
const char* rounds_footer = "Left=Erase Esc=Cancel Ctrl+C=Quit";
const char* selection_footer_text_entry = "Esc=Cancel Return=Submit Ctrl+C=Quit";

/* Keeps track of whether font is standard or double size (applicable to ShredOS only) */
int toggle_font_flag = 0;

/* The number of lines available in the terminal */
int stdscr_lines;

Expand Down Expand Up @@ -312,6 +320,17 @@ void nwipe_gui_init( void )
/* Enable most special keys. */
keypad( stdscr, TRUE );

/* Initialiase pointer to default end_wipe_footer text */
if( access( "/usr/bin/shredos_toggle_font_size.sh", F_OK ) == 0 )
{
p_end_wipe_footer = (char**) &shredos_end_wipe_footer;
p_main_window_footer = (char**) &shredos_main_window_footer;
}
else
{
p_end_wipe_footer = (char**) &end_wipe_footer;
p_main_window_footer = (char**) &main_window_footer;
}
/* Create the text/background color pairs */
nwipe_init_pairs();

Expand All @@ -322,7 +341,7 @@ void nwipe_gui_init( void )
nwipe_gui_create_header_window();

/* Create the footer window and panel */
nwipe_gui_create_footer_window( main_window_footer );
nwipe_gui_create_footer_window( *p_main_window_footer );

/* Create the options window and panel */
nwipe_gui_create_options_window();
Expand Down Expand Up @@ -672,7 +691,7 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
do
{

nwipe_gui_create_all_windows_on_terminal_resize( 0, main_window_footer );
nwipe_gui_create_all_windows_on_terminal_resize( 0, *p_main_window_footer );

/* There is one slot per line. */
getmaxyx( main_window, wlines, wcols );
Expand Down Expand Up @@ -720,7 +739,7 @@ void nwipe_gui_select( int count, nwipe_context_t** c )

/* If the user selected an option the footer text would have changed.
* Here we set it back to the main key help text */
nwipe_gui_create_footer_window( main_window_footer );
nwipe_gui_create_footer_window( *p_main_window_footer );

/* Refresh the stats window */
wnoutrefresh( stats_window );
Expand Down Expand Up @@ -1209,7 +1228,7 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
wattroff( footer_window, COLOR_PAIR( 10 ) );

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

break;
Expand All @@ -1225,7 +1244,7 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
wattroff( footer_window, COLOR_PAIR( 10 ) );

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

break;
Expand Down Expand Up @@ -1269,7 +1288,7 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
wattroff( footer_window, COLOR_PAIR( 10 ) );

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

/* Remove any repeated S key strokes, without this the gui would hang
Expand Down Expand Up @@ -1301,7 +1320,7 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
wattroff( footer_window, COLOR_PAIR( 10 ) );

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

/* Remove any repeated s key strokes, without this the gui would hang
Expand Down Expand Up @@ -1350,9 +1369,9 @@ void nwipe_gui_select( int count, nwipe_context_t** c )

break;

case 'd':
case 'f':

/* The d key is only meaningful for ShredOS, it toggles the fontsize */
/* The f key is only meaningful for ShredOS, it toggles the fontsize */
if( access( "/usr/bin/shredos_toggle_font_size.sh", F_OK ) == 0 )
{
if( system( "/usr/bin/shredos_toggle_font_size.sh > /dev/null 2>&1" ) == 0 )
Expand Down Expand Up @@ -1389,7 +1408,7 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
{
/* If user has pressed S to start wipe change status line */
werase( footer_window );
nwipe_gui_title( footer_window, end_wipe_footer );
nwipe_gui_title( footer_window, *p_end_wipe_footer );
wnoutrefresh( footer_window );
}

Expand Down Expand Up @@ -3866,7 +3885,7 @@ void nwipe_gui_list( int count, char* window_title, char** list, int* selected_e
do
{

nwipe_gui_create_all_windows_on_terminal_resize( 0, main_window_footer );
nwipe_gui_create_all_windows_on_terminal_resize( 0, *p_main_window_footer );

/* There is one slot per line. */
getmaxyx( main_window, wlines, wcols );
Expand Down Expand Up @@ -6319,7 +6338,7 @@ void* nwipe_gui_status( void* ptr )
nwipe_time_start = time( NULL ) - 1;
}

nwipe_gui_title( footer_window, end_wipe_footer );
nwipe_gui_title( footer_window, *p_end_wipe_footer );

loop_control = 1;

Expand Down Expand Up @@ -6392,7 +6411,7 @@ void* nwipe_gui_status( void* ptr )
if( nwipe_active != 0 )
{
/* if resizing the terminal during a wipe a specific footer is required */
nwipe_gui_create_all_windows_on_terminal_resize( 0, end_wipe_footer );
nwipe_gui_create_all_windows_on_terminal_resize( 0, *p_end_wipe_footer );
}
else
{
Expand Down Expand Up @@ -6430,7 +6449,7 @@ void* nwipe_gui_status( void* ptr )
{
tft_saver = 0;
nwipe_init_pairs();
nwipe_gui_create_all_windows_on_terminal_resize( 1, end_wipe_footer );
nwipe_gui_create_all_windows_on_terminal_resize( 1, *p_end_wipe_footer );

/* Show screen */
nwipe_gui_blank = 0;
Expand All @@ -6447,7 +6466,7 @@ void* nwipe_gui_status( void* ptr )
show_panel( main_panel );

/* Reprint the footer */
nwipe_gui_title( footer_window, end_wipe_footer );
nwipe_gui_title( footer_window, *p_end_wipe_footer );

// Refresh the footer_window ;
wnoutrefresh( footer_window );
Expand All @@ -6470,7 +6489,7 @@ void* nwipe_gui_status( void* ptr )
/* grey text on black background */
tft_saver = 1;
nwipe_init_pairs();
nwipe_gui_create_all_windows_on_terminal_resize( 1, end_wipe_footer );
nwipe_gui_create_all_windows_on_terminal_resize( 1, *p_end_wipe_footer );
}
else
{
Expand Down Expand Up @@ -6538,6 +6557,19 @@ void* nwipe_gui_status( void* ptr )

break;

case 'f':

/* The f key is only meaningful for ShredOS, it toggles the fontsize */
if( access( "/usr/bin/shredos_toggle_font_size.sh", F_OK ) == 0 )
{
if( system( "/usr/bin/shredos_toggle_font_size.sh > /dev/null 2>&1" ) == 0 )
{
nwipe_log( NWIPE_LOG_INFO, "Toggle font size" );
}
}

break;

default:

/* Do nothing. */
Expand Down
4 changes: 2 additions & 2 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* used by configure to dynamically assign those values
* to documentation files.
*/
const char* version_string = "0.37.2";
const char* version_string = "0.37.3";
const char* program_name = "nwipe";
const char* author_name = "Martijn van Brummelen";
const char* email_address = "[email protected]";
Expand All @@ -14,4 +14,4 @@ Modifications to original dwipe Copyright Andy Beverley <[email protected]>\n\
This is free software; see the source for copying conditions.\n\
There is NO warranty; not even for MERCHANTABILITY or FITNESS\n\
FOR A PARTICULAR PURPOSE.\n";
const char* banner = "nwipe 0.37.2";
const char* banner = "nwipe 0.37.3";

0 comments on commit 270d643

Please sign in to comment.