Source Code File 15-01_cursset
15-01_cursset.c
#include <ncurses.h> int main() { initscr(); /* first, turn the cursor off */ curs_set(0); addstr(" <- The cursor has been turned off"); move(0,0); refresh(); getch(); /* second, turn the cursor on */ curs_set(1); addstr("\n <- The cursor now on"); move(1,0); refresh(); getch(); /* third, turn the cursor very on */ curs_set(2); addstr("\n <- The cursor is now very on"); move(2,0); refresh(); getch(); endwin(); return(0); }
Output Screenshot
(Click to cycle images.)
Notes
* In the sample output (above), you see the cursor turned off, then the cursor on. The cursor "very on" setting usually shows a solid or bright cursor, though the terminal emulator (iTerm on the Mac) doesn't support that setting in the configuration I used.
* The only terminal emulator where I've gotten this code to work completely is a novelty program called Cathode, available for the Macintosh. Cathode delightfully emulates old video terminals, complete with phosphor burn-in and flickering. When run on Cathode, curs_set(0)
turns off the cursor, curs_set(1)
shows the standard, blinking cursor, and curs_set(2)
disables the cursor's blinking.
* By the way, I used a screenshot of Cathode for the eBook's cover.
Copyright © 1997-2024 by QPBC.
All rights reserved