this post was submitted on 21 Aug 2025
1 points (100.0% liked)

General Programming Discussion

9929 readers
2 users here now

A general programming discussion community.

Rules:

  1. Be civil.
  2. Please start discussions that spark conversation

Other communities

Systems

Functional Programming

Also related

founded 7 years ago
MODERATORS
 

Hello everyone!

I decided to learn ncurses a few days ago so I can do a project I've been thinking about lately, and in the process I figured since I'll go to the trouble of solving a bunch of the problems with writing relatively complicated TUIs with ncurses, I might as well generalise the solutions into a library or two for future me and anyone else who will find them useful.

Anyway, enough introduction, heres what I want to do with the library:

I want it to dynamically manage size and position of ncurses windows. This means windows should be able to be added, and removed (just those for now, I don't know if I'll implement resizing windows from the perspective of someone using the library to have that functionality), and have the size and position of the windows update automatically.

Initially I thought a binary space partitioning tree situation might be a good way to tackle this, but I want it to be a bit more flexible. For example, the dev using the library should be able to set certain windows to behave differently than leaves in a bsp (think persistent status bar at the bottom of the application, taking up the entire width but only a couple lines in height for example, or toggle-able file explorer on the left/right of the application like neovim's NERDTree).

How would you guys go about designing something like this, while still keeping the code relatively simple and efficient?

Here is a badly drawn diagram of what I mean:

Steps here refer to how someone using the library might go about creating each element (window) of their UI in their own project.

Until step 4 a bsp tree makes sense, but after that when I want to add a window which doesnt conform to the rules of a bsp tree, it gets a bit difficult.

Also, Im thinking there should be some way for windows to have some idea of their neighbours so that when a change occurs, they can adapt to it.

Anyways, essentially I'm looking for your thoughts on how you would go about implementing something like this.

Much appreciated!

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here