File tree Expand file tree Collapse file tree 8 files changed +51
-23
lines changed Expand file tree Collapse file tree 8 files changed +51
-23
lines changed Original file line number Diff line number Diff line change 1
1
DC =rdmd -g -w --build-only -ofbin/$@ -I../ -L-lncursesw $^
2
2
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
5
4
6
5
init :
7
6
@echo " building all examples..."
@@ -25,6 +24,9 @@ simpleKey: simpleKey.d
25
24
simpleSpectrum : simpleSpectrum.d
26
25
$(DC )
27
26
27
+ simpleMenu : simpleMenu.d
28
+ $(DC )
29
+
28
30
acsVars : acsVars.d
29
31
$(DC )
30
32
@@ -40,8 +42,24 @@ tempLeave: tempLeave.d
40
42
printw : printw.d
41
43
$(DC )
42
44
45
+ printBold : printBold.d
46
+ $(DC )
47
+
43
48
winBorder : winBorder.d
44
49
$(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
+
45
63
clean :
46
64
@rm bin/*
47
65
@echo " done."
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/rdmd -L-lmenu
1
2
import deimos.ncurses.menu;
2
-
3
+ import std.conv : to;
4
+ pragma (lib, " menu" );
3
5
const int CTRLD = 4 ;
4
6
5
7
immutable char [][] choices = [ " Choice 1" ,
@@ -30,7 +32,7 @@ int main()
30
32
init_pair(3 , COLOR_MAGENTA , COLOR_BLACK );
31
33
32
34
/* Initialize items */
33
- n_choices = choices.length;
35
+ n_choices = choices.length.to ! int ;
34
36
my_items.length = n_choices + 1 ;
35
37
for (i = 0 ; i < n_choices; ++ i)
36
38
my_items[i] = new_item((choices[i]~ ' \0 ' ).ptr, (choices[i]~ ' \0 ' ).ptr);
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/rdmd
1
2
import deimos.ncurses.form;
2
3
import std.string ;
3
-
4
+ // TODO fix
5
+ pragma (lib, " ncursesw" );
6
+ pragma (lib, " form" );
4
7
5
8
void main ()
6
9
{
Original file line number Diff line number Diff line change 1
- import std.string : toStringz;
1
+ #!/usr/bin/rdmd -L-lncursesw
2
+ import std.string : toStringz;
2
3
import deimos.ncurses.ncurses;
3
4
4
- // immutable maybe??
5
- immutable int WIDTH = 30 ;
6
- immutable int HEIGHT = 10 ;
5
+ enum WIDTH = 30 ;
6
+ enum HEIGHT = 10 ;
7
7
8
8
int startx = 0 ;
9
9
int starty = 0 ;
@@ -17,6 +17,7 @@ void main()
17
17
MEVENT event;
18
18
19
19
initscr(); // hopefully you've seen all of this before.
20
+ scope (exit) endwin ();
20
21
nclear();
21
22
noecho();
22
23
cbreak();
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/rdmd -L-lncursesw
1
2
import std.string : toStringz;
2
3
import deimos.ncurses.ncurses;
3
4
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/rdmd -L-lncursesw
1
2
/* This is rather interesting, it prints the bold version
2
3
* of whatever you type on the screen.
3
4
*
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
8
5
*/
9
6
10
7
import std.string : toStringz;
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/rdmd -L-lmenu
2
+ import std.conv : to;
1
3
import deimos.ncurses.menu;
2
-
4
+ pragma (lib, " menu " );
3
5
const int CTRLD = 4 ;
4
6
5
7
immutable char [][] choices = [ " Choice 1" ,
@@ -32,7 +34,7 @@ int main()
32
34
init_pair(2 , COLOR_CYAN , COLOR_BLACK );
33
35
34
36
/* Create items */
35
- n_choices = choices.length;
37
+ n_choices = choices.length.to ! int ;
36
38
my_items.length = n_choices;
37
39
for (i = 0 ; i < n_choices; ++ i)
38
40
my_items[i] = new_item((choices[i]~ ' \0 ' ).ptr, (choices[i]~ ' \0 ' ).ptr);
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/rdmd -L-lmenu
2
+ import std.conv : to;
1
3
import deimos.ncurses.menu;
2
4
3
- const int CTRLD = 4 ;
5
+ pragma (lib, " ncurses" );
6
+ pragma (lib, " menu" );
4
7
8
+ enum CTRLD = 4 ;
5
9
immutable char [][] choices = [ " Choice 1" ,
6
10
" Choice 2" ,
7
11
" Choice 3" ,
8
12
" Choice 4" ,
9
13
" Exit" ];
10
14
11
- int main ()
12
- { ITEM * [] my_items;
15
+ void main ()
16
+ {
17
+ ITEM * [] my_items;
13
18
int c;
14
19
MENU * my_menu;
15
- int n_choices, i ;
20
+ size_t n_choices;
16
21
ITEM * cur_item;
17
22
18
-
19
23
initscr();
24
+ scope (exit) endwin ();
20
25
cbreak();
21
26
noecho();
22
27
keypad(stdscr, true );
23
28
24
29
n_choices = choices.length;
25
30
my_items.length = n_choices + 1 ;
26
31
27
- for (i = 0 ; i < n_choices; ++ i )
32
+ foreach (i; 0 .. n_choices)
28
33
my_items[i] = new_item((choices[i]~ ' \0 ' ).ptr, (choices[i]~ ' \0 ' ).ptr);
34
+
29
35
my_items[n_choices] = null ;
30
36
31
37
my_menu = new_menu(my_items.ptr);
@@ -49,7 +55,5 @@ int main()
49
55
free_item(my_items[0 ]);
50
56
free_item(my_items[1 ]);
51
57
free_menu(my_menu);
52
- endwin();
53
- return 0 ;
54
58
}
55
59
You can’t perform that action at this time.
0 commit comments