https://github.com/hanilr/variation-ui
Single-header terminal user interface library. Written in ansi-c
https://github.com/hanilr/variation-ui
ansi-c c single-header single-header-lib terminal-user-interace tui ui user-interface
Last synced: 11 months ago
JSON representation
Single-header terminal user interface library. Written in ansi-c
- Host: GitHub
- URL: https://github.com/hanilr/variation-ui
- Owner: hanilr
- License: mit
- Created: 2022-04-08T18:03:25.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-02-28T09:57:20.000Z (over 1 year ago)
- Last Synced: 2025-04-04T04:35:06.713Z (about 1 year ago)
- Topics: ansi-c, c, single-header, single-header-lib, terminal-user-interace, tui, ui, user-interface
- Language: C
- Homepage:
- Size: 290 KB
- Stars: 21
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#  VARIATION UI 
Variation-ui is single-header terminal user interface library. Written in ansi-c. Simple to use, easy to learn and has small codebase. Also updatable thanks to MIT license (Look [license](#license) if you want to know more).
###  Dependencies:
* ` gcc ` _> Gnu Compiler Collection_
* ` make ` _> Gnu Make_
##  Important Note 
You need to define ` #define VN_UI_IMPLEMENTATION ` before ` #include "vn_ui.h" `
```c
#define VN_UI_IMPLEMENTATION
#include "vn_ui.h"
```
##  Example 
```c
#include
#include
#include
#define VN_UI_IMPLEMENTATION // Base features
#define VN_WIDGET // Widget features
#include "vn_ui.h"
int main()
{
/* Color declaring */
char* color_fg_red = vn_color("#e93737", 'f');
char* color_bg_blue = vn_color("#3737e9", 'b');
/* Text attribute */
VN_UI_TEXT vnt;
strcpy(vnt.color_fg, color_fg_red);
strcpy(vnt.color_bg, color_bg_blue);
strcpy(vnt.text_style, vn_text_bold);
/* Widget values */
VN_UI_WIDGET vnw;
vnw.pos_x = 2;
vnw.pos_y = 2;
vnw.width = 20;
vnw.height = 10;
/* UI Section */
vn_bg(' ', vnt, vnw); // Background
vn_gotoxy((vnw.pos_x + vnw.width) / 2, (vnw.pos_y + vnw.height) / 2); // Go to middle
vn_print("This is the example.", 'y', vnt.color_fg, vnt.color_bg, vnt.text_style); // Colourful printing
vn_gotoxy((vnw.pos_x + vnw.width), (vnw.pos_y + vnw.height)); // Go to end
// Free after use 'vn_color'
free(color_fg_red);
free(color_bg_blue);
return 0;
}
```
#  Compiling as shared-library or Using as default 
> Show make list `make` or `make run`
```
make run
```
 You can compile as shared-library and develope os specific projects. 
 How should I compile? 
```
make compile
```
> Unix shared-library (.so)
>
> Windows shared-library (.dll)
>
> If you want to delete this file you can use ` make clean `
 What if I want to use as default? 
```
make install
```
### [](doc/markdown/wiki.md) :  You can take a look to wiki page if you want learn more! 
#### Check Other Variation Libraries
* [Variation: Binary](https://github.com/hanilr/variation-bin) - A binary analysis library in Ansi-C.