Highlight installer, upgrader and disked interactive prompts.

This commit is contained in:
Jonas 'Sortie' Termansen 2017-08-20 17:15:55 +02:00
parent 46862b797f
commit 3d356af8d2
2 changed files with 13 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015 Jonas 'Sortie' Termansen.
* Copyright (c) 2015, 2016, 2017 Jonas 'Sortie' Termansen.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -396,6 +396,8 @@ static void prompt(char* buffer,
{
while ( true )
{
printf("\e[1m");
fflush(stdout);
text(question);
if ( answer )
printf(" [%s] ", answer);
@ -403,6 +405,8 @@ static void prompt(char* buffer,
printf(" ");
fflush(stdout);
fgets(buffer, buffer_size, stdin);
printf("\e[22m");
fflush(stdout);
size_t buffer_length = strlen(buffer);
if ( buffer_length && buffer[buffer_length-1] == '\n' )
buffer[--buffer_length] = '\0';

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016 Jonas 'Sortie' Termansen.
* Copyright (c) 2015, 2016, 2017 Jonas 'Sortie' Termansen.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -158,6 +158,8 @@ void promptx(char* buffer,
{
while ( true )
{
printf("\e[1m");
fflush(stdout);
text(question);
if ( answer )
printf(" [%s] ", answer);
@ -165,6 +167,8 @@ void promptx(char* buffer,
printf(" ");
fflush(stdout);
fgets(buffer, buffer_size, stdin);
printf("\e[22m");
fflush(stdout);
size_t buffer_length = strlen(buffer);
if ( buffer_length && buffer[buffer_length-1] == '\n' )
buffer[--buffer_length] = '\0';
@ -202,6 +206,8 @@ void password(char* buffer,
unsigned int termmode;
gettermmode(0, &termmode);
settermmode(0, termmode & ~TERMMODE_ECHO);
printf("\e[1m");
fflush(stdout);
text(question);
printf(" ");
fflush(stdout);
@ -209,7 +215,7 @@ void password(char* buffer,
// TODO: This may leave a copy of the password in the stdio buffer.
fgets(buffer, buffer_size, stdin);
fflush(stdin);
printf("\n");
printf("\e[22m\n");
size_t buffer_length = strlen(buffer);
if ( buffer_length && buffer[buffer_length-1] == '\n' )
buffer[--buffer_length] = '\0';