started implementing a configuration
This commit is contained in:
1 parent
38130ab1d9
commit
8ed2407463
5 files changed
+42
-13
No files matched your search
@@ -38,7 +38,8 @@ C_SRC := main.c \
|
||||
log.c \
|
||||
arguments.c \
|
||||
stringing.c \
|
||||
sorting.c
|
||||
sorting.c \
|
||||
format.c
|
||||
|
||||
C_FLAGS := -std=c11 \
|
||||
$(WG) \
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/* ------------------------------------------------------------------
|
||||
* -- project: SCAN
|
||||
* -- description: abstraction for terminal control sequences
|
||||
* ------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef __CONFIG_H
|
||||
#define __CONFIG_H
|
||||
|
||||
#include "format.h"
|
||||
|
||||
/* -- colour and style configuration */
|
||||
#define DIR_STYLE_NUM ( ( int )1 )
|
||||
const style_t directory_style[DIR_STYLE_NUM] = { style_bold };
|
||||
const uint32_t directory_colour = 0x6CA05C;
|
||||
|
||||
#endif
|
||||
+5
-5
@@ -7,12 +7,11 @@
|
||||
#ifndef __FORMAT_H
|
||||
#define __FORMAT_H
|
||||
|
||||
#include "stdint.h"
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
/* -- defines */
|
||||
#define NUMBER_STYLES ( ( int )8 )
|
||||
#define NUMBER_COLOURS ( ( int )9 )
|
||||
#define ESCAPE "\x1b"
|
||||
#define SEQUENCE_PREFIX ESCAPE"["
|
||||
#define SEQUENCE_SUFFIX "m"
|
||||
@@ -26,7 +25,8 @@ typedef enum {
|
||||
style_blinking,
|
||||
style_reversed,
|
||||
style_invisible,
|
||||
style_strikethrough
|
||||
style_strikethrough,
|
||||
style_end = NUMBER_STYLES
|
||||
} style_t;
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ extern const uint8_t STYLE_RESET[ NUMBER_STYLES ];
|
||||
|
||||
/* -- function prototypes */
|
||||
void format_clear( void );
|
||||
void format_set_style( style_t* styles, uint8_t number_styles );
|
||||
void format_reset_style( style_t* styles, uint8_t number_styles );
|
||||
void format_set_style( const style_t* const styles, uint8_t number_styles );
|
||||
void format_reset_style( const style_t* const styles, uint8_t number_styles );
|
||||
void format_set_fg_colour( uint32_t colour );
|
||||
void format_set_bg_colour( uint32_t colour );
|
||||
void format_clear_fg_colour( void );
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ void format_clear( void )
|
||||
fprintf( stdout, SEQUENCE_PREFIX"0"SEQUENCE_SUFFIX );
|
||||
}
|
||||
|
||||
void format_set_style( style_t* styles, uint8_t number )
|
||||
void format_set_style( const style_t* const styles, uint8_t number )
|
||||
{
|
||||
if ( NUMBER_STYLES < number )
|
||||
return;
|
||||
@@ -34,7 +34,7 @@ void format_set_style( style_t* styles, uint8_t number )
|
||||
fprintf( stdout, SEQUENCE_SUFFIX );
|
||||
}
|
||||
|
||||
void format_reset_style( style_t* styles, uint8_t number )
|
||||
void format_reset_style( const style_t* const styles, uint8_t number )
|
||||
{
|
||||
if ( NUMBER_STYLES < number )
|
||||
return;
|
||||
|
||||
+16
-5
@@ -18,6 +18,8 @@
|
||||
#include "arguments.h"
|
||||
#include "type_definitions.h"
|
||||
#include "sorting.h"
|
||||
#include "format.h"
|
||||
#include "config.h"
|
||||
|
||||
// macro definitions
|
||||
#define SUCCESS 0
|
||||
@@ -378,11 +380,20 @@ int display_directory_contents(
|
||||
tree[ 4 * recursion_level + 2 ] = '-';
|
||||
tree[ 4 * recursion_level + 3 ] = ' ';
|
||||
|
||||
log_info(
|
||||
"%s%s",
|
||||
tree,
|
||||
entry->name
|
||||
);
|
||||
fprintf( stdout, "%s", tree );
|
||||
|
||||
if ( entry->type == type_directory )
|
||||
{
|
||||
format_set_style( directory_style, DIR_STYLE_NUM );
|
||||
format_set_fg_colour( directory_colour );
|
||||
}
|
||||
fprintf( stdout, "%s", entry->name );
|
||||
if ( entry->type == type_directory )
|
||||
{
|
||||
format_reset_style( directory_style, DIR_STYLE_NUM );
|
||||
format_clear_fg_colour();
|
||||
}
|
||||
fprintf( stdout, "\n" );
|
||||
|
||||
if ( recursion_level < args->depth
|
||||
&& entry->type == type_directory )
|
||||
|
||||
Reference in new issue
Block a user