added basic connection between the files, fixed small issues. some parts were achieved using ai.
This commit is contained in:
parent
dd5816b175
commit
45e5cadc62
4 changed files with 184 additions and 63 deletions
|
|
@ -5,10 +5,16 @@ haTerm - v0.1
|
|||
haTerm is a Terminal Based hafas client, using the ivb endpoint.
|
||||
Prompt_toolkit (https://github.com/prompt-toolkit/python-prompt-toolkit) will be used to render a terminal user interface (TUI).
|
||||
The application will provide routing information and station departures/arrivals.
|
||||
"""
|
||||
#routenplanung mit promt tool kit
|
||||
|
||||
import prompt_toolkit as pk
|
||||
Route planning UI.
|
||||
|
||||
Wrapped in a function so it can be launched from `main.py` with a shared
|
||||
`HafasClient` instance from `backend.py`.
|
||||
|
||||
Note: This module is a minimal TUI stub. Many features are not implemented
|
||||
yet (station lookup, route rendering). Add TODOs where appropriate.
|
||||
"""
|
||||
|
||||
import time
|
||||
from prompt_toolkit import Application
|
||||
from prompt_toolkit.buffer import Buffer
|
||||
|
|
@ -17,25 +23,39 @@ from prompt_toolkit.layout.controls import BufferControl
|
|||
from prompt_toolkit.layout.layout import Layout
|
||||
from prompt_toolkit.key_binding import KeyBindings
|
||||
|
||||
kb = KeyBindings()
|
||||
startBuffer = Buffer()
|
||||
endBuffer = Buffer()
|
||||
import backend
|
||||
|
||||
|
||||
root_container = HSplit(children=[
|
||||
HSplit(children=[
|
||||
Window(content=BufferControl(buffer=startBuffer, focusable=True)),
|
||||
Window(width=1, char='-', style="fg:#2A71D5"),
|
||||
def run_route_planning(hafas: backend.HafasClient | None = None):
|
||||
"""Run the route planning TUI.
|
||||
|
||||
Window(content=BufferControl(buffer=endBuffer, focusable=True))
|
||||
]),
|
||||
Window(height=1, char=' ', style="bg:#2A71D5 fg:black"),
|
||||
#Window(content=BufferControl(buffer=userBuffer),height=4),
|
||||
])
|
||||
Parameters:
|
||||
- hafas: optional shared HafasClient instance. If omitted, a new one is
|
||||
created. Prefer passing the shared client from `main.py`.
|
||||
"""
|
||||
if hafas is None:
|
||||
hafas = backend.HafasClient()
|
||||
|
||||
layout = Layout(root_container)
|
||||
# TODO: integrate actual station search + routing using `hafas`.
|
||||
kb = KeyBindings()
|
||||
startBuffer = Buffer()
|
||||
endBuffer = Buffer()
|
||||
|
||||
app = Application(layout=layout, key_bindings=kb, full_screen=True)
|
||||
root_container = HSplit(children=[
|
||||
HSplit(children=[
|
||||
Window(content=BufferControl(buffer=startBuffer, focusable=True)),
|
||||
Window(width=1, char='-', style="fg:#2A71D5"),
|
||||
Window(content=BufferControl(buffer=endBuffer, focusable=True))
|
||||
]),
|
||||
Window(height=1, char=' ', style="bg:#2A71D5 fg:black"),
|
||||
])
|
||||
|
||||
app.run()
|
||||
layout = Layout(root_container)
|
||||
app = Application(layout=layout, key_bindings=kb, full_screen=True)
|
||||
|
||||
try:
|
||||
app.run()
|
||||
except KeyboardInterrupt:
|
||||
# graceful exit on Ctrl-C
|
||||
return
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue