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

51 lines
1.4 KiB
Plaintext
Raw Normal View History

2024-07-14 16:24:54 +02:00
@page "/openbirch"
2024-07-15 04:08:10 +02:00
@inject OpenBirchConsole console
@inject IJSRuntime js
2024-07-14 16:24:54 +02:00
<div class="console-container reverse-stack-direction pa-4">
2024-07-15 04:08:10 +02:00
<div class="px-2 h-100 reverse-scroll-start overflow-auto">
2024-07-14 16:24:54 +02:00
<div>
2024-07-15 04:08:10 +02:00
@for (int i = 0; i < console.history.Count; i++)
2024-07-14 16:24:54 +02:00
{
int temp = i;
2024-07-15 04:08:10 +02:00
ConsoleLine line = console.history[temp];
<MudText Align="Align.Start"> @((line.source == ConsoleSource.User) ? ">" : "") @line.text</MudText>
@if (line.source == ConsoleSource.OpenBirch)
{
<br/>
}
2024-07-14 16:24:54 +02:00
}
</div>
</div>
<div>
2024-07-15 04:08:10 +02:00
<MudTextField id="console-input" AutoFocus="true" @bind-Value="inputField" Variant="Variant.Outlined" OnKeyDown="OnKeyDown" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.ArrowForwardIos"></MudTextField>
2024-07-14 16:24:54 +02:00
</div>
</div>
@code {
2024-07-15 04:08:10 +02:00
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()
{
}
2024-07-14 16:24:54 +02:00
}