You are browsing as a guest. Sign up (or log in) to start making projects!

shi

@shi

Joined June 28th, 2026

  • 4Devlogs
  • 1Projects
  • 0Ships
  • 0Votes
Hi!I'm shi, a seventeen y.o highschool student in italy, looking to share my projects, see cool projects made by other people and hopefully gain some stardust!
Open comments for this post

14h 14m 27s logged

Hi! finally finished making TUI menus for my app. I had some difficulties with menu sizing and accounting for borders and style while making it but when I finally figured out that issue it was pretty straightforward to implement everything.


What was interesting about all of this

In this part of development I’m really understanding the difficulties of creating things we take for granted, like menus or just simple boxes of text, implementing menu scrolling and other types of utilities to make them usable was a pain for sure, but it was also interesting to see my changes in code affecting something as immediate as graphics (well TUI graphics but still graphics non the less). This is the first time i programmed something that could be seen and used and it’s honestly pretty sweet.


The stars of the show

All this time I spent working on this was to implement mainly three functions: create_menu_handle, draw_menu and menu_driver, those three functions regulate how the menu looks, feels, and takes input:

menu_handle_t* create_menu_handle(WINDOW* parent, 
        const char* menu_label,
        point_t pos,
        int max_height,
        int pad_y,
        int pad_x,
        int n_options,
        const char** option_labels,
        void (**opt_funcs)(void*),
        void **opt_args,
        chtype menu_attrs,
        chtype menu_color,
        chtype highlight_attrs,
        chtype highlight_color,
        int inside_shading,
        enum MenuBorderTypes border,
        int mouse_enabled);

this is a beefy boy (look at all those parameters) but it’s pretty configurable and allows some real customization of your menu! It calculates available option space from the max height, and implements scrolling automatically

int draw_menu(menu_handle_t* menu);

Pretty much self explanatory, draws the menu and its borders.

int menu_driver(menu_handle_t* menu, int input_type, MEVENT* mouse);

Really cool function that given an input handles option selection/scrolling mechanics and highlighting of the selected option.

0
0
9
Open comments for this post

15h 20m 44s logged


Hi there guys! These are a lot of hours to log i know, but I swear I
have a reason!!


The main problem that took so long

When I started to work on the client I came accross the problem of
making a stable and working UI for it, and because I’m one of the
cool kids developing in C (this is me -> 🤓) I obviously had to go
for a TUI(Text User Interface) for street cred.

Nerdy stuff about library searching and linking

There i came accross the first real problem of the journey, wich library
do I use (because no way im gonna code all of that myself)??

While searching i came accross a second problem: NOBODY USES A TUI,
there are 0, and i mean 0 multi-platform libraries that work for
linux and windows because of console shenanigans.
I spent 2 hours + another 2 hours of changing the build pipe COMPLETELY
(goodbye MSVC, hi there gcc and ninja) to find something.

At last i went with NCurses for linux and PDCurses for windows,
and the coolest thing is that they have (almost) the same exact API,
so i just need to link them conditionally.

Now out of the way with nerdy stuff and hi there cool TUI graphical
stuff.


Hi there graphical elements!!

Now NCurses and PDCurses are mainly low level console libraries, in
short they allow you to manipulate the console and cursor however you
want (with some utility stuff).
but we need a good old UI, so we need textboxes, menus, input
fields
, etc.

while some of these exist for NCurses as addons, they dont for PDCurses, so i went with the bob the builder approach.
I’m spending this much time writing the UI elements, for now the only thing I can show for my work is a textbox element that with a couple of lines
of code can display text with: padding, colors and eventual attributes (bold, italic, etc…).

other than that i made some changes to
utils and added a really cool split_lines function that makes splitting on newline in C pretty easy.

Here’s a little preview of the textboxes!

