more functions and documentation

This commit is contained in:
2021-03-12 22:33:18 +01:00
parent 8ddd20203d
commit 6f2547eb1f
21 changed files with 582 additions and 117 deletions

49
doc/color.md Normal file
View File

@@ -0,0 +1,49 @@
Color
=====
256 8-bit colors
----------------
```python
print(ansi_escape.color("fg", "red") + "red text")
```
Makes the color of the text itself (aka the foreground color) red.
```python
print(ansi_escape.color("bg", "bright-cyan") + "bright cyan text background")
```
This will make the background color bright cyan.
ansi_escape.color() also supports the numbers 0-255 [here is a list explaining each number.](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit)
```python
print(ansi_escape.color("bg", 33) + "text")
```
You can also use the following human readable names insteead of 0-16:
| Instead of | Use |
| ---------: | :------------- |
| 0|"black" |
| 1|"red" |
| 2|"green" |
| 3|"yellow" |
| 4|"blue" |
| 5|"magenta" |
| 6|"cyan" |
| 7|"white" |
| 8|"bright-black" |
| 9|"bright-red" |
| 10|"bright-green" |
| 11|"bright-yellow" |
| 12|"bright-blue" |
| 13|"bright-magenta"|
| 14|"bright-cyan" |
| 15|"bright-white" |
24-bit True Color
-----------------
To do this provide ansi_escape.color() with "fg" or "bg" + 3 comma reperated values for r, g, and b respectivley, each rgb value can be a number between 0-255.
```python
print(ansi_escape.color("bg", 128, 0, 255) + "bg for background color")
print(ansi_escape.color("fg", 255, 69, 128) + "fg for foreground color")
```

49
doc/cursor.md Normal file
View File

@@ -0,0 +1,49 @@
Cursor control
==============
Move to spesific coordinates
----------------------------
To move the terminal cursor using positional coordinates use the following function:
```python
ansi_escape.cursor_position()
```
If the function name is to long you can use:
```python
ansi_escape.cup()
```
instead.
```python
ansi_escape.cup() #sets position to 1,1
ansi_escape.cursor_position(row=5) #sets cursor position to row 5 and column 1
ansi_escape.cup(column=16) #sets cursor position to column 16 and row 1
ansi_escape.cursor_position(row=30, column=3) #sets cursor position to row 30 and column 3
```
Move cursor from current position
---------------------------------
For relative movements use:
```python
ansi_escape(direction, cells)
```
direction can be:
- "up"
- "down"
- "forward"
- "backward"
It is the direction the cursor moves towards.
cells is an optional argumant which specifies how many character cells you want to move the cursor.
Move cursor to spesific horisontal position
-------------------------------------------
Use:
```python
ansi_escape.cursor_horisontal_absolute(column)
#or
ansi_escape.cha(column)
```
column can be omitted and will then default to 1.
This will not affect the vertical coordinates of the cursor.

38
doc/delete.md Normal file
View File

@@ -0,0 +1,38 @@
Character deletion
==================
Erase character
---------------
```python
ansi_escape.erase_character(n)
```
Will erase n amount of characters from the cursor to the right of the cursor.
amount defaults to 1.
<!---Example:
0|1|2|3|4|5|6|7|8|9|10
:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:--
h|e|l|l|o|{cursor}|w|o|r|l|d
Here the cursor is on cell 5, if you where to run--->
Delete character
----------------
```python
ansi_escape.delete_character(n)
```
Works just like erase_character(), but after deleting the characters it wil shift any remaining characters to the left of the cursor by n amount.
If n is omitted it defaults to 1.
Erase in display
----------------
```python
ansi_escape.erase_in_display(n)
#or
ansi_escape.ed(n)
```
Will erase in the display from the cursor.
n is the direction from the cursor to erase in and can be : forward, backward, or both. n can also be "history" which works like "both", but will also include the buffered history of the terminal. I do not reccomend using history since it is not widley supported.
Erase in line
-------------
```python
ansi_escape.erase_in_line(n)
#or
ansi_escape.el(n)
```
Like erase in display, but limited to one line. The n variable works the same way, minus the history option.