Skip to content

miamore / development with miamore

Editors note: This Library is not functionable alone, add to your existing project.

Terminal window
# Include the libmiamore (miamore) for compilation
clang src/PROJECT_NAME -lmiamore -o PROJECT_NAME

The 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.

First install the library into your current Rust project

Terminal window
cargo add miamore

Or add the following to your Cargo.toml file.

miamore = "0.1.0"
extern unsigned int window_width;
extern unsigned int window_height;

Editors note: The current window width and height
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

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.


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

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.


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

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.

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.

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.


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.


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().


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.


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.


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

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