deprived-main-website/OpenBirchWebsite/Pages/OpenBirch.razor

40 lines
1015 B
Plaintext

@page "/openbirch"
@inject OpenBirchConsole console
@inject IJSRuntime js
<div class="console-container reverse-stack-direction pa-4">
<div class="px-2 h-100 reverse-scroll-start overflow-auto">
<ConsoleText/>
</div>
<div>
<MudTextField id="console-input" AutoFocus="true" @bind-Value="inputField" Variant="Variant.Outlined" OnKeyDown="OnKeyDown" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.ArrowForwardIos"></MudTextField>
</div>
</div>
@code {
public string inputField = "";
async void OnKeyDown(KeyboardEventArgs args)
{
if (args.Key == "Enter")
{
await Task.Delay(100);
sendCommand(inputField);
StateHasChanged();
}
}
private async void sendCommand(string command)
{
inputField = "";
await console.pushCommand(command);
await InvokeAsync(StateHasChanged);
}
protected override async Task OnInitializedAsync()
{
}
}