Linux Hidden display terminal cursor

Source: Internet
Author: User
Tags clear screen echo command set background

Reprint: http://blog.chinaunix.net/uid-20682890-id-3180911.html

First, use the Shell's echo command to implement.

Echo-ne <ctrl+v><ESC>[?25l&<60;&<60;&<60; Hide Cursor

Echo-ne <ctrl+v><ESC>[?25h&<60; Display cursor

L,h is the letter, <ctrl+v> the CTRL key is pressed, then V is pressed, <ESC> is the ESC key on the keyboard

In the terminal echo scenario is as follows:

echo-ne&<60; ^[[?25l

echo-ne&<60; ^[[?25h

Where ^[is obtained with <ctrl+v><ESC>, the direct input ^[is invalid

The cursor in HyperTerminal often disappears unexpectedly, which is a good way to get it back.

A simpler approach

Echo-e "\033[?25l" Hide cursor

Echo-e "\033[?25h" Display cursor

In fact \033 (octal, equivalent to 10 binary 27) is the value of the character entered by <ctrl+v><ESC>.

Echo-ne "\33[32m" To change the display color of a character to green

Echo-ne "\33[3;1h" to move the cursor to the 1th column of line 3rd

Some of the specific excerpts are as follows:

\33[0m Close All Properties

\33[1m Setting High brightness

\33[4m Underline

\33[5m Flashing

\33[7M Reverse Display

\33[8m blanking

\33[30m--\33[37m setting foreground color

\33[40m--\33[47m Set background color

\33[na the cursor to move n rows

\33[NB cursor down n rows

\33[NC cursor right shifts n rows

\33[nd cursor left n rows

\33[Y;XH Setting the cursor position

\33[2J Clear Screen

\33[k clears the contents from the cursor to the end of the line

\33[s Save Cursor position

\33[u Restore cursor Position

\33[?25l Hide Cursor

\33[?25h Display cursor

Word background color range: 49----

40: Black

41: Crimson

42: Green

43: Yellow

44: Blue

45: Purple

46: Dark Green

47: White

Word color: 39-----------

30: Black

31: Red

32: Green

33: Yellow

34: Blue

35: Purple

36: Dark Green

37: White

Don't forget the-E and "", otherwise it won't work.

Second, using the printf function of Linux C to implement

printf ("\033[?25h");//Display cursor

printf ("\033[?25l");//Hide cursor

Linux Hidden display terminal cursor

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.