Fast and reasonably complete (framebuffer) terminal emulator (Zig fork)

Add flanterm_fb_simple_init() and add basic usage to README

mintsuki b1a2c69a 63359f43

Changed files
+50 -5
backends
-5
README
···
-
Flanterm
-
========
-
-
Flanterm is a fast and reasonably complete terminal emulator with support for
-
multiple output backends. Included is a fast framebuffer backend.
+29
README.md
···
+
# Flanterm
+
+
Flanterm is a fast and reasonably complete terminal emulator with support for
+
multiple output backends. Included is a fast framebuffer backend.
+
+
### Quick usage
+
+
To quickly set up and use a framebuffer Flanterm instance, it is possible to
+
use the `flanterm_fb_simple_init()` function as such:
+
```c
+
#include <flanterm/flanterm.h>
+
#include <flanterm/backends/fb.h>
+
+
struct flanterm_context *ft_ctx = flanterm_fb_simple_init(
+
framebuffer_ptr, framebuffer_width, framebuffer_height, framebuffer_pitch
+
);
+
```
+
Where `framebuffer_{ptr,width,height,pitch}` represent the corresponding info
+
about the framebuffer to use for this given instance.
+
+
To then print to the terminal instance, simply use the `flanterm_write()`
+
function on the given instance. For example:
+
```c
+
#include <flanterm/flanterm.h>
+
+
const char msg[] = "Hello world\n";
+
+
flanterm_write(ft_ctx, msg, sizeof(msg));
+
```
+21
backends/fb.h
···
size_t margin
);
+
#ifndef FLANTERM_FB_DISABLE_BUMP_ALLOC
+
static inline struct flanterm_context *flanterm_fb_simple_init(
+
uint32_t *framebuffer, size_t width, size_t height, size_t pitch
+
) {
+
return flanterm_fb_init(
+
NULL,
+
NULL,
+
framebuffer, width, height, pitch,
+
#ifndef FLANTERM_FB_DISABLE_CANVAS
+
NULL,
+
#endif
+
NULL, NULL,
+
NULL, NULL,
+
NULL, NULL,
+
NULL, 0, 0, 1,
+
1, 1,
+
0
+
);
+
}
+
#endif
+
#ifdef __cplusplus
}
#endif