Skip to content

Commit ab32cee

Browse files
committed
changed names to D standard and added a Makefile
1 parent 1724677 commit ab32cee

File tree

5 files changed

+50
-14
lines changed

5 files changed

+50
-14
lines changed

examples/Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
DMD=rdmd -g -w --build-only -ofbin/$@ -L-lncursesw $^
2+
3+
all: helloUnicode helloWorld
4+
5+
helloWorld: helloWorld.d
6+
$(DMD)
7+
8+
helloUnicode: helloUnicode.d
9+
$(DMD)
10+
11+
simpleColor: simpleColor.d
12+
$(DMD)
13+
14+
15+
clean:
16+
@rm bin/*

examples/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# D Ncurses Examples
2+
3+
Here are a few examples to get you started.
4+
5+
The main site where these examples were originally found is here [tldp.org](http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/)
6+
These examples need some work, but they should demonstrate that most everything is in working order.
7+
8+
### Requirements:
9+
- [rdmd](http://github.com/D-Programming-Language/tools)
10+
- ncursesw
11+
12+
### Files
13+
14+
15+
16+
Again, please file any bugs that you come across.
17+
Even if you don't know if it is actually a bug, we appreciate the time.
18+
We understand that sometimes it is hard to figure out.

examples/hello_unicode.d renamed to examples/helloUnicode.d

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
#!/usr/bin/rdmd -L-lncursesw
12
/** hello_unicode.d
23
*
34
* This is a demonstration of Unicode output with ncurses in D.
4-
*
55
* The functionality of this code is otherwise identical to hello_world.d
66
*
77
* Requirements for Unicode in ncurses:
@@ -13,8 +13,8 @@
1313
*
1414
* Modified by: Wyatt
1515
*/
16-
import std.string: toStringz;
17-
import std.c.locale; // Need setlocale()
16+
import std.string: toStringz;
17+
import std.c.locale; // Need setlocale()
1818
import deimos.ncurses.ncurses;
1919

2020
void main()

examples/hello_world.d renamed to examples/helloWorld.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
/** hello_world.d
23
*
34
* I'm assuming that you are starting here, so I've included

examples/simple_color.d renamed to examples/simpleColor.d

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1+
#!/usr/bin/rdmd -L-lncursesw
12
//Modified by: 1100110
2-
3-
import std.stdio: writeln;
4-
import std.string: toStringz;
3+
import std.stdio: writeln;
4+
import std.string: toStringz;
55
import deimos.ncurses.ncurses;
66

77

8-
9-
int main()
10-
{
8+
int main() {
119
initscr(); //Start curses mode
10+
1211
if(has_colors() == false)
1312
{
1413
endwin();
15-
writeln("Your terminal does not support color...");
16-
return 1; //ends the program
14+
writeln("Your terminal does not support color... Goodbye");
15+
return 1;
1716
}
18-
start_color(); // Start color
17+
start_color();
18+
1919
init_pair(1, COLOR_RED, COLOR_BLACK);
2020

2121
attron(COLOR_PAIR(1));
@@ -32,7 +32,6 @@ int main()
3232
void print_in_middle(WINDOW *win, int starty, int startx, int width, string str)
3333
{
3434
int length, x, y;
35-
float temp;
3635

3736
if(win == null)
3837
win = stdscr;
@@ -48,9 +47,11 @@ void print_in_middle(WINDOW *win, int starty, int startx, int width, string str)
4847
width = 80;
4948

5049
//int already takes the floor, we can change temp to int.
51-
temp = (width - str.length)/ 2;
50+
float temp = (width - str.length)/ 2;
5251
x = startx + cast(int)temp;
52+
5353
mvwprintw(win, y, x, "%s", toStringz(str));
54+
5455
refresh();
5556
}
5657

0 commit comments

Comments
 (0)