init_color(short color_number, short r, short g, short b) uses values from 0 to 1000, not 255.
Custom colors are global: once you redefine COLOR_GREEN, that's what it means from now on.
#include <curses.h>
#include <ncurses.h>
int main() {
initscr();
// check for color support
if (!has_colors() || !can_change_color()) {
printw("Your terminal does not support colors.");
getch();
return 1;
}
start_color();
// Query how many you get
printw("COLORS : %d\n", COLORS);
printw("COLOR_PAIRS : %d\n", COLOR_PAIRS);
// Redefine COLOR_CYAN
init_color(COLOR_CYAN, 1000, 200, 800);
init_pair(1, COLOR_CYAN, COLOR_BLACK);
attron(COLOR_PAIR(1));
printw("Custom color magenta-ish cyan?\n");
attroff(COLOR_PAIR(1));
getch();
endwin();
return 0;
}
// function to add / remove lines
#include <curses.h>
int main() {
initscr();
noecho();
WINDOW *win = newwin(4, 25, 5, 5);
refresh();
wrefresh(win);
mvwprintw(win, 0, 0, "1 Line of Text here");
mvwprintw(win, 1, 0, "2 Line of Text here");
mvwprintw(win, 2, 0, "3 Line of Text here");
mvwprintw(win, 3, 0, "4 Line of Text here");
wmove(win, 1, 0);
wgetch(win);
// inserts a line wherever the cursor it. needs a wmove().
// Moves every other lines -1
// winsertln(win);
// deletes the line, again at the position determined by wmove()
// also moves other lines
wdeleteln(win);
// deletes or inserts lines, determined by the second int argument
// (positive int to add, negative int to remove).
winsdelln(win, -2);
// No more room for lines? the bottom ones gets deleted first.
wgetch(win);
endwin();
return 0;
}