continued adding support for other text editors, added a home screen

This commit is contained in:
2026-05-16 21:18:21 +10:00
parent 7df6ce10c7
commit fc07ffbfa8
6 changed files with 255 additions and 116 deletions

103
home_page.py Normal file
View File

@@ -0,0 +1,103 @@
from textual.containers import Center, Vertical, Horizontal
from textual.widgets import Rule, Static
from textual import on
from textualeffects.widgets import EffectLabel
from textualeffects.effects import effects
from terminaltexteffects.utils.graphics import Color
class HomePage(Vertical):
LOGO = r""" ______ ______ ______ ______ __ __
/\ == \ /\ ___\ /\ == \ /\ == \ /\ \_\ \
\ \ __< \ \ __\ \ \ __< \ \ __< \ \____ \
\ \_____\ \ \_____\ \ \_\ \_\ \ \_\ \_\ \/\_____\
\/_____/ \/_____/ \/_/ /_/ \/_/ /_/ \/_____/
"""
DEFAULT_CSS = """
HomePage {
content-align: center top;
Static {
text-align: center;
}
#banner {
height: 5; # probs will need to be updated
margin-bottom: 1;
Rule {
color: $surface-lighten-2;
height: 100%;
content-align: center middle;
margin: 0 3;
}
EffectLabel {
height: 100%;
}
}
#bindings {
Horizontal {
max-width: 50;
width: 50%;
margin-top: 1;
height: 1;
.bind-name {
width: 85%;
}
.bind-keys {
width: 15%;
}
Static {
text-align: left;
link-background: transparent;
link-color: $primary;
}
}
}
}
"""
@on(EffectLabel.EffectFinished)
def restart_effect(self):
self.banner_label.run_worker(self.banner_label.run_effect, exclusive=True)
def compose(self):
with Horizontal(id="banner"):
yield Rule()
self.banner_label = EffectLabel(self.LOGO, effect="Highlight", config={
"final_gradient_stops": [Color("#f263ff"), Color("#946ff2")],
"cycles": 0
})
yield self.banner_label
yield Rule()
yield Static("[dim]The text editor that no one asked for and didn't need.[/]")
# bindings
with Center(id="bindings"):
binds = self.app.bindings
with Horizontal():
yield Static("[b] New file[/]", classes="bind-name")
yield Static(f"[@click=app.new]{binds["new"]}[/]", classes="bind-keys")
with Horizontal():
yield Static("[b] Open file[/]", classes="bind-name")
yield Static(f"[@click=app.open]{binds["open"]}[/]", classes="bind-keys")
with Horizontal():
yield Static("[b] Settings[/]", classes="bind-name")
yield Static(f"[@click=app.settings]{binds["settings"]}[/]", classes="bind-keys")