Skip to content

Commit

Permalink
Merge pull request #16 from r-richter/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
r-richter authored Jun 21, 2020
2 parents aba0f87 + 159a446 commit 2f7a64b
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 20 deletions.
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Version 0.8 (Jun. 21st, 2020)
- Code refactoring
- Enhanced user interface\
\
[Source Code](https://github.com/r-richter/hyenae-ng/releases/tag/v0.8)

## Version 0.7 (Jun. 21st, 2020)
- Added terminal colors
- Enhanced user interface
Expand Down
15 changes: 13 additions & 2 deletions include/frontend/console/console_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@
#ifndef CONSOLE_IO_H
#define CONSOLE_IO_H

#include "../../../include/os.h"
#include "../../../include/common.h"

#ifdef OS_WINDOWS
#define CHARSET_ASCII
#else
#define CHARSET_UNICODE
#endif

namespace hyenae::frontend::console
{
/*---------------------------------------------------------------------- */
Expand Down Expand Up @@ -66,10 +73,14 @@ namespace hyenae::frontend::console
static const string_t ANSI_BG_CYAN;
static const string_t ANSI_BG_WHITE;

private:
bool _ansi_color_on;

public:
console_io(bool ansi_color_on = true);
void header_out(string_t title);
void input_separator_out(bool nl_before, bool nl_after);
void menu_item_separator_out(bool nl_before, bool nl_after);
void separator_out(bool nl_before, bool nl_after);
void menu_separator_out(bool nl_before, bool nl_after);

void menu_item_out(
const string_t& choice,
Expand Down
Binary file modified msc/ip_v4_setup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msc/main_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msc/start_dispatcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace hyenae
/*---------------------------------------------------------------------- */

const char* constants::APP_NAME = "Hyenae NG";
const char* constants::APP_VERSION = "0.7";
const char* constants::APP_VERSION = "0.8";

/*---------------------------------------------------------------------- */

Expand Down
59 changes: 47 additions & 12 deletions src/frontend/console/console_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ namespace hyenae::frontend::console
const string_t console_io::ANSI_FG_CYAN = "\u001B[36m";
const string_t console_io::ANSI_FG_WHITE = "\u001B[37m";

/*---------------------------------------------------------------------- */

const string_t console_io::ANSI_BG_RESET = ANSI_FG_RESET;
const string_t console_io::ANSI_BG_BLACK = "\u001B[40m";
const string_t console_io::ANSI_BG_RED = "\u001B[41m";
Expand All @@ -54,6 +56,14 @@ namespace hyenae::frontend::console

/*---------------------------------------------------------------------- */

console_io::console_io(bool ansi_color_on)
{
_ansi_color_on = ansi_color_on;

} /* console_io */

/*---------------------------------------------------------------------- */

void console_io::header_out(string_t title)
{
string_t menu_info = "";
Expand Down Expand Up @@ -83,15 +93,24 @@ namespace hyenae::frontend::console
header.append("\n");
pad_to_margin(header, BASE_MARGIN + 1);
header.append(titlebar);
header.append("\n\n");
header.append("\n");

out(header);

if (_ansi_color_on)
{
out("\n");
}
else
{
separator_out(false, true);
}

} /* header_out */

/*---------------------------------------------------------------------- */

void console_io::input_separator_out(bool nl_before, bool nl_after)
void console_io::separator_out(bool nl_before, bool nl_after)
{
string_t text = "";

Expand All @@ -102,7 +121,16 @@ namespace hyenae::frontend::console

pad_to_margin(text, BASE_MARGIN + text.size());

text.append(string_t(MENU_WIDTH, '-'));
for (int i = 0; i < (int)MENU_WIDTH; i++)
{
#if defined(CHARSET_ASCII)
text.append(string_t(1, (char)205));
#elif defined (CHARSET_UNICODE)
text.append("\u2550");
#else
text.append("-");
#endif
}

if (nl_after)
{
Expand All @@ -111,11 +139,11 @@ namespace hyenae::frontend::console

out(text);

} /* input_separator_out */
} /* separator_out */

/*---------------------------------------------------------------------- */

void console_io::menu_item_separator_out(bool nl_before, bool nl_after)
void console_io::menu_separator_out(bool nl_before, bool nl_after)
{
string_t text = "";

Expand All @@ -139,7 +167,7 @@ namespace hyenae::frontend::console

out(text);

} /* menu_item_separator_out */
} /* menu_separator_out */

/*---------------------------------------------------------------------- */

Expand Down Expand Up @@ -487,13 +515,20 @@ namespace hyenae::frontend::console
{
string_t colored = "";

colored.append(ansi_bg);
colored.append(ansi_fg);
colored.append(text);
colored.append(ANSI_FG_RESET);
colored.append(ANSI_BG_RESET);
if (_ansi_color_on)
{
colored.append(ansi_bg);
colored.append(ansi_fg);
colored.append(text);
colored.append(ANSI_FG_RESET);
colored.append(ANSI_BG_RESET);

return colored;
return colored;
}
else
{
return text;
}

} /* text_color */

Expand Down
4 changes: 2 additions & 2 deletions src/frontend/console/console_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace hyenae::frontend::console
item_out(_items[pos]);
}

_console_io->menu_item_separator_out(true, true);
_console_io->menu_separator_out(true, true);

if (_start_state != NULL)
{
Expand Down Expand Up @@ -218,7 +218,7 @@ namespace hyenae::frontend::console
hint = default_choice->get_choice();
}

_console_io->input_separator_out(true, false);
_console_io->separator_out(true, false);

input = _console_io->prompt("Enter Selection", hint);

Expand Down
6 changes: 3 additions & 3 deletions src/frontend/console/states/start_dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ namespace hyenae::frontend::console::states
{
get_console()->task_out("Dispatching...");

get_console()->input_separator_out(true, false);
get_console()->separator_out(true, false);

get_console()->prompt_out("", "Press any key to stop");

Expand All @@ -166,7 +166,7 @@ namespace hyenae::frontend::console::states
get_console()->error_out(_thread_exception->what(), true);
}

get_console()->input_separator_out(true, false);
get_console()->separator_out(true, false);

get_console()->wait_for_key_press();
}
Expand Down Expand Up @@ -202,7 +202,7 @@ namespace hyenae::frontend::console::states
get_console()->error_out(_thread_exception->what(), true);
}

get_console()->input_separator_out(true, false);
get_console()->separator_out(true, false);

safe_delete(_dispatcher);

Expand Down

0 comments on commit 2f7a64b

Please sign in to comment.