set_cursor_drawer(3)
π set_cursor_drawer π
okay so bestie, welcome to the gstream manual, and today's main character is set_cursor_drawer β the glow-up your cursor has been waiting for β¨
πΈ NAME πΈ
set_cursor_drawer β like, literally the function that lets you pick who draws your cursor π
β¨ SYNOPSIS β¨
#include <gstream.h>
void set_cursor_drawer(void (*cd)(BITMAP *, int, int, int, int, int,
bool));
π¦ DESCRIPTION π¦
so what this does is it sets the function that draws the cursor. it's giving "customize your cursor with your own fave little guy" energy β and yeah, that little guy can absolutely be a BITMAP if that's your vibe π
but listen, no cap: before you can actually use that cursor for inputting, you also have to call set_cursor_dimensions with the width and height of your cursor β and you gotta do it for both insert mode and overwrite mode. both. don't skip one, i'm begging π
so here's the tea on the drawer function's parameters:
- destination bitmap β the
BITMAPyou're drawing on πΌοΈ - x-coordinate π
- y-coordinate π
- the width β and if you passed
gbuf::DYNAMIC_CURSOR_SIZE, this is the width of the character under the cursor; otherwise it's the width you specified - the height β same deal as the width, ditto π«Ά
- the colour of the font β β οΈ watch out for a
-1! she's tricky! - whether in insert mode β
trueif so β
here's a simple lil example of a standard console cursor, iconic behavior:
void cd_cons(BITMAP *bmp, int x, int y, int w, int h, int c, bool ins)
{
int colour;
// determine colour (defaults to black if no colour specified)
if (c == -1)
colour = makecol_depth(bitmap_color_depth(bmp), 0, 0, 0);
else
colour = c;
if (ins) // if it is the insert cursor
rectfill(bmp, x, y + h - 2, x + w - 1, y + h - 1, colour);
else // else overwrite cursor
rectfill(bmp, x, y, x + w - 1, y + h - 1, colour);
}
okay and here's the part where you can fully relax: you do not have to think about flashing the cursor or any of those other pecularities β the gstream handles all of that for you, bestie π§ all you gotta do is construct a function that draws something on the specified BITMAP, at the specified position, and doesn't go past the specified width and height. that's it. that's the whole job.
and yes, you are of course free to ignore the colour and the insert parameter β go off, do your thing π
β οΈ but fr fr: make sure you don't draw outside the given rectangle. if you do, the gstream can't recover the background and the result will be artifacts. and not the cute kind of artifacts. the bad kind. π
little quality-of-life moment: there's a typedef, 'cursor_drawer', in 'gbuf', and it makes declaring pointers to this type of function sooo easy:
gbuf::cursor_drawer tmp_cd;
//...
tmp_cd = gs1.get_cursor_drawer();
gs1.set_cursor_drawer(gs2.get_cursor_drawer());
gs2.set_cursor_drawer(tmp_cd);
(not me writing a whole lil swap routine, we love to see it π₯)
and the default cursor drawer? that's 'cd_winconsole'. the OG. π
π SEE ALSO π
and that's the whole page, bestie!! π this one's from the gstream manual, version 1.6, and it's the set_cursor_drawer(3) page β go forth and make your cursor absolutely stunning πβ¨π¦πΈπ
π¦ where this page comes from
- fedora 43: gstream-devel 1.6-35.fc43 Β· Giftware
- fedora 43: gstream-devel 1.6-35.fc43 Β· Giftware
- fedora 44: gstream-devel 1.6-36.fc44 Β· Giftware
- fedora 44: gstream-devel 1.6-36.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms