18.02.2013 Views

NCURSES ile Yazılım Geli¸stirme NASIL

NCURSES ile Yazılım Geli¸stirme NASIL

NCURSES ile Yazılım Geli¸stirme NASIL

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

<strong>NCURSES</strong> <strong>ile</strong> Yazılım Geli¸stirme <strong>NASIL</strong><br />

init_pair(2, COLOR_GREEN, COLOR_BLACK);<br />

init_pair(3, COLOR_MAGENTA, COLOR_BLACK);<br />

/* Ö˘geleri ˙Ilklendir */<br />

n_choices = ARRAY_SIZE(choices);<br />

my_items = (ITEM **)calloc(n_choices + 1, sizeof(ITEM *));<br />

for(i = 0; i < n_choices; ++i)<br />

{ my_items[i] = new_item(choices[i], choices[i]);<br />

/* Set the user pointer */<br />

set_item_userptr(my_items[i], func);<br />

}<br />

my_items[n_choices] = (ITEM *)NULL;<br />

/* Menüyü olu¸stur */<br />

my_menu = new_menu((ITEM **)my_items);<br />

/* Menüyü ekrana yaz */<br />

mvprintw(LINES – 3, 0,<br />

"Seçili ö˘geyi görmek için ’a basın");<br />

mvprintw(LINES – 2, 0,<br />

"Hareket etmek için Yukarı ve A¸sa˘gı ok tu¸slarını kullanın "<br />

"(Çıkmak için F1)");<br />

post_menu(my_menu);<br />

refresh();<br />

wh<strong>ile</strong>((c = getch()) != KEY_F(1))<br />

{ switch(c)<br />

{ case KEY_DOWN:<br />

menu_driver(my_menu, REQ_DOWN_ITEM);<br />

break;<br />

case KEY_UP:<br />

menu_driver(my_menu, REQ_UP_ITEM);<br />

break;<br />

case 10: /* Enter */<br />

{ ITEM *cur;<br />

void (*p)(char *);<br />

}<br />

cur = current_item(my_menu);<br />

p = item_userptr(cur);<br />

p((char *)item_name(cur));<br />

pos_menu_cursor(my_menu);<br />

break;<br />

}<br />

break;<br />

}<br />

unpost_menu(my_menu);<br />

for(i = 0; i < n_choices; ++i)<br />

free_item(my_items[i]);<br />

free_menu(my_menu);<br />

endwin();<br />

void func(char *name)<br />

{ move(20, 0);<br />

clrtoeol();<br />

mvprintw(20, 0, "Seçili öge: %s", name);<br />

http://belgeler.org Linux Kitaplı˘gı 66 / 90

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!