-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Added material documentation, api reference
- Loading branch information
Showing
10 changed files
with
375 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# API Reference | ||
|
||
## Terminals | ||
|
||
::: mono.Terminals | ||
|
||
## Shells | ||
|
||
::: mono.shells | ||
|
||
## Terminal | ||
|
||
::: mono.terminal.Terminal | ||
|
||
## Theme | ||
|
||
::: mono.theme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
## Mono: Embeddable Terminal Emulator | ||
|
||
<!-- prettier-ignore --> | ||
!!! Info "New Output Parser" | ||
See [PR #4](https://github.com/tomlin7/mono/pull/4) on new output parser under development | ||
|
||
<!-- prettier-ignore --> | ||
**Mono** is a terminal emulator that can be embedded in tkinter applications. See [examples](./examples) to see mono in action. The codebase was extracted from the [**Biscuit project**](https://github.com/billyeatcookies/biscuit) and published as an embeddable widget library. | ||
|
||
- Supports handling **multiple instances** of terminals of different shells running simultaneously. | ||
- Comes as a standalone terminal widget & a **tabbed widget** as well, for handling different terminal instances. | ||
- **Custom terminals** can be made; most shells available on the platform are detected by mono. | ||
- Themes are fully customizable by the user. | ||
|
||
![monopreview](https://github.com/user-attachments/assets/365babe3-0ffd-4095-a8b8-ff98d0e615a7) | ||
|
||
```py title="examples/tabbed.py" hl_lines="2 7 8 9" | ||
import tkinter as tk | ||
from mono import Terminals, get_available_shells, get_shell_from_name | ||
|
||
root = tk.Tk() | ||
root.geometry('800x300') | ||
|
||
terminals = Terminals(root) | ||
terminals.add_default_terminal() | ||
terminals.pack(fill='both', expand=True) | ||
|
||
# A menu for opening terminals | ||
mbtn = tk.Menubutton(root, text="Open Terminal", relief=tk.RAISED) | ||
menu = tk.Menu(mbtn) | ||
for i in get_available_shells(): | ||
menu.add_command(label=i, command=lambda i=i: terminals.open_shell(get_shell_from_name(i))) | ||
|
||
mbtn.config(menu=menu) | ||
mbtn.pack() | ||
root.mainloop() | ||
``` | ||
|
||
`Terminals` is a container for multiple terminals. It provides a simple interface for managing multiple terminals in a tabbed interface. | ||
|
||
All the shells detected for the platform can be accessed with `get_available_shells()`. The `get_shell_from_name()` function returns a shell object from the name of the shell. | ||
|
||
### Custom Terminals | ||
|
||
Following example demonstrates how to create a NodeJS standalone terminal with mono. | ||
|
||
```py title="examples/customshell.py" hl_lines="7 8 9 12 13" | ||
# NOTE: Due to the missing additional ANSI handling, NodeJS shell | ||
# might not work as expected. The issue is being fixed, see pr #4 | ||
|
||
import tkinter as tk | ||
from mono import Terminal | ||
|
||
class NodeJS(Terminal): | ||
name = "NodeJS" | ||
shell = "node" | ||
|
||
root = tk.Tk() | ||
terminal = NodeJS(root) | ||
terminal.start_service() | ||
terminal.pack(fill='both', expand=True) | ||
|
||
root.mainloop() | ||
``` | ||
|
||
### Custom Theming | ||
|
||
Following example implements a custom light theme for mono terminals | ||
|
||
```py title="examples/customtheme.py" hl_lines="4 5 6 7 8 9 21" | ||
import tkinter as tk | ||
from mono import Terminals, Theme | ||
|
||
class Light(Theme): | ||
bg = "#FFFFFF" | ||
fg = "#000000" | ||
abg = "#CCCCCC" | ||
afg = "#000000" | ||
border = "#DDDDDD" | ||
|
||
# further overriding the __init__ will give more control over specific widgets: | ||
# | ||
# def __init__(self, master=None, **kwargs): | ||
# super().__init__(master, **kwargs) | ||
# self.tabs = (self.bg, 'red') | ||
|
||
|
||
root = tk.Tk() | ||
root.geometry("800x300") | ||
|
||
terminals = Terminals(root, theme=Light()) | ||
terminals.pack(fill="both", expand=True) | ||
|
||
terminals.open_python() # open a python console | ||
terminals.open_another_terminal() # open another instance of active | ||
|
||
root.mainloop() | ||
``` | ||
|
||
Further... | ||
|
||
- Shells can be run standalone or in a tabbed interface, see [examples/standalone](./examples/standalone.py). | ||
- Custom terminals can be made by subclassing the `Terminal` class, see [examples/customshell](./examples/customshell.py). | ||
- Custom themes can be passed to the `Terminal`, `Terminals` classes, see [examples/customtheme](./examples/customtheme.py). | ||
- High resolution text rendering can be enabled for windows, see [examples/highres](./examples/highres.py). | ||
|
||
For more examples, see the [examples](./examples) directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
site_name: Mono | ||
site_description: "Embeddable terminal emulator" | ||
site_url: "https://tomlin7.github.io/mono" | ||
repo_url: "https://github.com/tomlin7/mono" | ||
repo_name: "tomlin7/mono" | ||
copyright: Copyright © 2024 Billy | ||
|
||
theme: | ||
name: "material" | ||
palette: | ||
- media: "(prefers-color-scheme: light)" | ||
scheme: default | ||
primary: pink | ||
accent: pink | ||
toggle: | ||
icon: material/weather-sunny | ||
name: Switch to dark mode | ||
|
||
- media: "(prefers-color-scheme: dark)" | ||
scheme: slate | ||
primary: black | ||
accent: pink | ||
toggle: | ||
icon: material/weather-night | ||
name: Switch to light mode | ||
features: | ||
- navigation.top | ||
- toc.follow | ||
- content.code.copy | ||
- content.code.select | ||
|
||
plugins: | ||
- mkdocstrings: | ||
handlers: | ||
python: | ||
options: | ||
heading_level: 3 | ||
- search | ||
- autorefs | ||
|
||
nav: | ||
- Home: index.md | ||
- API Reference: api-reference.md | ||
|
||
extra: | ||
social: | ||
- icon: fontawesome/brands/github | ||
link: https://github.com/tomlin7/mono | ||
|
||
markdown_extensions: | ||
- pymdownx.highlight: | ||
anchor_linenums: true | ||
line_spans: __span | ||
pygments_lang_class: true | ||
- pymdownx.inlinehilite | ||
- pymdownx.snippets | ||
- pymdownx.superfences | ||
- admonition | ||
- pymdownx.details |
Oops, something went wrong.