NCurses Tutorial Filiz Şenyüzlüler Güzelbey. What is nCurses? Ncurses is a library, which is...
-
Upload
corey-davis -
Category
Documents
-
view
216 -
download
0
description
Transcript of NCurses Tutorial Filiz Şenyüzlüler Güzelbey. What is nCurses? Ncurses is a library, which is...
![Page 1: NCurses Tutorial Filiz Şenyüzlüler Güzelbey. What is nCurses? Ncurses is a library, which is used for creating and using windows, screen painting and.](https://reader036.fdocuments.in/reader036/viewer/2022082600/5a4d1b447f8b9ab0599a2c31/html5/thumbnails/1.jpg)
nCurses Tutorial
Filiz Şenyüzlüler Güzelbey
![Page 2: NCurses Tutorial Filiz Şenyüzlüler Güzelbey. What is nCurses? Ncurses is a library, which is used for creating and using windows, screen painting and.](https://reader036.fdocuments.in/reader036/viewer/2022082600/5a4d1b447f8b9ab0599a2c31/html5/thumbnails/2.jpg)
What is nCurses?
• Ncurses is a library, which is used for creating and using windows, screen painting and using function keys for text-based terminals.
![Page 3: NCurses Tutorial Filiz Şenyüzlüler Güzelbey. What is nCurses? Ncurses is a library, which is used for creating and using windows, screen painting and.](https://reader036.fdocuments.in/reader036/viewer/2022082600/5a4d1b447f8b9ab0599a2c31/html5/thumbnails/3.jpg)
What is nCurses?
• What you can do with Ncurses:
– Use any part of the screen according to your request.
– Create and manage windows.– Use 8 different colors.– Use the function keys on the keyboard.
![Page 4: NCurses Tutorial Filiz Şenyüzlüler Güzelbey. What is nCurses? Ncurses is a library, which is used for creating and using windows, screen painting and.](https://reader036.fdocuments.in/reader036/viewer/2022082600/5a4d1b447f8b9ab0599a2c31/html5/thumbnails/4.jpg)
Getting Ready
• Add #include <ncurses.h>
• Open Terminal (Compile & Run from Terminal)
![Page 5: NCurses Tutorial Filiz Şenyüzlüler Güzelbey. What is nCurses? Ncurses is a library, which is used for creating and using windows, screen painting and.](https://reader036.fdocuments.in/reader036/viewer/2022082600/5a4d1b447f8b9ab0599a2c31/html5/thumbnails/5.jpg)
Basic Functions • initscr();
– initializes the terminal in curses mode.– it clears the screen and presents a blank screen.
• printw("Hello World !!!");
• refresh() checks the window and updates only the portion which has been changed.
• endwin() frees the memory taken by curses sub-system and its data structures and puts the terminal in normal mode.
![Page 6: NCurses Tutorial Filiz Şenyüzlüler Güzelbey. What is nCurses? Ncurses is a library, which is used for creating and using windows, screen painting and.](https://reader036.fdocuments.in/reader036/viewer/2022082600/5a4d1b447f8b9ab0599a2c31/html5/thumbnails/6.jpg)
Hello World !!
![Page 7: NCurses Tutorial Filiz Şenyüzlüler Güzelbey. What is nCurses? Ncurses is a library, which is used for creating and using windows, screen painting and.](https://reader036.fdocuments.in/reader036/viewer/2022082600/5a4d1b447f8b9ab0599a2c31/html5/thumbnails/7.jpg)
Hello World !! (2)
![Page 8: NCurses Tutorial Filiz Şenyüzlüler Güzelbey. What is nCurses? Ncurses is a library, which is used for creating and using windows, screen painting and.](https://reader036.fdocuments.in/reader036/viewer/2022082600/5a4d1b447f8b9ab0599a2c31/html5/thumbnails/8.jpg)
Using Terminal
• cd Desktop (to reach the file-path)
• cd foldername
• g++ filename.cpp –lncurses (to compile)
• ./a.out (to run)
![Page 9: NCurses Tutorial Filiz Şenyüzlüler Güzelbey. What is nCurses? Ncurses is a library, which is used for creating and using windows, screen painting and.](https://reader036.fdocuments.in/reader036/viewer/2022082600/5a4d1b447f8b9ab0599a2c31/html5/thumbnails/9.jpg)
Basic Functions
• getch() – Waits for user input
• clear()– Clears the screen
![Page 10: NCurses Tutorial Filiz Şenyüzlüler Güzelbey. What is nCurses? Ncurses is a library, which is used for creating and using windows, screen painting and.](https://reader036.fdocuments.in/reader036/viewer/2022082600/5a4d1b447f8b9ab0599a2c31/html5/thumbnails/10.jpg)
clearing the screen
![Page 11: NCurses Tutorial Filiz Şenyüzlüler Güzelbey. What is nCurses? Ncurses is a library, which is used for creating and using windows, screen painting and.](https://reader036.fdocuments.in/reader036/viewer/2022082600/5a4d1b447f8b9ab0599a2c31/html5/thumbnails/11.jpg)
attributes
• attributes are used to print characters with some special effects.
• attron(), attroff() can be used to switch attributes on/off
![Page 12: NCurses Tutorial Filiz Şenyüzlüler Güzelbey. What is nCurses? Ncurses is a library, which is used for creating and using windows, screen painting and.](https://reader036.fdocuments.in/reader036/viewer/2022082600/5a4d1b447f8b9ab0599a2c31/html5/thumbnails/12.jpg)
A_BOLD attron(A_BOLD);
printw("%c", ch);attroff(A_BOLD);
![Page 13: NCurses Tutorial Filiz Şenyüzlüler Güzelbey. What is nCurses? Ncurses is a library, which is used for creating and using windows, screen painting and.](https://reader036.fdocuments.in/reader036/viewer/2022082600/5a4d1b447f8b9ab0599a2c31/html5/thumbnails/13.jpg)
COLOR_PAIR(n) start_color(); /* Start color*/init_pair(1, COLOR_RED, COLOR_GREEN); attron(COLOR_PAIR(1));printw("%c", ch);attroff(COLOR_PAIR(1));