首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何集成节点模块vorpal和blessed

如何集成节点模块vorpal和blessed
EN

Stack Overflow用户
提问于 2015-12-22 19:14:50
回答 1查看 586关注 0票数 1

我想集成的节点模块祝福和vorpal,谁能给我一些关于如何集成这两个模块的提示,非常感谢!

下面是我的草稿代码(仅供参考),我的目标是终端的左侧部分用于vorpal交互式CLI,右上角部分用于日志输出。

代码语言:javascript
复制
var blessed = require('blessed')
    , screen;
var vorpal = require('vorpal')();

vorpal
    .command('foo', 'bar')
    .action(function(args, callback) {
        this.log('bar');
        callback();
    });

vorpal
    .delimiter('testapp$')
    .show();

screen = blessed.screen({
    dump: __dirname + '/logs/logger.log',
    smartCSR: true,
    autoPadding: false,
    warnings: true
});

//This area I want the vorpal interactive CLI
var leftPart = blessed.box({
    parent: screen,
    left: 0,
    top: 0,
    width: '50%',
    height: '100%',
    border: {
        type: 'line',
        left: false,
        top: false,
        right: true,
        bottom: false
    },
    // border: 'line',

    content: 'I want here is the normal terminal input/output with vorpal style\n'+
             'How can I do this?'
    //content:vorpal
});

//This area with be the log output area
var logger = blessed.log({
    parent: screen,
    top: '0',
    left: '50%-1',
    width: '50%-1',
    height: '50%-1',
    border: 'line',
    tags: true,
    keys: true,
    vi: true,
    mouse: true,
    scrollback: 100,
    scrollbar: {
        ch: ' ',
        track: {
            bg: 'yellow'
        },
        style: {
            inverse: true
        }
    }
});

leftPart.focus();


setInterval(function() {
    logger.log('Hello {#0fe1ab-fg}world{/}: {bold}%s{/bold}.', Date.now().toString(36));

    //screen.render();
}, 1000).unref();

screen.key('q', function() {
    return screen.destroy();
});

screen.render();
EN

回答 1

Stack Overflow用户

发布于 2015-12-23 01:09:16

我不认为这是以前尝试过的,所以这是一种未知的领域!

我确实认为你将能够在Vorpal中使用受祝福的组件,但是我不确定你是否能够将Vorpal提示符填充到受祝福的方框包装中。Vorpal是基于Inquirer.js的,他的逻辑是根据提示符的位置而设计的。

也许您将日志框放在屏幕顶部,并保持Vorpal提示符的位置。

尝试一下,看看它是否有效--并在进行的过程中随时询问更多的问题!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34414603

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档