Removed new project title, displaying directory right to create button instead of input
This commit is contained in:
+14
-18
@@ -68,7 +68,6 @@ def new_project(template: Optional[str] = "../toolchain-mod") -> Optional[int]:
|
|||||||
from prompt_toolkit.keys import Keys
|
from prompt_toolkit.keys import Keys
|
||||||
from prompt_toolkit.layout import (HSplit, Layout, ScrollablePane,
|
from prompt_toolkit.layout import (HSplit, Layout, ScrollablePane,
|
||||||
ScrollOffsets, Window)
|
ScrollOffsets, Window)
|
||||||
from prompt_toolkit.layout.processors import AfterInput, ConditionalProcessor
|
|
||||||
contents = [
|
contents = [
|
||||||
Interactable("Create new project"),
|
Interactable("Create new project"),
|
||||||
Window(height=1),
|
Window(height=1),
|
||||||
@@ -84,19 +83,18 @@ def new_project(template: Optional[str] = "../toolchain-mod") -> Optional[int]:
|
|||||||
def update_project_name(buffer: Buffer) -> None:
|
def update_project_name(buffer: Buffer) -> None:
|
||||||
nonlocal output_directory
|
nonlocal output_directory
|
||||||
output_directory = get_project_folder_by_name(GLOBALS.TOOLCHAIN_CONFIG.directory, buffer.text)
|
output_directory = get_project_folder_by_name(GLOBALS.TOOLCHAIN_CONFIG.directory, buffer.text)
|
||||||
create_interactable.style = "" if output_directory is not None else "class:print.answer"
|
if output_directory:
|
||||||
|
create_interactable.interactable_text = f"Create in {output_directory}!"
|
||||||
|
create_interactable.style = ""
|
||||||
|
else:
|
||||||
|
create_interactable.interactable_text = "Create..."
|
||||||
|
create_interactable.style = "class:print.answer"
|
||||||
|
|
||||||
name_editable = Editable(
|
name_editable = Editable(
|
||||||
"Name: ",
|
"Name: ",
|
||||||
text=GLOBALS.TOOLCHAIN_CONFIG.get_value("template.name", ""),
|
text=GLOBALS.TOOLCHAIN_CONFIG.get_value("template.name", ""),
|
||||||
hint=template_config.get_value("info.name"),
|
hint=template_config.get_value("info.name"),
|
||||||
on_text_changed=update_project_name,
|
on_text_changed=update_project_name
|
||||||
input_processors=[
|
|
||||||
ConditionalProcessor(
|
|
||||||
AfterInput(lambda: f" in {output_directory}", style="class:print.answer"),
|
|
||||||
Condition(lambda: output_directory is not None)
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
contents.append(name_editable)
|
contents.append(name_editable)
|
||||||
|
|
||||||
@@ -129,14 +127,15 @@ def new_project(template: Optional[str] = "../toolchain-mod") -> Optional[int]:
|
|||||||
description_editable,
|
description_editable,
|
||||||
client_side_selectable
|
client_side_selectable
|
||||||
]
|
]
|
||||||
|
|
||||||
create_interactable = Interactable(
|
create_interactable = Interactable(
|
||||||
"Create!",
|
|
||||||
focusable=Condition(lambda: output_directory is not None),
|
focusable=Condition(lambda: output_directory is not None),
|
||||||
on_interact=lambda _: app.exit(),
|
on_interact=lambda _: app.exit(),
|
||||||
add_interact_key_bindings=True,
|
add_interact_key_bindings=True,
|
||||||
always_indent=True
|
always_indent=True
|
||||||
)
|
)
|
||||||
contents.append(create_interactable)
|
contents.append(create_interactable)
|
||||||
|
|
||||||
if not have_template:
|
if not have_template:
|
||||||
contents += [
|
contents += [
|
||||||
Window(height=1),
|
Window(height=1),
|
||||||
@@ -156,14 +155,11 @@ def new_project(template: Optional[str] = "../toolchain-mod") -> Optional[int]:
|
|||||||
|
|
||||||
app = Application(
|
app = Application(
|
||||||
layout=Layout(
|
layout=Layout(
|
||||||
HSplit([
|
ScrollablePane(
|
||||||
Interactable("Inner Core Mod Toolchain"),
|
HSplit(contents),
|
||||||
ScrollablePane(
|
scroll_offsets=ScrollOffsets(3, 3),
|
||||||
HSplit(contents),
|
display_arrows=False,
|
||||||
scroll_offsets=ScrollOffsets(3, 3),
|
)
|
||||||
display_arrows=False,
|
|
||||||
)
|
|
||||||
])
|
|
||||||
),
|
),
|
||||||
style=get_toolchain_style(),
|
style=get_toolchain_style(),
|
||||||
include_default_pygments_style=False,
|
include_default_pygments_style=False,
|
||||||
|
|||||||
Reference in New Issue
Block a user