cdk_draw(3)

πŸ“¦
version 5.0.20260119 Β· 2 versions
, in debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– cdk_draw β€” Cdk drawing functions πŸ’–

okay bestie, welcome to cdk_draw(3) from the Cdk library calls girlies ✨ this is the page where we learn how to actually draw stuff on a window β€” boxes, lines, shadows, strings with vibes β€” so grab your WINDOW * and let's go πŸŽ€


✨ SYNOPSIS ✨

cc [ flag ... ] file ...  -lcdk [ library ... ]

#include <cdk.h>

void boxWindow (
               WINDOW *window,
               chtype attr);

void attrbox ( WINDOW *win,
               chtype tlc,
               chtype trc,
               chtype blc,
               chtype brc,
               chtype horz,
               chtype vert,
               chtype attr);

void drawObjBox (
               WINDOW *win,
               CDKOBJS *object);

void drawLine (
               WINDOW *window,
               int startx,
               int starty,
               int endx,
               int endy,
               chtype line);

void drawShadow (
               WINDOW *shadowWin);

void writeBlanks (
               WINDOW *window,
               int xpos,
               int ypos,
               int align,
               int start,
               int end);

void writeChar (
               WINDOW *window,
               int xpos,
               int ypos,
               char *string,
               int align,
               int start,
               int end);

void writeCharAttrib (
               WINDOW *window,
               int xpos,
               int ypos,
               char *string,
               chtype attr,
               int align,
               int start,
               int end);

void writeChtype (
               WINDOW *window,
               int xpos,
               int ypos,
               chtype *string,
               int align,
               int start,
               int end);

void writeChtypeAttrib (
               WINDOW *window,
               int xpos,
               int ypos,
               chtype *string,
               chtype attr,
               int align,
               int start,
               int end);

🌈 DESCRIPTION 🌈

These functions perform useful drawing and attribute operations. that's it, that's the whole thesis πŸ’… a lil toolkit of box-drawing, line-drawing, shadow-having, string-writing icons, and honestly? they ate 🫢


πŸ¦‹ AVAILABLE FUNCTIONS πŸ¦‹

🌸 boxWindow

draw a box with on the window win. Like attrbox, this function ORs attr with each character as it draws the box.

ngl the docs literally say "draw a box with on the window" β€” we are NOT the ones editing that, we just pass it along, no cap πŸ’€

🌸 attrbox

draw a box with on the window win, letting the caller define each element of the box. so like, you're the designer, bestie, you pick every single corner πŸ‘‘

The parameters tlc, trc, blc, brc are used for the top-left, top-right, bottom-left and bottom-right corners respectively. The parameters horz and vert are used for the horizontal and vertical sides of the box. Any of these parameters may be zero. In that case, the function skips the corresponding element of the box. gone, ghosted, not invited to the party πŸ™ˆ

The function ORs attr with each character as it draws the box.

🌸 drawObjBox

Draw a box around the given window win using the object's defined line-drawing characters. it's giving "the object already picked its outfit, you just wear it" ✨

🌸 drawLine

draw a line on the given window.

The parameters starty, startx are the starting coordinates. The parameters endy, endx are the ending coordinates. The function writes the data in line to each coordinate in that range including the start/end coordinates.

The function handles lines other than vertical or horizontal, but normally it is used for that, e.g., with line set to ACS_HLINE or ACS_VLINE. diagonal slay is technically possible, horizontal/vertical is just the everyday lewk πŸ”₯

🌸 drawShadow

draw a shadow on the right and bottom edges of a window. dramatic lighting, main character energy, lowkey iconic 🌚

🌸 writeBlanks

write a string of blanks, using writeChar. The parameters are passed to writeChar as is. There is no corresponding writeBlanksAttrib function. nope, not a thing, don't go looking for it bestie 😭

🌸 writeChar

writes out a char * string without adding attributes. The parameters are passed to writeCharAttrib as is. plain, unbothered, moisturised, in its lane πŸ’–

🌸 writeCharAttrib

writes out a char * string with the given attributes added. The string is written to the given window, using its relative screen coordinates ypos and xpos.

Compare with writeChtypeAttrib, which writes a chtype * string. two sisters, different types, same energy 🫢

The function ORs the attribute attr with each item from the string. For instance, it may be A_BOLD. The align parameter controls whether it is written horizontally (HORIZONTAL) or vertically (VERTICAL).

Finally, only a subset of the string is written. The function starts with the data from the start item of string, and ends before the end item. If start is greater than, or equal to end, no data is written. zero. nada. the void. πŸ•³οΈ

🌸 writeChtype

writes out a chtype * string without adding attributes. The parameters are passed to writeChtypeAttrib as is.

🌸 writeChtypeAttrib

writes out a chtype * string with the given attributes added. The string is written to the given window, using its relative screen coordinates ypos and xpos. You would normally construct the string from a char * string using char2Chtype (3). that's the glow-up pipeline, fr fr ✨

The function ORs the attribute attr with each item from the string. For instance, it may be A_BOLD. The align parameter controls whether it is written horizontally (HORIZONTAL) or vertically (VERTICAL).

Finally, only a subset of the string is written. The function starts with the data from the start item of string, and ends before the end item. If start is greater than, or equal to end, no data is written.


πŸ‘‘ SEE ALSO πŸ‘‘


okay that's the whole page bestie, go forth and draw boxes that are genuinely gorgeous πŸŒΈπŸ’…

sign-off szn πŸŽ€ this lil masterpiece is from the Cdk library, version/date stamped 2024-03-28, and the page itself is cdk_draw(3) β€” mwah, obsessed, bye πŸ¦‹πŸ’œ