Introduction to Linux terminal graphics library curses and instance analysis

Source: Internet
Author: User
Linux terminal graphics library curses introduction and instance analysis-Linux general technology-Linux programming and kernel information, the following is a detailed description. With the popularization of computer knowledge, more and more computer enthusiasts begin to understand and use Linux .. The ease and freedom of Linux gives us different feelings. However, we are not satisfied with basic commands and operations on user interfaces such as KDE and Gnome. What should we do? Programming, right, programming! For programmers, Linux has a good programming environment: gcc (GNU Compiler Collection) can compile C, C ++, Java and many other languages, and many function libraries can be called in Linux. knowing how to use these function libraries will add many useful tools to your programming toolbox. today, let's take a look at curses, a graphic function library that is widely used in Linux/Unix, instead of a medieval witch.

If you have learned TC2.0 before, remember that there is a graphic library BGI (Borland Graphics Interface) in TC. Header file :). we can use it to draw user interfaces and beautiful images under DOS. linux/Unix programming gives people the feeling of being cool. It seems that Linux programming is carried out on black and black terminals. indeed, many Linux experts like to work in the terminal mode. After being familiar with some commands, this mode of work is still very efficient. but it's annoying to watch black and black screens for a long time, especially for cainiao who are new to Linux like me :) is there a tool that allows us to compile good-looking images in Linux? The answer is yes. It is curses!

The name of curses originates from "cursor optimization", that is, cursor optimization. it was first written by Bill Joy and Ken Arnold of the University of Berkeley to process the screen display of a game rogue. later, Mark Horton of Bell's lab re-compiled curses in System III Unix. currently, almost all Unix and Linux operating systems have the curses function library. curses also supports mouse and some menu and panel processing. it can be said that curses is the best choice for Linux terminal graphics programming (for example, the famous text editor vi is based on curses)

OK. Let's talk about it in a few minutes. Now let's get started:

First, we should understand that the screen mode used on the terminal is text-based. before using curses, use the initscr () function to initialize the screen. correspondingly, the endwin () function must be called to close the curses state when the program ends.

With this concept, we can write the famous "Hello, world! "Curses version:
QUOTE:
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.