51 lines
1.4 KiB
Plaintext
51 lines
1.4 KiB
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">
|
|
<div>
|
|
@for (int i = 0; i < console.history.Count; i++)
|
|
{
|
|
int temp = i;
|
|
ConsoleLine line = console.history[temp];
|
|
<MudText Align="Align.Start"> @((line.source == ConsoleSource.User) ? ">" : "") @line.text</MudText>
|
|
@if (line.source == ConsoleSource.OpenBirch)
|
|
{
|
|
<br/>
|
|
}
|
|
}
|
|
</div>
|
|
</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()
|
|
{
|
|
|
|
}
|
|
}
|