tiny-shell 0.2
A mini shell project aiming to gain knowledge about Win32 and Linux API
|
#include "io_wrap.h"
#include "../os/operations.h"
#include "config.h"
#include "utils.h"
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
Go to the source code of this file.
Macros | |
#define | COLOR_GREEN "\033[32m" |
#define | COLOR_YELLOW "\033[33m" |
#define | COLOR_RED "\033[31m" |
#define | COLOR_BLUE "\033[34m" |
#define | COLOR_BLACK "\033[30m" |
#define | COLOR_WHITE "\033[97m" |
#define | COLOR_DEFAULT (*io_use_white_text() ? COLOR_WHITE : COLOR_BLACK) |
Functions | |
static bool * | io_use_white_text () |
enum run_result * | last_run_status () |
void | io_set_last_status (enum run_result result) |
Set the result of last command (RUN_OK/RUN_FAIL/...) | |
void | io_set_text_white () |
Set default text color to white. | |
bool * | is_prompt_visible () |
void | io_set_prompt_visibility (bool visible) |
Config if prompt should be printed. | |
void | prompt_input () |
void | scan_input (struct cmd *obj) |
Ask and convert user's input into command. | |
void | format_usage (char *fmt,...) |
Used format_xxx instead of printf and such for uniform output. | |
void | format_success (char *fmt,...) |
Used format_xxx instead of printf and such for uniform output. | |
void | format_output (char *fmt,...) |
Used format_xxx instead of printf and such for uniform output. | |
void | format_error (char *fmt,...) |
Used format_xxx instead of printf and such for uniform output. | |
#define COLOR_BLUE "\033[34m" |
Definition at line 14 of file io_wrap.c.
Referenced by prompt_input().
#define COLOR_DEFAULT (*io_use_white_text() ? COLOR_WHITE : COLOR_BLACK) |
Definition at line 18 of file io_wrap.c.
Referenced by format_error(), format_output(), format_success(), format_usage(), and prompt_input().
#define COLOR_GREEN "\033[32m" |
Definition at line 11 of file io_wrap.c.
Referenced by format_success().
#define COLOR_RED "\033[31m" |
Definition at line 13 of file io_wrap.c.
Referenced by format_error(), and prompt_input().
#define COLOR_YELLOW "\033[33m" |
Definition at line 12 of file io_wrap.c.
Referenced by format_usage().
void format_error | ( | char * | fmt, |
... ) |
Used format_xxx
instead of printf
and such for uniform output.
Definition at line 89 of file io_wrap.c.
References COLOR_DEFAULT, COLOR_RED, and support_color().
Referenced by add_path(), cmd_init_from_str(), main(), split_by_whitespaces(), and transform_quotes().
void format_output | ( | char * | fmt, |
... ) |
Used format_xxx
instead of printf
and such for uniform output.
Definition at line 80 of file io_wrap.c.
References COLOR_DEFAULT, and support_color().
Referenced by run_get_all_env(), run_get_env(), and run_help().
void format_success | ( | char * | fmt, |
... ) |
Used format_xxx
instead of printf
and such for uniform output.
Definition at line 69 of file io_wrap.c.
References COLOR_DEFAULT, COLOR_GREEN, and support_color().
Referenced by add_path(), invoke_runner(), and main().
void format_usage | ( | char * | fmt, |
... ) |
Used format_xxx
instead of printf
and such for uniform output.
Definition at line 57 of file io_wrap.c.
References COLOR_DEFAULT, COLOR_YELLOW, and support_color().
Referenced by cmd_init_from_str().
void io_set_last_status | ( | enum run_result | result | ) |
Set the result of last command (RUN_OK/RUN_FAIL/...)
Definition at line 29 of file io_wrap.c.
References last_run_status().
Referenced by main().
void io_set_prompt_visibility | ( | bool | visible | ) |
Config if prompt should be printed.
Definition at line 42 of file io_wrap.c.
References is_prompt_visible().
Referenced by main().
void io_set_text_white | ( | ) |
Set default text color to white.
Definition at line 33 of file io_wrap.c.
References io_use_white_text().
Referenced by main().
|
static |
Definition at line 19 of file io_wrap.c.
Referenced by io_set_text_white().
bool * is_prompt_visible | ( | ) |
Definition at line 37 of file io_wrap.c.
Referenced by io_set_prompt_visibility(), and prompt_input().
enum run_result * last_run_status | ( | ) |
Definition at line 24 of file io_wrap.c.
References RUN_OK.
Referenced by io_set_last_status(), and prompt_input().
void prompt_input | ( | ) |
Definition at line 101 of file io_wrap.c.
References COLOR_BLUE, COLOR_DEFAULT, COLOR_RED, CWD_BUFFER_SIZE, get_cwd(), is_prompt_visible(), last_run_status(), RUN_EXIT, RUN_FAILED, RUN_OK, and support_color().
Referenced by scan_input().
void scan_input | ( | struct cmd * | obj | ) |
Ask and convert user's input into command.
Definition at line 47 of file io_wrap.c.
References cmd_init_from_str(), INPUT_BUFFER_SIZE, and prompt_input().
Referenced by main().