![]() This works more or less the same as the codes that are used to change the color of the text only there are are range of characters that can be used to move a cursor a number of positions up down left or right there are also characters that can be used to save and restore the cursor position. In this example I am not just moving the cursor I am also saving the position of the cursor after drawing the display area so that when I am done I can then restore to that location. 2.1 - Move a cursor and also save and restore In this section I will be covering some of these escape codes that can control cursor movement when making a node cli tool. So then this can be used as a way to create a terminal based interface. The escape codes can also be used to control the movement of the cursor in the console as well. There is much more to ANSI escape codes beyond that of just setting the foreground and background colors of text. The pattern must start with an escape character followed by an open bracket and then a color number finished with the m character.ΔΆ - Cursor Movement plus save and restore Some terminals support a wide range of color options but for the most part I like to stick to the original standard that just supports eight color options for the foreground as well as background color of the text. In this section I will be writing about using these text patterns to control the color of the terminal output. This pattern is of course and ANSI escape code sequence. So I have wrote a post on using chalk to change color a long time ago, and I have notices that it works by sending a text pattern to the standard output of the console that the console uses to set the color of the terminal text. 1 - using ANSI escape codes to set color in the terminal In this post I will be covering some basic examples of the use of ANSI escape codes to control things like the color of text, as well as cursor movement and more in nodejs. ![]() in node npm packages like chalk use ANSI escape codes to control the color of text, but they can be used to do far more than just that in the terminal. The use of ANSI escape codes is what can be used to control the format and behavior of a command line interface when making some kind of node cli tool. ![]()
0 Comments
Leave a Reply. |