3h-term 中文文档教程

发布于 4年前 浏览 26 项目主页 更新于 3年前

3h-term

浏览器中的终端模拟器。

Example

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>3h-term example</title>
</head>

<body>
    <script type="text/javascript" crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/super-x@1.0.0/dist/super-x.umd.min.js"></script>
    <script type="text/javascript" crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/3h-term@0.1.0/dist/3h-term.umd.min.js"></script>
    <script>

        const handlers = new Map([
            ['echo', input => {
                terminal.writeln(`"${input}"`);
            }],
            ['clear', () => {
                terminal.clear();
            }],
        ]);

        const terminal = new T.Terminal(
            {
                margin: '1em auto',
                width: '480px',
                height: '320px',
                fontSize: '16px',
                borderRadius: '5px',
            },
            T.createProgram(handlers, input => {
                terminal.writeln(`Unknown operation: ${input}`);
            })
        );

        document.body.appendChild(terminal.container);

        terminal.write('This is an example of ')
            .write('3h-term', {
                color: '#FFF',
                fontWeight: 'bold',
            })
            .write('.')
            .writeln();

    </script>
</body>

</html>

3h-term

A terminal simulator in browser.

Example

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>3h-term example</title>
</head>

<body>
    <script type="text/javascript" crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/super-x@1.0.0/dist/super-x.umd.min.js"></script>
    <script type="text/javascript" crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/3h-term@0.1.0/dist/3h-term.umd.min.js"></script>
    <script>

        const handlers = new Map([
            ['echo', input => {
                terminal.writeln(`"${input}"`);
            }],
            ['clear', () => {
                terminal.clear();
            }],
        ]);

        const terminal = new T.Terminal(
            {
                margin: '1em auto',
                width: '480px',
                height: '320px',
                fontSize: '16px',
                borderRadius: '5px',
            },
            T.createProgram(handlers, input => {
                terminal.writeln(`Unknown operation: ${input}`);
            })
        );

        document.body.appendChild(terminal.container);

        terminal.write('This is an example of ')
            .write('3h-term', {
                color: '#FFF',
                fontWeight: 'bold',
            })
            .write('.')
            .writeln();

    </script>
</body>

</html>
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文