Skip to content

Commit e9aba1b

Browse files
committed
Merge pull request #1 from Wyatts/patch-1
Fix examples
2 parents 63aed12 + b7e81e6 commit e9aba1b

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

deimos/ncurses/ncurses.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@
3232
module deimos.ncurses.ncurses;
3333

3434
public import deimos.ncurses.curses;
35+
alias deimos.ncurses.curses.clear nclear;

examples/menu_scroll.d

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ int main()
5555
/* Print a border around the main window and print a title */
5656
box(my_menu_win, 0, 0);
5757
print_in_middle(my_menu_win, 1, 0, 40, "My Menu", COLOR_PAIR(1));
58-
mvwaddch(my_menu_win, 2, 0, acs_map[ACS.LTEE]);
59-
mvwhline(my_menu_win, 2, 1, acs_map[ACS.HLINE], 38);
60-
mvwaddch(my_menu_win, 2, 39, acs_map[ACS.RTEE]);
58+
mvwaddch(my_menu_win, 2, 0, ACS_LTEE);
59+
mvwhline(my_menu_win, 2, 1, ACS_HLINE, 38);
60+
mvwaddch(my_menu_win, 2, 39, ACS_RTEE);
6161

6262
/* Post the menu */
6363
post_menu(my_menu);
@@ -99,7 +99,7 @@ int main()
9999
}
100100

101101
void print_in_middle(WINDOW *win, int starty, int startx, int width, string strtemp, chtype color)
102-
{ int length, x, y;
102+
{ int x, y;
103103
float temp;
104104

105105
if(win == null)
@@ -112,7 +112,7 @@ void print_in_middle(WINDOW *win, int starty, int startx, int width, string strt
112112
if(width == 0)
113113
width = 80;
114114

115-
length = strtemp.length;
115+
auto length = strtemp.length;
116116
temp = (width - length)/ 2;
117117
x = startx + cast(int)temp;
118118
wattron(win, color);

examples/mouse_menu.d

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import std.string: toStringz;
32
import deimos.ncurses.ncurses;
43

@@ -18,7 +17,7 @@ void main()
1817
MEVENT event;
1918

2019
initscr(); //hopefully you've seen all of this before.
21-
clear();
20+
nclear();
2221
noecho();
2322
cbreak();
2423
keypad(stdscr, true);
@@ -83,7 +82,7 @@ void print_menu(WINDOW* menu_win, int highlight)
8382

8483
box(menu_win, 0, 0);
8584

86-
foreach(i, choice; choices)
85+
foreach(int i, choice; choices)
8786
{
8887
if(highlight == i + 1)
8988
wattron(menu_win, A_REVERSE);
@@ -100,7 +99,7 @@ int report_choice(int mouse_x, int mouse_y)
10099
int i = startx + 2;
101100
int j = starty + 3;
102101
int report = 0;
103-
foreach(choice, str; choices)
102+
foreach(int choice, str; choices)
104103
{
105104
if((mouse_y == j + choice) && (mouse_x >= i) && (mouse_x <= i+str.length))
106105
{

examples/printw_example.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//Modified by: 1100110
22

3+
import std.conv;
34
import std.string;
45
import deimos.ncurses.ncurses; /* ncurses.h includes stdio.h */
56

@@ -11,7 +12,7 @@ void main()
1112
initscr(); //start the curses mode
1213
getmaxyx(stdscr, row, col); //get the number of rows and columns
1314
//print the message at the center of the screen
14-
mvprintw(row/2, (col-(mesg.length - 1))/2, "%s", toStringz(mesg));
15+
mvprintw(row/2, to!uint((col-(mesg.length - 1))/2), "%s", toStringz(mesg));
1516
//Did you notice? there is a '%s' not toStringified.
1617
//In one of those great weird blips, D2 will pass small characters
1718
//like that, and yet will choke on larger strings.

examples/simple_key.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ int main()
1717
int c;
1818

1919
initscr();
20-
clear();
20+
nclear();
2121
noecho();
2222
cbreak(); /* Line buffering disabled. pass on everything */
2323
scope(exit) endwin();

examples/with_chgat.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ void main()
77

88
init_pair(1, COLOR_CYAN, COLOR_BLACK);
99
printw(toStringz("A Big string which i didn't care to type fully... "));
10-
mvchgat(0, 0, -1, cast(attr_t)A_BLINK, cast(short)1, null);
10+
mvchgat(0, 0, -1, cast(attr_t)A_BLINK, cast(short)1, cast(void*)null);
1111
/*
1212
* First two parameters specify the position at which to start
1313
* Third parameter number of characters to update. -1 means till

0 commit comments

Comments
 (0)