miamore / development with miamore
Using miamore:
Section titled “Using miamore:”Linking to C code
Section titled “Linking to C code”# Include the libmiamore (miamore) for compilationclang src/PROJECT_NAME -lmiamore -o PROJECT_NAMEThe example shows clang but can be swapped out interchangeably with gcc.
Replace "PROJECT_NAME" with your project name. All code presented is drag-and-droppable.
Using in Rust
Section titled “Using in Rust”First install the library into your current Rust project
cargo add miamoreOr add the following to your Cargo.toml file.
miamore = "0.1.0"Global Definitions/Variables:
Section titled “Global Definitions/Variables:”window_*
Section titled “window_*”extern unsigned int window_width;extern unsigned int window_height;Editors note: The current window width and height
cursor_*
Section titled “cursor_*”extern unsigned int cursor_x;extern unsigned int cursor_y;Editors note: The current cursor x and y
#define SECONDS(s) ((seconds_t)(s))#define MS(m) ((seconds_t)((m) / 1000.0))Editors note: The macros can be used in the wait_for() function
char *give_color(colors_t color);Editors note: Returns char array (char*) should not be used stand-alone
Type Definitions:
Section titled “Type Definitions:”cursor_t
Section titled “cursor_t”The typedef in C.
typedef enum { hide, show, move,} cursor_t;This is type cursor_t is used in functions like manage_cursor() to allow the user to specify what the cursor should do in that current moment.
keys_t
Section titled “keys_t”The typedef in C.
typedef enum { disable, enable} keys_t;This is type keys_t is used in the function manage_keys() to allow the user to specify disable or enable the keyboard.
Editors note: Can be used if things like TUI based games or system monitors
position_t
Section titled “position_t”The typedef in C.
typedef struct { int x; int y;} position_t;This is type position_t is used in functions like manage_cursor() or draw_shape()’s ShapeOptions structure to allow the user to specify the x(row) and y(col) the cursor should be at in the terminal window.
shape_t
Section titled “shape_t”The typedef in C.
typedef enum { rect,} shape_t;This is type shape_t is used in functions like draw_shape() which allows shapes to be specified to be drawn to the screen.
Editors note: More shapes will be added in later updates, currently only rect is supported
theme_t
Section titled “theme_t”The typedef in C.
typedef enum { single_l, double_l, thick_l, round_l, blocky_l} theme_t;This is type theme_t is used in functions like draw_shape(), init_miamore() and draw_border() which allows the developer to specify the type of line that gets used to create that shape.
Line types
Section titled “Line types”static const char *THEME_STR[][6] = { // 0 1 2 3 4 5 [single_l] = {"┌", "┐", "└", "┘", "─", "│"}, [double_l] = {"╔", "╗", "╚", "╝", "═", "║"}, [thick_l] = {"┏", "┓", "┗", "┛", "━", "┃"}, [round_l] = {"╭", "╮", "╰", "╯", "─", "│"}, [blocky_l] = {"█", "█", "█", "█", "█", "█"},};Editors note: More line types may be added in future along with custom line support.
Editors note: Dev has no access to this structure as it is strictly for internal use currently.
dimensions_t
Section titled “dimensions_t”The typedef in C.
typedef struct { int width; int height;} dimensions_t;This is type dimensions_t is used in functions like draw_shape() which allows the developer to specify the dimensions width and height that gets used to create that shape.
seconds_t
Section titled “seconds_t”The typedef in C.
typedef double seconds_t;This is type seconds_t is used in wait_for(), it can take both MS(m) -> miliseconds and SECONDS(s) -> seconds.
colors_t
Section titled “colors_t”The typedef in C.
typedef enum colors_t { red, orange, yellow, green, blue, pink, purple, cyan, magenta, black, white,} colors_t;This is type colors_t is used in various functions such as set_fg(), set_bg() and *give_color().
MiamoreOptions
Section titled “MiamoreOptions”The typedef in C.
typedef struct { bool should_clear; bool disable_mouse;} MiamoreOptions;This is type MiamoreOptions is used in init_miamore(), to set default functionality for the developer. Allowing them so speficy if should_clear -> should clear the terminal window when starting the TUI, disable_mouse -> should disable the mouse in the TUI when starting the TUI.
ShapeOptions
Section titled “ShapeOptions”The typedef in C.
typedef struct { theme_t theme; dimensions_t dimensions; position_t position;} ShapeOptions;This is type ShapeOptions is used in draw_shape(), to set variables to be used when creating the shape. Allowing developers to set theme_t -> the theme/type of line the shape should use, the dimensions_t -> dimensions of the shape width and height.
BorderOptions
Section titled “BorderOptions”The typedef in C.
typedef struct { char *text; theme_t theme;} BorderOptions;This is type BorderOptions is used in draw_border(), to set variables to be used when creating the border. Allowing developers to set theme_t -> the theme/type of line the shape should use and set text which will show as the title at the top of the terminal window.
Editors note: Functions can be found on the next page
License
Section titled “License”This project is licensed under the GNU LESSER GENERAL PUBLIC LICENSEThe GNU Lesser General Public License is used in some Ametrine projects - see the LICENSE file for details or see the license on here