Skip to content

Commit 9cfff16

Browse files
committed
simple_spectrum: added more documentation comments
1 parent 37bfdc3 commit 9cfff16

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

examples/simple_spectrum.d

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,57 @@
1+
//simple_spectrum: Sample of 256-colour ncurses output in D.
12
//Modified by: Wyatt
23

34
import std.stdio: writeln;
45
import std.conv;
56
import deimos.ncurses.ncurses;
67

8+
//Extended colour support was added in ncurses 5.5 for the wncurses
9+
//library. wncurses has generally been shipped by default in Linux
10+
//distros for roughly the last decade as of this writing (often as the
11+
//only version installed); if this doesn't work, check that your TERM
12+
//is compatible with 256-colour modes, that your terminal emulator
13+
//supports it, and that your copy of ncurses is built with
14+
//--enable-ext-colors. If the latter is false, you may wish to file a
15+
//bug with your distro.
16+
717
int main()
818
{
9-
initscr(); //Start curses mode
19+
initscr();
1020
if(has_colors() == false)
1121
{
1222
endwin();
1323
writeln("Your terminal does not support color...");
1424
return 1; //ends the program
1525
}
16-
start_color(); // Start color
26+
start_color();
1727
foreach(ushort i; 0 .. 256){ // Define all the colours with the default palette
1828
init_pair(i, 0, i); // We're only setting the background here;
1929
} // The space is rendered as nothing.
30+
2031
auto w = COLS/9; // Let's just fill all the horizontal space
32+
33+
// Basic colours
2134
foreach(ushort i; 0 .. 16){
2235
attron(COLOR_PAIR(i));
2336
mvwhline(stdscr, cast(int)(i%8),w*(i/8),to!size_t(' '),w);//chtype is a size_t by spec.
2437
attroff(COLOR_PAIR(i));
2538
}
26-
//foreach(ushort i; 8 .. 16){
27-
//attron(COLOR_PAIR(i));
28-
//mvwhline(stdscr, cast(int)(i-8),5,to!size_t(' '),5);
29-
//attroff(COLOR_PAIR(i));
30-
//}
39+
40+
// 6x6x6 cubemap
3141
foreach(ushort i; 16 .. 232){
3242
attron(COLOR_PAIR(i));
3343
mvwhline(stdscr, cast(int)((i-16)%36),(2*w+w*((i-16)/36)),to!size_t(' '),w);
3444
attroff(COLOR_PAIR(i));
3545
}
46+
47+
// Greyscale
3648
foreach(ushort i; 232 .. 256){
3749
attron(COLOR_PAIR(i));
3850
mvwhline(stdscr, cast(int)(i-232),(8*w),to!size_t(' '),w);
3951
attroff(COLOR_PAIR(i));
4052
}
41-
wmove(stdscr, LINES-1, COLS-1);
53+
54+
wmove(stdscr, LINES-1, COLS-1);//Moving this out of the way
4255
getch();
4356
endwin();
4457

0 commit comments

Comments
 (0)