Name | flyconsole JSON |
Version |
1.2
JSON |
| download |
home_page | |
Summary | Modify the Terminal |
upload_time | 2023-12-07 15:34:14 |
maintainer | |
docs_url | None |
author | fluffy |
requires_python | >=3.8 |
license | |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Fly Console
Fly Console is build to easy manipulate the terminal xonsole in multiple aspects It is possible to change the color, clear the terminal or manipulate the position, visibility of the cursor and use custom input methods.
You can install it for python via pip [here](https://pypi.org/project/flyconsole/) and you can view the source code on github [here](https://github.com/fluffeliger/fly-console).
## Documenation
Welcome to the documentation about the fly console package c:
The Documentation is based on the newest Version.
With this package it is possible to change the foreground and background color of the text in the terminal, write with or without line breaks, set the cursor position with different modes, show and hide the cursor or clear the console on specific parts.
Lets get right into it!
---
### Writing to the Terminal
The most important part is writing to the terminal. This can done in two ways. Write a line without a break or write a line with a break at the end.
We can write with a break like this
```py
from flyconsole import Console
Console.writeln('This is a test!')
Console.writeln('This is another test!')
```
The output will look like this
```
This is a test!
This is another test!
```
To write without a break we use
```py
from flyconsole import Console
Console.write('This is a test!')
Console.write('This is another test!')
```
With the following output
```
This is a test!This is another test!
```
As we can see, there is no line break betweeen
---
### Colors
First of all there are two ways to use colors It is possible to use just integers from 0 to 255. There are also predefined constants for the first 16 colors (0 - 15).
They can be imported as following
```py
from flyconsole import Color
```
Now lets make the console colorful!
To set the foreground color of the text you can just simply run
```py
from flyconsole import Console, Color
Console.set_color(Color.RED)
```
But you are not limited to the foreground color. You can also only set the background color
```py
from flyconsole import Console, Color
Console.set_color(background=Color.CYAN)
```
And as if that wasn't enough, you can combine these into one line
```py
from flyconsole import Console, Color
Console.set_color(Color.RED, Color.CYAN)
```
This line will do the same as the two lines before.
At some point you may want to remove all Color effects. For this the following code does the job
```py
from flyconsole import Console
Console.reset_color()
```
Pretty self-explanatory.
Lets hop on to the next part!
---
### Cursor Maniplation
Before we can start there is one thing to say.
The cursor module is a submodule of the console. You dont have to import it, you can just use it right away like this
```py
from flyconsole import Console
Console.Cursor # Thats the Cursor sub module
```
There a nine methods for manipulation of the cursor
The first is the simplest. To jump to a specific line and column just write the follwing
```py
from flyconsole import Console
Console.Cursor.go_to(line, column)
```
If u want to go to the cursors home instead, you can write
```py
from flyconsole import Console
Console.Cursor.go_home()
```
There are 4 methods to go relative amounts in different directions
```py
from flyconsole import Console
# The Cursor will go one line up
Console.Cursor.go_up()
# The Cursor will go n lines up
Console.Cursor.go_up(n)
# The Cursor will go one line down
Console.Cursor.go_down()
# The Cursor will go n lines down
Console.Cursor.go_down(n)
# The Cursor will go one column to the right
Console.Cursor.go_right()
# The Cursor will go n columns to the right
Console.Cursor.go_right(n)
# The Cursor will go one column to the left
Console.Cursor.go_left()
# The Cursor will go n columns to the left
Console.Cursor.go_left(n)
```
As you can see, the variable n is predefined with the value 1 so you dont have to write it again and again
You can also move the cursor down n lines and then go automatically to the beginning of that line with the following code
```py
from flyconsole import Console
# n is predifned with 1
Console.Cursor.go_down_beginning(n)
```
The same also for going up
```py
from flyconsole import Console
# n is predifned with 1
Console.Cursor.go_up_beginning(n)
```
Last but not least, you can go to a specific column via
```py
from flyconsole import Console
# n is predifned with 1
Console.Cursor.go_to_column(column)
```
This can be usefull when u go up a line and want to be on another column
##### Private Modes
Private modes are some console sequences that may not work on every Terminal. To manipulate the visibility of the cursor we need private modes.
The visibility can be modified with
```py
from flyconsole import Console
Console.Cursor.Private.hide()
Console.Cursor.Private.show()
```
Its obvious which method does what
---
### Clearing the Terminal
There are six methods to clear the terminal or specific parts of it.
The first one and the most common one is there to clear the whole terminal
```py
from flyconsole import Console
Console.Clear.clear()
```
To clear from the cursor to the end of the terminal you can use the next snippet
```py
from flyconsole import Console
Console.Clear.cursor_to_end()
```
To clear from the cursor to the beginning of the terminal you can use this
```py
from flyconsole import Console
Console.Clear.cursor_to_start()
```
You can also clear from the cursor to the end or start of the current line with
```py
from flyconsole import Console
Console.Clear.cursor_to_end_line()
Console.Clear.cursor_to_start_line()
```
And you can also clear the whole current line with the following
```py
from flyconsole import Console
Console.Clear.current_line()
```
---
### Inputs
There are also some inputs you can use. In later updates there are coming more!
#### List Menu (Since V1.2)
A List Menu uses for its fields a `Menuitem`. You can also customize the key events with a `KeyConfiguration`.
To setup a List menu you can write the following
```py
from flyconsole import ListMenu
menu = Menu(0) # 0 Defines the y coordinate of the menu
menu.add_item('Item A')
menu.add_item('Item B')
menu.add_item('Item C')
menu.enable() # Shows the menu and enables the Key Events
# After the menu is done you can get its result with
menu.result
# The result will return a MenuItem
```
When we look at the `ListMenu` init arguments
```py
ListMenu(y:int=0, can_cancel:bool=1, can_escape:bool=1, key_configuration:KeyConfiguration=KeyConfiguration())
```
we can see, we can disable the `[CTRl] + [C]` cancel and the `[ESC]` key. The cancel and escape keys can also be modified in a `KeyConfiguration`
The Keyconfiguration looks like this
```py
@dataclass
class KeyConfiguration:
up: tuple = (72, 1)
down: tuple = (80, 1)
select: tuple = (13, 0)
escape: tuple = (27, 0)
cancel: tuple = (3, 0)
```
Foreach tuple the first argument is the keycode and the second argument defines if the key means something else. For example if you press an arrow key it will return `(72, 1)` and if u press `[H]` it will return `(72, 0)`.
Raw data
{
"_id": null,
"home_page": "",
"name": "flyconsole",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "",
"author": "fluffy",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/4c/fd/b12c60b213ac6a1a852297c78506a8c027165f85d35ec7dd9bb0eb57581e/flyconsole-1.2.tar.gz",
"platform": null,
"description": "# Fly Console\r\n\r\nFly Console is build to easy manipulate the terminal xonsole in multiple aspects It is possible to change the color, clear the terminal or manipulate the position, visibility of the cursor and use custom input methods.\r\n\r\nYou can install it for python via pip [here](https://pypi.org/project/flyconsole/) and you can view the source code on github [here](https://github.com/fluffeliger/fly-console).\r\n\r\n## Documenation\r\n\r\nWelcome to the documentation about the fly console package c:\r\n\r\nThe Documentation is based on the newest Version.\r\n\r\nWith this package it is possible to change the foreground and background color of the text in the terminal, write with or without line breaks, set the cursor position with different modes, show and hide the cursor or clear the console on specific parts.\r\n\r\nLets get right into it!\r\n\r\n---\r\n\r\n### Writing to the Terminal\r\n\r\nThe most important part is writing to the terminal. This can done in two ways. Write a line without a break or write a line with a break at the end.\r\n\r\nWe can write with a break like this\r\n\r\n```py\r\nfrom flyconsole import Console\r\nConsole.writeln('This is a test!')\r\nConsole.writeln('This is another test!')\r\n```\r\n\r\nThe output will look like this\r\n\r\n```\r\nThis is a test!\r\nThis is another test!\r\n```\r\n\r\nTo write without a break we use\r\n\r\n```py\r\nfrom flyconsole import Console\r\nConsole.write('This is a test!')\r\nConsole.write('This is another test!')\r\n```\r\n\r\nWith the following output\r\n\r\n```\r\nThis is a test!This is another test!\r\n```\r\n\r\nAs we can see, there is no line break betweeen\r\n\r\n---\r\n\r\n### Colors\r\n\r\nFirst of all there are two ways to use colors It is possible to use just integers from 0 to 255. There are also predefined constants for the first 16 colors (0 - 15).\r\n\r\nThey can be imported as following\r\n\r\n```py\r\nfrom flyconsole import Color\r\n```\r\n\r\nNow lets make the console colorful!\r\nTo set the foreground color of the text you can just simply run\r\n\r\n```py\r\nfrom flyconsole import Console, Color\r\nConsole.set_color(Color.RED)\r\n```\r\n\r\nBut you are not limited to the foreground color. You can also only set the background color\r\n\r\n```py\r\nfrom flyconsole import Console, Color\r\nConsole.set_color(background=Color.CYAN)\r\n```\r\n\r\nAnd as if that wasn't enough, you can combine these into one line\r\n\r\n```py\r\nfrom flyconsole import Console, Color\r\nConsole.set_color(Color.RED, Color.CYAN)\r\n```\r\n\r\nThis line will do the same as the two lines before.\r\n\r\nAt some point you may want to remove all Color effects. For this the following code does the job\r\n\r\n```py\r\nfrom flyconsole import Console\r\nConsole.reset_color()\r\n```\r\n\r\nPretty self-explanatory.\r\n\r\nLets hop on to the next part!\r\n\r\n---\r\n\r\n### Cursor Maniplation\r\n\r\nBefore we can start there is one thing to say.\r\nThe cursor module is a submodule of the console. You dont have to import it, you can just use it right away like this\r\n\r\n```py\r\nfrom flyconsole import Console\r\nConsole.Cursor # Thats the Cursor sub module\r\n```\r\n\r\nThere a nine methods for manipulation of the cursor\r\nThe first is the simplest. To jump to a specific line and column just write the follwing\r\n\r\n```py\r\nfrom flyconsole import Console\r\nConsole.Cursor.go_to(line, column)\r\n```\r\n\r\nIf u want to go to the cursors home instead, you can write\r\n\r\n```py\r\nfrom flyconsole import Console\r\nConsole.Cursor.go_home()\r\n```\r\n\r\nThere are 4 methods to go relative amounts in different directions\r\n\r\n```py\r\nfrom flyconsole import Console\r\n\r\n# The Cursor will go one line up\r\nConsole.Cursor.go_up() \r\n# The Cursor will go n lines up\r\nConsole.Cursor.go_up(n)\r\n\r\n# The Cursor will go one line down\r\nConsole.Cursor.go_down()\r\n# The Cursor will go n lines down\r\nConsole.Cursor.go_down(n)\r\n\r\n# The Cursor will go one column to the right\r\nConsole.Cursor.go_right()\r\n# The Cursor will go n columns to the right\r\nConsole.Cursor.go_right(n)\r\n\r\n# The Cursor will go one column to the left\r\nConsole.Cursor.go_left()\r\n# The Cursor will go n columns to the left\r\nConsole.Cursor.go_left(n)\r\n```\r\n\r\nAs you can see, the variable n is predefined with the value 1 so you dont have to write it again and again\r\n\r\nYou can also move the cursor down n lines and then go automatically to the beginning of that line with the following code\r\n\r\n```py\r\nfrom flyconsole import Console\r\n\r\n# n is predifned with 1\r\nConsole.Cursor.go_down_beginning(n)\r\n```\r\n\r\nThe same also for going up\r\n\r\n```py\r\nfrom flyconsole import Console\r\n\r\n# n is predifned with 1\r\nConsole.Cursor.go_up_beginning(n)\r\n```\r\n\r\nLast but not least, you can go to a specific column via\r\n\r\n```py\r\nfrom flyconsole import Console\r\n\r\n# n is predifned with 1\r\nConsole.Cursor.go_to_column(column)\r\n```\r\n\r\nThis can be usefull when u go up a line and want to be on another column\r\n\r\n##### Private Modes\r\n\r\nPrivate modes are some console sequences that may not work on every Terminal. To manipulate the visibility of the cursor we need private modes.\r\n\r\nThe visibility can be modified with\r\n\r\n```py\r\nfrom flyconsole import Console\r\n\r\nConsole.Cursor.Private.hide()\r\nConsole.Cursor.Private.show()\r\n```\r\n\r\nIts obvious which method does what\r\n\r\n---\r\n\r\n### Clearing the Terminal\r\n\r\nThere are six methods to clear the terminal or specific parts of it.\r\n\r\nThe first one and the most common one is there to clear the whole terminal\r\n\r\n```py\r\nfrom flyconsole import Console\r\nConsole.Clear.clear()\r\n```\r\n\r\nTo clear from the cursor to the end of the terminal you can use the next snippet\r\n\r\n```py\r\nfrom flyconsole import Console\r\nConsole.Clear.cursor_to_end()\r\n```\r\n\r\nTo clear from the cursor to the beginning of the terminal you can use this\r\n\r\n```py\r\nfrom flyconsole import Console\r\nConsole.Clear.cursor_to_start()\r\n```\r\n\r\nYou can also clear from the cursor to the end or start of the current line with\r\n\r\n```py\r\nfrom flyconsole import Console\r\nConsole.Clear.cursor_to_end_line()\r\nConsole.Clear.cursor_to_start_line()\r\n```\r\n\r\nAnd you can also clear the whole current line with the following\r\n\r\n```py\r\nfrom flyconsole import Console\r\nConsole.Clear.current_line()\r\n```\r\n\r\n---\r\n\r\n### Inputs\r\n\r\nThere are also some inputs you can use. In later updates there are coming more!\r\n\r\n#### List Menu (Since V1.2)\r\n\r\nA List Menu uses for its fields a `Menuitem`. You can also customize the key events with a `KeyConfiguration`.\r\n\r\nTo setup a List menu you can write the following\r\n\r\n```py\r\nfrom flyconsole import ListMenu\r\n\r\nmenu = Menu(0) # 0 Defines the y coordinate of the menu\r\nmenu.add_item('Item A')\r\nmenu.add_item('Item B')\r\nmenu.add_item('Item C')\r\nmenu.enable() # Shows the menu and enables the Key Events\r\n\r\n# After the menu is done you can get its result with\r\nmenu.result\r\n# The result will return a MenuItem\r\n```\r\n\r\nWhen we look at the `ListMenu` init arguments\r\n\r\n```py\r\nListMenu(y:int=0, can_cancel:bool=1, can_escape:bool=1, key_configuration:KeyConfiguration=KeyConfiguration())\r\n```\r\n\r\nwe can see, we can disable the `[CTRl] + [C]` cancel and the `[ESC]` key. The cancel and escape keys can also be modified in a `KeyConfiguration`\r\n\r\nThe Keyconfiguration looks like this\r\n\r\n```py\r\n@dataclass\r\nclass KeyConfiguration:\r\n up: tuple = (72, 1)\r\n down: tuple = (80, 1)\r\n select: tuple = (13, 0)\r\n escape: tuple = (27, 0)\r\n cancel: tuple = (3, 0)\r\n```\r\n\r\nForeach tuple the first argument is the keycode and the second argument defines if the key means something else. For example if you press an arrow key it will return `(72, 1)` and if u press `[H]` it will return `(72, 0)`.\r\n",
"bugtrack_url": null,
"license": "",
"summary": "Modify the Terminal",
"version": "1.2",
"project_urls": {
"Homepage": "https://github.com/fluffeliger/fly-console",
"Issues": "https://github.com/fluffeliger/fly-console/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3b14675c6e3ec86889e8af30618906f46e961a347521c8922d4deee97a9982e4",
"md5": "a86d9a02c6bf5bf6b2b5c64bb1f735c7",
"sha256": "34ff8003aee00aa0d83e43adbb210b3f32461a04a61d4c7126870967546ba2b0"
},
"downloads": -1,
"filename": "flyconsole-1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a86d9a02c6bf5bf6b2b5c64bb1f735c7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 6621,
"upload_time": "2023-12-07T15:34:13",
"upload_time_iso_8601": "2023-12-07T15:34:13.134081Z",
"url": "https://files.pythonhosted.org/packages/3b/14/675c6e3ec86889e8af30618906f46e961a347521c8922d4deee97a9982e4/flyconsole-1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4cfdb12c60b213ac6a1a852297c78506a8c027165f85d35ec7dd9bb0eb57581e",
"md5": "9c3e633b1a8005cfac1931371b599bef",
"sha256": "9cfdd9639e213a3f1fc765ba2a37146a0fcd0399f914fd33bfd2389411916f1d"
},
"downloads": -1,
"filename": "flyconsole-1.2.tar.gz",
"has_sig": false,
"md5_digest": "9c3e633b1a8005cfac1931371b599bef",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 6386,
"upload_time": "2023-12-07T15:34:14",
"upload_time_iso_8601": "2023-12-07T15:34:14.714482Z",
"url": "https://files.pythonhosted.org/packages/4c/fd/b12c60b213ac6a1a852297c78506a8c027165f85d35ec7dd9bb0eb57581e/flyconsole-1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-07 15:34:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "fluffeliger",
"github_project": "fly-console",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "flyconsole"
}