Skip to content

Commit c01f529

Browse files
committed
removed useless comments and fixed a few minor issues.
1 parent 12e3f98 commit c01f529

File tree

6 files changed

+130
-140
lines changed

6 files changed

+130
-140
lines changed

examples/acs_vars.d

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//regretfully modified by: 1100110
21

32
import std.string: toStringz;
43
import curses;

examples/hello_world.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
*
1212
* Modified by: 1100110
1313
*/
14-
import std.string: toStringz; //I don't need anything but toStringz()
15-
import ncurses; //Your inport path might(will) be different
14+
import std.string: toStringz;
15+
import ncurses;
1616

1717
void main()
1818
{ //toStringz returns immutable char* Which is what most of these

examples/mouse_menu.d

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/* Modified by: 1100110
2-
* This one looks fun...
3-
*/
1+
42
import std.string: toStringz;
53
import ncurses;
64

@@ -24,12 +22,12 @@ void main()
2422
noecho();
2523
cbreak();
2624
keypad(stdscr, true);
27-
scope(exit) endwin(); //I'm not entirely sure...
25+
scope(exit) endwin();
2826

2927
startx = (80 - WIDTH) / 2;
3028
starty = (24 - HEIGHT) / 2;
3129

32-
attron(A_REVERSE); //not entirely sure...
30+
attron(A_REVERSE);
3331
mvprintw(23, 1, toStringz("Click on Exit to quit"));
3432
attroff(A_REVERSE);
3533
refresh();
@@ -40,10 +38,7 @@ void main()
4038

4139
print_menu(menu_win, 1);
4240

43-
//while_loop: I'm not entirely sure why this was in there...
44-
//oh god, please tell me he isn't using labels... he is...
45-
//trying to route around it...
46-
//failing miserably...
41+
4742
c = wgetch(menu_win);
4843
while(c != -1)
4944
{

examples/other_border.d

Lines changed: 92 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,122 @@
1-
//Modified by: 1100110
2-
//exercise: make "Press F1" not disappear.
3-
41
import std.string: toStringz;
52
import ncurses;
63

74
struct WIN_BORDER
85
{
9-
chtype ls, rs, ts, bs, tl, tr, bl, br;
6+
chtype ls, rs, ts, bs, tl, tr, bl, br;
107
}//struct WIN_BORDER
118

129
struct WIN
1310
{
14-
int startx, starty;
15-
int height, width;
16-
WIN_BORDER border;
11+
int startx, starty;
12+
int height, width;
13+
WIN_BORDER border;
1714
}
1815

1916
void main()
20-
{ WIN win;
21-
int ch;
17+
{ WIN win;
18+
int ch;
19+
20+
initscr(); //Start curses mode
21+
start_color(); //Start the color functionality
22+
cbreak(); //Line buffering disabled, Pass on everty thing to me
23+
24+
keypad(stdscr, true); //I need that nifty F1
25+
noecho();
26+
scope(exit) endwin(); //End curses mode
27+
init_pair(1, COLOR_CYAN, COLOR_BLACK);
2228

23-
initscr(); //Start curses mode
24-
start_color(); //Start the color functionality
25-
cbreak(); //Line buffering disabled, Pass on everty thing to me
26-
27-
keypad(stdscr, true); //I need that nifty F1
28-
noecho();
29-
scope(exit) endwin(); //End curses mode
30-
init_pair(1, COLOR_CYAN, COLOR_BLACK);
3129

30+
//Initialize the window parameters
31+
init_win_params(&win);
32+
print_win_params(&win);
3233

33-
//Initialize the window parameters
34-
init_win_params(&win);
35-
print_win_params(&win);
34+
attron(COLOR_PAIR(1));
35+
printw(toStringz("Press F1 to exit"));
36+
refresh();
37+
attroff(COLOR_PAIR(1));
3638

37-
attron(COLOR_PAIR(1));
38-
printw(toStringz("Press F1 to exit"));
39-
refresh();
40-
attroff(COLOR_PAIR(1));
41-
42-
create_box(&win, true);
43-
while((ch = getch()) != KEY_F(1))
44-
{
45-
switch(ch)
46-
{
47-
case KEY_LEFT:
48-
create_box(&win, false);
49-
--win.startx;
50-
create_box(&win, true);
51-
break;
52-
case KEY_RIGHT:
53-
create_box(&win, false);
54-
++win.startx;
55-
create_box(&win, true);
56-
break;
57-
case KEY_UP:
58-
create_box(&win, false);
59-
--win.starty;
60-
create_box(&win, true);
61-
break;
62-
case KEY_DOWN:
63-
create_box(&win, false);
64-
++win.starty;
65-
create_box(&win, true);
66-
break;
67-
default:
68-
break;
69-
}//switch-case()
70-
}//while()
39+
create_box(&win, true);
40+
while((ch = getch()) != KEY_F(1))
41+
{
42+
switch(ch)
43+
{
44+
case KEY_LEFT:
45+
create_box(&win, false);
46+
--win.startx;
47+
create_box(&win, true);
48+
break;
49+
case KEY_RIGHT:
50+
create_box(&win, false);
51+
++win.startx;
52+
create_box(&win, true);
53+
break;
54+
case KEY_UP:
55+
create_box(&win, false);
56+
--win.starty;
57+
create_box(&win, true);
58+
break;
59+
case KEY_DOWN:
60+
create_box(&win, false);
61+
++win.starty;
62+
create_box(&win, true);
63+
break;
64+
default:
65+
break;
66+
}//switch-case()
67+
}//while()
7168
}//main()
7269

7370
void init_win_params(WIN *p_win)
7471
{
75-
p_win.height = 3;
76-
p_win.width = 10;
77-
p_win.starty = (LINES - p_win.height)/2;
78-
p_win.startx = (COLS - p_win.width)/2;
72+
p_win.height = 3;
73+
p_win.width = 10;
74+
p_win.starty = (LINES - p_win.height)/2;
75+
p_win.startx = (COLS - p_win.width)/2;
7976

80-
p_win.border.ls = '|';
81-
p_win.border.rs = '|';
82-
p_win.border.ts = '-';
83-
p_win.border.bs = '-';
84-
p_win.border.tl = '+';
85-
p_win.border.tr = '+';
86-
p_win.border.bl = '+';
87-
p_win.border.br = '+';
77+
p_win.border.ls = '|';
78+
p_win.border.rs = '|';
79+
p_win.border.ts = '-';
80+
p_win.border.bs = '-';
81+
p_win.border.tl = '+';
82+
p_win.border.tr = '+';
83+
p_win.border.bl = '+';
84+
p_win.border.br = '+';
8885
}//void init_win_params()
8986

9087
void print_win_params(WIN *p_win)
9188
{
92-
debug
93-
{
94-
mvprintw(25, 0, toStringz("%d %d %d %d"), p_win.startx, p_win.starty,
95-
p_win.width, p_win.height);
96-
refresh();
97-
}
89+
debug
90+
{
91+
mvprintw(25, 0, toStringz("%d %d %d %d"), p_win.startx, p_win.starty,
92+
p_win.width, p_win.height);
93+
refresh();
94+
}
9895
}//void print_win_params
9996

10097
void create_box(WIN *p_win, bool flag)
10198
{
102-
int i, j;
103-
int x = p_win.startx;
104-
int y = p_win.starty;
105-
int w = p_win.width;
106-
int h = p_win.height;
107-
108-
if(flag == true)
109-
{
110-
mvaddch(y, x, p_win.border.tl);
111-
mvaddch(y, x + w, p_win.border.tr);
112-
mvaddch(y + h, x, p_win.border.bl);
113-
mvaddch(y + h, x + w, p_win.border.br);
114-
mvhline(y, x + 1, p_win.border.ts, w - 1);
115-
mvhline(y + h, x + 1, p_win.border.bs, w - 1);
116-
mvvline(y + 1, x, p_win.border.ls, h - 1);
117-
mvvline(y + 1, x + w, p_win.border.rs, h - 1);
118-
}//if
119-
else
120-
for(j = y; j <= y + h; ++j)
121-
for(i = x; i <= x + w; ++i)
122-
mvaddch(j, i, ' ');
123-
124-
refresh();
99+
int i, j;
100+
int x = p_win.startx;
101+
int y = p_win.starty;
102+
int w = p_win.width;
103+
int h = p_win.height;
104+
105+
if(flag == true)
106+
{
107+
mvaddch(y, x, p_win.border.tl);
108+
mvaddch(y, x + w, p_win.border.tr);
109+
mvaddch(y + h, x, p_win.border.bl);
110+
mvaddch(y + h, x + w, p_win.border.br);
111+
mvhline(y, x + 1, p_win.border.ts, w - 1);
112+
mvhline(y + h, x + 1, p_win.border.bs, w - 1);
113+
mvvline(y + 1, x, p_win.border.ls, h - 1);
114+
mvvline(y + 1, x + w, p_win.border.rs, h - 1);
115+
}//if
116+
else
117+
for(j = y; j <= y + h; ++j)
118+
for(i = x; i <= x + w; ++i)
119+
mvaddch(j, i, ' ');
120+
121+
refresh();
125122
}//void create_box

examples/simple_color.d

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,50 +8,49 @@ import ncurses;
88

99
int main()
1010
{
11-
initscr(); //Start curses mode
12-
if(has_colors() == false)
13-
{
14-
endwin();
15-
writeln("Your terminal does not support color...");
16-
return 1; //ends the program
17-
}
18-
start_color(); // Start color
19-
init_pair(1, COLOR_RED, COLOR_BLACK);
20-
21-
attron(COLOR_PAIR(1));
22-
print_in_middle(stdscr, LINES/2, 0, 0, "Voila !!! In color... =)");
23-
attroff(COLOR_PAIR(1));
11+
initscr(); //Start curses mode
12+
if(has_colors() == false)
13+
{
14+
endwin();
15+
writeln("Your terminal does not support color...");
16+
return 1; //ends the program
17+
}
18+
start_color(); // Start color
19+
init_pair(1, COLOR_RED, COLOR_BLACK);
20+
21+
attron(COLOR_PAIR(1));
22+
print_in_middle(stdscr, LINES/2, 0, 0, "Voila !!! In color... =)");
23+
attroff(COLOR_PAIR(1));
2424

2525
getch();
26-
endwin();
26+
endwin();
2727

2828
return 0;
2929
}
3030

31-
//you know what? I don't even know. I'll get back to you when I'm done
32-
//translating all of the files to D2...
31+
3332
void print_in_middle(WINDOW *win, int starty, int startx, int width, string str)
3433
{
35-
int length, x, y;
36-
float temp;
34+
int length, x, y;
35+
float temp;
3736

38-
if(win == null)
39-
win = stdscr;
37+
if(win == null)
38+
win = stdscr;
4039

41-
getyx(win, y, x);
42-
if(startx != 0)
43-
x = startx;
40+
getyx(win, y, x);
41+
if(startx != 0)
42+
x = startx;
4443

45-
if(starty != 0)
46-
y = starty;
44+
if(starty != 0)
45+
y = starty;
4746

48-
if(width == 0)
49-
width = 80;
47+
if(width == 0)
48+
width = 80;
5049

51-
//int already takes the floor, we can change temp to int.
52-
temp = (width - str.length)/ 2;
53-
x = startx + cast(int)temp;
54-
mvwprintw(win, y, x, "%s", toStringz(str));
55-
refresh();
50+
//int already takes the floor, we can change temp to int.
51+
temp = (width - str.length)/ 2;
52+
x = startx + cast(int)temp;
53+
mvwprintw(win, y, x, "%s", toStringz(str));
54+
refresh();
5655
}
5756

examples/simple_key.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ int main()
4848
choice = highlight;
4949
break;
5050
default:
51-
mvprintw(24, 0, "Charcter pressed is = %3d Hopefully it can be printed as '%c'", c, c);
51+
mvprintw(24, 0, "Character pressed is = %3d Hopefully it can be printed as '%c'", c, c);
5252
refresh();
5353
break;
5454
}

0 commit comments

Comments
 (0)