alecAbstraction Layer for Escape Codes |
git clone git://git.dimitrijedobrota.com/alec.git |
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING |
commit | b02e0ba34e3a27238bfa660bedf1e87fb6313f15 |
parent | 15a08272ab5daa5b79e57b254e06957053603d57 |
author | Dimitrije Dobrota < mail@dimitrijedobrota.com > |
date | Sat, 7 Jun 2025 17:24:57 +0200 |
Version 0.2
M | README.md | | | ++++++++++ ------------------------------------------------------------------------ |
M | vcpkg-configuration.json | | | + - |
2 files changed, 13 insertions(+), 99 deletions(-)
diff --git a/ README.md b/ README.md
@@ -9,22 +9,11 @@
of ANSI Escape Codes from C++ project. It exports a set of template variables
to be used when the content is known at compile time, as well as a set of
functions to be used at run-time.
Since there are two set of functionalities I noticed a twofold code duplication
so I decided to add a preprocessing step that turns a bison-like config file
into the desired header, based on the set of simple rules. This step was not
100% necessary, and might be an overkill, but I wanted to experiment with this
concept for a while and now I have got the change.
Generator code shown here is written in flex and bison and can be easily
adapted for other use cases.
## Dependencies
* CMake 3.14 or latter
* Compiler with C++20 support (tested on clang version 16.0.5)
* Flex 2.6.4
* Bison 3.8.2
## Building and installing
@@ -40,7 +29,7 @@
Everything that this library provide is found in `alec` namespace.
Functions have names shown in the table below, whilst templates have suffix _v
and don't need to be called.
#### Available functions with short explanation
### Available functions with short explanation
| Name | parameters | Description |
|-------------------|---------------------|---------------------------------------------------|
@@ -78,29 +67,16 @@
and don't need to be called.
| paste_disable | | Turn off bracketed paste mode |
#### Enumeration
##### Ctrl
* BELL: Terminal bell
* BS: Backspace
* HT: Horizontal TAB
* LF: Linefeed (newline)
* VT: Vertical TAB
* FF: Formfeed
* CR: Carriage return
* ESC: Escape character
* DEL: Delete character
### Enumeration
##### Motion
#### Motion
* END: erase from cursor until end of screen/line
* BEGIN: erase from cursor to beginning of screen/line
* WHOLE: erase entire screen/line
##### Color
#### Color
* BLACK
* RED
@@ -113,7 +89,7 @@
and don't need to be called.
* DEFAULT
##### Decor
#### Decor
* RESET
* BOLD
@@ -126,81 +102,19 @@
and don't need to be called.
* STRIKE
## Configuration
Configuration file `alec.rules.hpp` is used to customize the output of
`alec.hpp` file. Similarly to Flex and Bison, configuration files needs to have
3 sections separated by `/*%%*/`: prologue, grammar and epilogue. Prologue and
epilogue are copied as-is to the output file whilst the grammar section
contains rules for generating template and function code.
* Rules can be separated by an arbitrary number of blank lines.
* Everything can have arbitrary indentation that is not carried to the resulting file.
* There could be C-style comments that are copied to the resulting file.
Each rule consists of 4 lines:
1. Name: name of the generated function, must be valid C++ name
2. Parameters: list of `type name` pairs separated by a comma
3. Constraints: list of constraint functions separated by a comma
4. Rules: list of chars and ints (or expressions producing them) separated by a
comma, or a single string literal
> You *must* use `|` character in place of empty list rule
### Constraints
* All constraints used in code generation must be defined in the prologue
* Every constraint listed will be applied to all of the arguments one by one.
* Every constraint has to have a function and template concept variant with the
same name, but suffix _v for the template one.
* Function constraints are translated into asserts, whilst template ones are used
in requires clause of the teconceptmplate.
### Examples
```c++
// begining of a header file
// tamplate constraint
template <int n>
concept limit_pos_v = n >= 0;
// function constraint
static inline bool limit_pos(int n) { return n >= 0; };
/*%%*//*
// comment that goes into output
decor_reset
Decor decor
|
(int)decor + 20, 'm'
screen_mode_set
int mode
limit_pos
'=', mode, 'h'
paste_enable
|
|
"?2004h"
*//*%%*/
## Contributing
// ending of a header file
```
See the [`CONTRIBUTING`](CONTRIBUTING.md) document.
## Version History
* 0.2
* Drop generation phase
* Modernize codebase
* Basic user input facilities
* 0.1
* Initial Release
## Contributing
See the [`CONTRIBUTING`](CONTRIBUTING.md) document.
* Initial development
## License
diff --git a/ vcpkg-configuration.json b/ vcpkg-configuration.json
@@ -8,7 +8,7 @@
{
"kind": "git",
"repository": "git://git.dimitrijedobrota.com/vcpkg-registry.git",
"baseline": "487d7c36bb87d45fb7f98f5bd6c7dd0bed9b8c08",
"baseline": "786b64a20fb1154200a454b8a3d12e318fcd117e",
"packages": [ "based" ]
}
]