Skip to content

Commit 2cb8f2a

Browse files
committed
finished adding/removing examples. all should compile.
1 parent c8c0b0b commit 2cb8f2a

File tree

8 files changed

+51
-23
lines changed

8 files changed

+51
-23
lines changed

examples/Makefile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
DC=rdmd -g -w --build-only -ofbin/$@ -I../ -L-lncursesw $^
22

3-
all: init helloUnicode helloWorld simpleColor simpleKey simpleSpectrum keyCode chgat acsVars printw simplePanel winBorder.d
4-
3+
all: init helloUnicode helloWorld simpleColor simpleKey simpleSpectrum keyCode chgat acsVars printw simplePanel winBorder.d simpleMenu.d otherBorder mouseMenu scrollMenu attribMenu printBold
54

65
init:
76
@echo "building all examples..."
@@ -25,6 +24,9 @@ simpleKey: simpleKey.d
2524
simpleSpectrum: simpleSpectrum.d
2625
$(DC)
2726

27+
simpleMenu: simpleMenu.d
28+
$(DC)
29+
2830
acsVars: acsVars.d
2931
$(DC)
3032

@@ -40,8 +42,24 @@ tempLeave: tempLeave.d
4042
printw: printw.d
4143
$(DC)
4244

45+
printBold: printBold.d
46+
$(DC)
47+
4348
winBorder: winBorder.d
4449
$(DC)
50+
51+
otherBorder: otherBorder.d
52+
$(DC)
53+
54+
mouseMenu: mouseMenu.d
55+
$(DC)
56+
57+
scrollMenu: scrollMenu.d
58+
$(DC)
59+
60+
attribMenu: attribMenu.d
61+
$(DC)
62+
4563
clean:
4664
@rm bin/*
4765
@echo "done."

examples/menu_attrib.d renamed to examples/attribMenu.d

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
#!/usr/bin/rdmd -L-lmenu
12
import deimos.ncurses.menu;
2-
3+
import std.conv: to;
4+
pragma(lib, "menu");
35
const int CTRLD = 4;
46

57
immutable char[][] choices = [ "Choice 1",
@@ -30,7 +32,7 @@ int main()
3032
init_pair(3, COLOR_MAGENTA, COLOR_BLACK);
3133

3234
/* Initialize items */
33-
n_choices = choices.length;
35+
n_choices = choices.length.to!int;
3436
my_items.length = n_choices + 1;
3537
for(i = 0; i < n_choices; ++i)
3638
my_items[i] = new_item((choices[i]~'\0').ptr, (choices[i]~'\0').ptr);

examples/form_attrib.d

100644100755
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
#!/usr/bin/rdmd
12
import deimos.ncurses.form;
23
import std.string;
3-
4+
//TODO fix
5+
pragma(lib, "ncursesw");
6+
pragma(lib, "form");
47

58
void main()
69
{

examples/mouse_menu.d renamed to examples/mouseMenu.d

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import std.string: toStringz;
1+
#!/usr/bin/rdmd -L-lncursesw
2+
import std.string: toStringz;
23
import deimos.ncurses.ncurses;
34

4-
//immutable maybe??
5-
immutable int WIDTH = 30;
6-
immutable int HEIGHT = 10;
5+
enum WIDTH = 30;
6+
enum HEIGHT = 10;
77

88
int startx = 0;
99
int starty = 0;
@@ -17,6 +17,7 @@ void main()
1717
MEVENT event;
1818

1919
initscr(); //hopefully you've seen all of this before.
20+
scope(exit) endwin();
2021
nclear();
2122
noecho();
2223
cbreak();

examples/other_border.d renamed to examples/otherBorder.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/rdmd -L-lncursesw
12
import std.string: toStringz;
23
import deimos.ncurses.ncurses;
34

examples/init_func_example.d renamed to examples/printBold.d

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1+
#!/usr/bin/rdmd -L-lncursesw
12
/* This is rather interesting, it prints the bold version
23
* of whatever you type on the screen.
34
*
4-
* Today's exercise: put all of this in a while loop,
5-
* so that you can keep typing stuff in until you get bored.
6-
* Might be harder than you think. ;)
7-
* Modified by: 1100110
85
*/
96

107
import std.string: toStringz;

examples/menu_scroll.d renamed to examples/scrollMenu.d

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
#!/usr/bin/rdmd -L-lmenu
2+
import std.conv: to;
13
import deimos.ncurses.menu;
2-
4+
pragma(lib, "menu");
35
const int CTRLD = 4;
46

57
immutable char[][] choices = [ "Choice 1",
@@ -32,7 +34,7 @@ int main()
3234
init_pair(2, COLOR_CYAN, COLOR_BLACK);
3335

3436
/* Create items */
35-
n_choices = choices.length;
37+
n_choices = choices.length.to!int;
3638
my_items.length = n_choices;
3739
for(i = 0; i < n_choices; ++i)
3840
my_items[i] = new_item((choices[i]~'\0').ptr, (choices[i]~'\0').ptr);

examples/menu_simple.d renamed to examples/simpleMenu.d

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
1+
#!/usr/bin/rdmd -L-lmenu
2+
import std.conv: to;
13
import deimos.ncurses.menu;
24

3-
const int CTRLD = 4;
5+
pragma(lib, "ncurses");
6+
pragma(lib, "menu");
47

8+
enum CTRLD = 4;
59
immutable char[][] choices = [ "Choice 1",
610
"Choice 2",
711
"Choice 3",
812
"Choice 4",
913
"Exit" ];
1014

11-
int main()
12-
{ ITEM*[] my_items;
15+
void main()
16+
{
17+
ITEM*[] my_items;
1318
int c;
1419
MENU* my_menu;
15-
int n_choices, i;
20+
size_t n_choices;
1621
ITEM* cur_item;
1722

18-
1923
initscr();
24+
scope(exit) endwin();
2025
cbreak();
2126
noecho();
2227
keypad(stdscr, true);
2328

2429
n_choices = choices.length;
2530
my_items.length = n_choices + 1;
2631

27-
for(i = 0; i < n_choices; ++i)
32+
foreach(i; 0..n_choices)
2833
my_items[i] = new_item((choices[i]~'\0').ptr, (choices[i]~'\0').ptr);
34+
2935
my_items[n_choices] = null;
3036

3137
my_menu = new_menu(my_items.ptr);
@@ -49,7 +55,5 @@ int main()
4955
free_item(my_items[0]);
5056
free_item(my_items[1]);
5157
free_menu(my_menu);
52-
endwin();
53-
return 0;
5458
}
5559

0 commit comments

Comments
 (0)