the code:

    init_pair(1, COLOR_RED, COLOR_BLUE);
    textbox_t* my_txt = create_textbox(stdscr, POINT(0,0), PAD(1, 1, 1, 1), str, A_BOLD, COLOR_PAIR(1));
    if(!my_txt) {
        error("hell naw");
        return 1;
    }
    point_t centered = get_centered_pos(stdscr, my_txt->h, my_txt->w);
    move_text_box(my_txt, centered);
    if(draw_textbox(my_txt) == -1) error("ERR");
    getch();
    destroy_textbox(my_txt);

the result:

0
0
10
Open comments for this post

4h 23m 14s logged

Hi! Finished working on an interface beetwen the database and my server code, it was really too messy earlier. So i made an interface that manages caching and retrieving the data, the only downside is that the data it returns (pointers to the cache) is completely immutable outside of the interface, so for every update you necessarily need to call update_user or update_channel or appropriate caching functions, other than that it should work pretty well and i made my previous example 1000 times simpler (in the photos I’ll provide a before and after).


How i made it

So while coding this new interface I encountered some problems, first of all I’m gonna remind myself to never use databases in C, i really hate all that boilerplate :d. I decided to make the interface pretty specific on users and channels, if i ever need to add anything to my database it’s gonna be a pain but I dont plan to do that (outside of files but those will come later), I also decided to use arena’s to manage memory in the cached user and channel struct because it’s cleaner cleanup. For last I was going to make a check_credentials function for log in but i decided to do that later as I need to implement hashing and md5 and that will be another dependancy. I think the next feature I’m gonna work on is probably making a decent client, if I continue the server I’m gonna have a functioning server without a client to serve. Later guys!

0
0
8
Open comments for this post

5h 30m 32s logged

Hi there! This is my first devlog ever, so bear with me. It’s gonna be kinda long since this is a WIP project and I want to walk you through the codebase. This first devlog covers the pre-existing code and what I did in the ~5 hours I logged.


Overview

IOMessage is a centralized messaging CLI platform built entirely in C. Server and client are both meant to be multi-platform.
The app will implement:

  • channels (groups where users can share messages)
  • moderation capabilities (kick, mute, …)
  • file sharing
  • (maybe other things in the future)

Architecture

  • CommunicationManager: this module handles I/O for each connected client
  • ServerManager: this module handles requests and allows client communication
  • ThreadManager / NetworkManager: modules that handles OS abstraction

Thread communication: CommunicationManager and ServerManager talk through shared queues. Each CommunicationManager pushes incoming requests to a shared request queue, ServerManager pops them, processes them, and pushes responses back to that specific client’s response queue in a consumer-producer model.


What I’m working on

Done: CommunicationManager, ThreadManager, NetworkManager.
WIP: ServerManager mainly the channel and messaging feature so i can ship a demo.

Right now I need auth and channels working. I was facing the problem of storing user data past program exit. I considered files/folders, but linking data got messy fast, example: channels need to reference actual users by id so the server can identify the allowed users, and once channels and members live in separate files with changing data, it turns into a mess.

So I choose SQLite: i choose because it stores data in just a file (minimum complexity) and as solid C API. Spent a good two hours designing the schema (it was the first time I used a DB lol).

Then the hard part: seed the DB with some info, get the server to open it, print the channels, exit and read a looooot of docs. then after I started coding, i read the documentation bit by bit and slowly became horrified… THE BOILERPLATE WAS ABSOLUTELY GRUELING: 5 function calls per query, each one can fail, so for each function there are 5 lines of code Handling the error and freeing memory. I tried wrapper functions, I really tried, but it didn’t help much.

Still need to find a way to cut the boilerplate down. I’m a bit of a perfectionist and it’s killing me. But after a lot of fighting, reading, and debugging, it finally works and displays the seeded info about channels.(the code I’m showing is basically 70% boilerplate for sqlite, btw the i swear the application can talk to clients, handle bad client behaviour and serialize the protocol, i have it turned off for testing so the app quits immediately after reading data from the database tho).

0
0
9

Followers

Loading…