mirror of
https://github.com/mintsuki/flanterm
synced 2024-11-27 07:09:40 +03:00
Add flanterm_fb_simple_init() and add basic usage to README
This commit is contained in:
parent
63359f43d4
commit
b1a2c69aea
5
README
5
README
@ -1,5 +0,0 @@
|
||||
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
Normal file
29
README.md
Normal file
@ -0,0 +1,29 @@
|
||||
# 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));
|
||||
```
|
@ -123,6 +123,27 @@ struct flanterm_context *flanterm_fb_init(
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user