Skip to content

Commit

Permalink
Update Demos
Browse files Browse the repository at this point in the history
  • Loading branch information
BattlefieldDuck committed Mar 7, 2024
1 parent 5404109 commit ab31802
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,22 @@ In the HTML body section of either `index.html` or `_Host.cshtml` add this:
## Addons
Xterm supports [Addons](https://github.com/xtermjs/xterm.js/tree/master/addons)

To use `xterm-addon-fit` addon, you need to add the following to your HTML body section either `index.html` or `_Host.cshtml`.
To use `@xterm/addon-fit` addon, you need to add the following to your HTML body section either `index.html` or `_Host.cshtml`.

```html
<!-- Add xterm-addon-fit.min.js before XtermBlazor.min.js -->
<!-- Add addon-fit.min.js before XtermBlazor.min.js -->
<script src="https://cdn.jsdelivr.net/npm/@xterm/[email protected]/lib/addon-fit.min.js"></script>

<script src="_content/XtermBlazor/XtermBlazor.min.js"></script>

<!-- Register addon to XtermBlazor -->
<script>XtermBlazor.registerAddons({"xterm-addon-fit": new FitAddon.FitAddon()});</script>
<script>XtermBlazor.registerAddons({"addon-fit": new FitAddon.FitAddon()});</script>
```

### Usage with addons

```razor
<Xterm @ref="_terminal" Options="_options" AddonIds="_addonIds" OnFirstRender="@OnFirstRender" />
<Xterm @ref="_terminal" Options="_options" Addons="_addons" OnFirstRender="@OnFirstRender" />
@code {
private Xterm _terminal;
Expand All @@ -108,15 +108,15 @@ To use `xterm-addon-fit` addon, you need to add the following to your HTML body
CursorStyle = CursorStyle.Bar,
};
private string[] _addonIds = new string[]
private HashSet<string> _addons = new HashSet<string>()
{
"xterm-addon-fit",
"addon-fit",
};
private async Task OnFirstRender()
{
// Invoke fit() function
await _terminal.InvokeAddonFunctionVoidAsync("xterm-addon-fit", "fit");
await _terminal.Addon("addon-fit").InvokeVoidAsync("fit");
await _terminal.WriteLine("Hello World");
}
Expand Down
12 changes: 6 additions & 6 deletions XtermBlazor.Demo.Server/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ EventCallback Logs:

private HashSet<string> _addons = new HashSet<string>()
{
"xterm-addon-fit",
"xterm-addon-search",
"xterm-addon-web-links",
"addon-fit",
"addon-search",
"addon-web-links",
};

private TerminalOptions _options2 = new TerminalOptions
Expand Down Expand Up @@ -130,8 +130,8 @@ EventCallback Logs:
});
}

await _terminal.Addon("xterm-addon-fit").InvokeVoidAsync("fit");
await _terminalEvent.Addon("xterm-addon-fit").InvokeVoidAsync("fit");
await _terminal.Addon("addon-fit").InvokeVoidAsync("fit");
await _terminalEvent.Addon("addon-fit").InvokeVoidAsync("fit");

_columns = await _terminal.GetColumns();
_rows = await _terminal.GetRows();
Expand Down Expand Up @@ -245,7 +245,7 @@ EventCallback Logs:

private async Task Search(MouseEventArgs args)
{
bool searchSuccess = await _terminal.Addon("xterm-addon-search").InvokeAsync<bool>("findNext", _searchInput);
bool searchSuccess = await _terminal.Addon("addon-search").InvokeAsync<bool>("findNext", _searchInput);
await _terminalEvent.WriteLine($"({++_eventId}) Search(): {searchSuccess}");
}

Expand Down
12 changes: 6 additions & 6 deletions XtermBlazor.Demo.Server/Pages/_Host.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
<a class="dismiss">🗙</a>
</div>

<script src="https://cdn.jsdelivr.net/npm/xterm-addon-fit@0.7.0/lib/xterm-addon-fit.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xterm-addon-search@0.11.0/lib/xterm-addon-search.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xterm-addon-web-links@0.8.0/lib/xterm-addon-web-links.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@xterm/addon-fit@0.9.0/lib/addon-fit.min.js"></script>

Check failure on line 36 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (6)

The name 'xterm' does not exist in the current context

Check failure on line 36 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (6)

The name 'xterm' does not exist in the current context

Check failure on line 36 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (7)

The name 'xterm' does not exist in the current context

Check failure on line 36 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (7)

The name 'xterm' does not exist in the current context

Check failure on line 36 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (8)

The name 'xterm' does not exist in the current context

Check failure on line 36 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (8)

The name 'xterm' does not exist in the current context
<script src="https://cdn.jsdelivr.net/npm/@xterm/addon-search@0.14.0/lib/addon-search.min.js"></script>

Check failure on line 37 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (6)

The name 'xterm' does not exist in the current context

Check failure on line 37 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (6)

The name 'xterm' does not exist in the current context

Check failure on line 37 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (7)

The name 'xterm' does not exist in the current context

Check failure on line 37 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (7)

The name 'xterm' does not exist in the current context

Check failure on line 37 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (8)

The name 'xterm' does not exist in the current context

Check failure on line 37 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (8)

The name 'xterm' does not exist in the current context
<script src="https://cdn.jsdelivr.net/npm/@xterm/addon-web-links@0.10.0/lib/addon-web-links.min.js"></script>

Check failure on line 38 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (6)

The name 'xterm' does not exist in the current context

Check failure on line 38 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (6)

The name 'xterm' does not exist in the current context

Check failure on line 38 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (7)

The name 'xterm' does not exist in the current context

Check failure on line 38 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (7)

The name 'xterm' does not exist in the current context

Check failure on line 38 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (8)

The name 'xterm' does not exist in the current context

Check failure on line 38 in XtermBlazor.Demo.Server/Pages/_Host.cshtml

View workflow job for this annotation

GitHub Actions / build (8)

The name 'xterm' does not exist in the current context

<script src="_framework/blazor.server.js"></script>
<script src="_content/XtermBlazor/XtermBlazor.min.js"></script>
<script>
XtermBlazor.registerAddons({
"xterm-addon-fit": new FitAddon.FitAddon(),
"xterm-addon-search": new SearchAddon.SearchAddon(),
"xterm-addon-web-links": new WebLinksAddon.WebLinksAddon()
"addon-fit": new FitAddon.FitAddon(),
"addon-search": new SearchAddon.SearchAddon(),
"addon-web-links": new WebLinksAddon.WebLinksAddon()
});
</script>
</body>
Expand Down
12 changes: 6 additions & 6 deletions XtermBlazor.Demo.Wasm/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ EventCallback Logs:

private HashSet<string> _addons = new HashSet<string>()
{
"xterm-addon-fit",
"xterm-addon-search",
"xterm-addon-web-links",
"addon-fit",
"addon-search",
"addon-web-links",
};

private TerminalOptions _options2 = new TerminalOptions
Expand Down Expand Up @@ -130,8 +130,8 @@ EventCallback Logs:
});
}

await _terminal.Addon("xterm-addon-fit").InvokeVoidAsync("fit");
await _terminalEvent.Addon("xterm-addon-fit").InvokeVoidAsync("fit");
await _terminal.Addon("addon-fit").InvokeVoidAsync("fit");
await _terminalEvent.Addon("addon-fit").InvokeVoidAsync("fit");

_columns = await _terminal.GetColumns();
_rows = await _terminal.GetRows();
Expand Down Expand Up @@ -245,7 +245,7 @@ EventCallback Logs:

private async Task Search(MouseEventArgs args)
{
bool searchSuccess = await _terminal.Addon("xterm-addon-search").InvokeAsync<bool>("findNext", _searchInput);
bool searchSuccess = await _terminal.Addon("addon-search").InvokeAsync<bool>("findNext", _searchInput);
await _terminalEvent.WriteLine($"({++_eventId}) Search(): {searchSuccess}");
}

Expand Down
12 changes: 6 additions & 6 deletions XtermBlazor.Demo.Wasm/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@
<a class="dismiss">🗙</a>
</div>

<script src="https://cdn.jsdelivr.net/npm/xterm-addon-fit@0.7.0/lib/xterm-addon-fit.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xterm-addon-search@0.11.0/lib/xterm-addon-search.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xterm-addon-web-links@0.8.0/lib/xterm-addon-web-links.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@xterm/addon-fit@0.9.0/lib/addon-fit.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@xterm/addon-search@0.14.0/lib/addon-search.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@xterm/addon-web-links@0.10.0/lib/addon-web-links.min.js"></script>

<script src="_framework/blazor.webassembly.js"></script>
<script>navigator.serviceWorker.register('service-worker.js');</script>
<script src="_content/XtermBlazor/XtermBlazor.min.js"></script>
<script>
XtermBlazor.registerAddons({
"xterm-addon-fit": new FitAddon.FitAddon(),
"xterm-addon-search": new SearchAddon.SearchAddon(),
"xterm-addon-web-links": new WebLinksAddon.WebLinksAddon()
"addon-fit": new FitAddon.FitAddon(),
"addon-search": new SearchAddon.SearchAddon(),
"addon-web-links": new WebLinksAddon.WebLinksAddon()
});
</script>
</body>
Expand Down

0 comments on commit ab31802

Please sign in to comment.