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.

MENU *my_menu;<br />

WINDOW *my_menu_win;<br />

int n_choices, i;<br />

/* Curses kipini ilklendir */<br />

initscr();<br />

start_color();<br />

cbreak();<br />

noecho();<br />

keypad(stdscr, TRUE);<br />

init_pair(1, COLOR_RED, COLOR_BLACK);<br />

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

/* Ö˘geleri olu¸stur */<br />

n_choices = ARRAY_SIZE(choices);<br />

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

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

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

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

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

/* Menü <strong>ile</strong> ili¸siklendir<strong>ile</strong>cek pencereyi olu¸stur */<br />

my_menu_win = newwin(10, 40, 4, 4);<br />

keypad(my_menu_win, TRUE);<br />

/* Ana pencereyi ve alt pencereleri ayarla */<br />

set_menu_win(my_menu, my_menu_win);<br />

set_menu_sub(my_menu, derwin(my_menu_win, 6, 38, 3, 1));<br />

/* Menü göstericisini " * " olarak ayarla*/<br />

set_menu_mark(my_menu, " * ");<br />

/* Ana pencere etrafında bir çerçeve çiz ve bir ba¸slık yaz */<br />

box(my_menu_win, 0, 0);<br />

print_in_middle(my_menu_win, 1, 0, 40, "My Menu", COLOR_PAIR(1));<br />

mvwaddch(my_menu_win, 2, 0, ACS_LTEE);<br />

mvwhline(my_menu_win, 2, 1, ACS_HLINE, 38);<br />

mvwaddch(my_menu_win, 2, 39, ACS_RTEE);<br />

mvprintw(LINES – 2, 0, "F1 to exit");<br />

refresh();<br />

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

post_menu(my_menu);<br />

wrefresh(my_menu_win);<br />

wh<strong>ile</strong>((c = wgetch(my_menu_win)) != 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 />

}<br />

wrefresh(my_menu_win);<br />

}<br />

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

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

Saved successfully!

Ooh no, something went wrong!