• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

TypeScript blessed.box函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中blessed.box函数的典型用法代码示例。如果您正苦于以下问题:TypeScript box函数的具体用法?TypeScript box怎么用?TypeScript box使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了box函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: heatMap

export const labelbar = (options: ProgressSetOptions) => {
    const bar = blessed.progressbar({
        parent: options.parent,
        bottom: options.bottom,
        left: '25%',
        // pch: 'X',
        width: '72%',
        height: '10%',
        filled: 0,
        orientation: 'horizontal',
        style: {
            fg: 'black',
            bg: 'black',
            bar: {
                bg: 'white',
                fg: 'white'
            }
        }
    });

    const tempBox = blessed.box({
        parent: options.parent,
        bottom: options.bottom,
        left: 0,
        right: 2,
        height: '10%',
        width: '25%',
        tags: true
    });

    const updateLabel = (value) => {
        let valueString = `${value}${options.unit}`;

        if (options.useHeatMap) {
            // const color = heatMap(value);
            // valueString = `{${color}}${valueString}{/${color}}`;
        }

        tempBox.setContent(`{bold}${options.label}{/bold} ${valueString}`);
    };

    const updateBar = (value) => {
        bar.setProgress(value);

        if (options.useHeatMap) {
            bar.style.bar.bg = heatMap(value);
        }
    };

    const updateValue = (value) => {
        updateLabel(value);
        updateBar(value);
    };

    return { updateValue }
};
开发者ID:fanch317,项目名称:cloudshell-lcd-blessed,代码行数:56,代码来源:visualization.ts


示例2:

let screen: blessed.Widgets.Screen = null;

// https://github.com/chjj/blessed/blob/master/test/widget-autopad.js

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

const box1 = blessed.box({
  parent: screen,
  top: "center",
  left: "center",
  width: 20,
  height: 10,
  border: "line"
});

const box2 = blessed.box({
  parent: box1,
  top: 0,
  left: 0,
  width: 10,
  height: 5,
  border: "line"
});

screen.key("q", () => screen.destroy());
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:30,代码来源:blessed-tests.ts


示例3: function

let screen: blessed.Widgets.Screen = null;

// https://github.com/chjj/blessed/blob/master/test/widget-autopad.js

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

var box1 = blessed.box({
  parent: screen,
  top: 'center',
  left: 'center',
  width: 20,
  height: 10,
  border: 'line'
});

var box2 = blessed.box({
  parent: box1,
  top: 0,
  left: 0,
  width: 10,
  height: 5,
  border: 'line'
});

screen.key('q', function() {
  return screen.destroy();
开发者ID:ArtemZag,项目名称:DefinitelyTyped,代码行数:31,代码来源:blessed-tests.ts


示例4: main

(async function main() {
    const provider = new DataProvider();

    // Create a screen object.
    const theScreen = blessed.screen({
        smartCSR: true
    });

    // theScreen.title = 'my window title';

    // Create a box perfectly centered horizontally and vertically.
    const box = blessed.box({
        top: 'center',
        left: 'center',
        width: '100%',
        height: '100%',
        content: ``,
        tags: true,
        border: {
            type: 'bg'
        },
        style: {
            fg: 'white',
            bg: 'purple',
            border: {
                bg: 'black'
            }
        }
    });

    const tempSet = labelbar({
        parent: box,
        label: 'temp',
        value: 0,
        unit: 'C',
        useHeatMap: true,
        bottom: 0
    });

    const memSet = labelbar({
        parent: box,
        label: 'mem',
        value: 0,
        unit: '%',
        useHeatMap: true,
        bottom: 2
    });

    const cpuSet = labelbar({
        parent: box,
        label: 'cpu',
        value: 0,
        unit: '%',
        useHeatMap: true,
        bottom: 4
    });

    const fsSet = labelbar({
        parent: box,
        label: 'btrfs',
        value: 0,
        unit: '%',
        useHeatMap: true,
        bottom: 6
    });

    // Append our box to the screen.
    theScreen.append(box);

    provider.on('data', function(data) {
        box.setContent(`{bold}{red-fg}${data.hostname || ''}{/}`);

        cpuSet.updateValue(Math.round(data.cpu) || 0);
        tempSet.updateValue(data.temp || 0);
        fsSet.updateValue(data.fsUsage ? data.fsUsage.usedPercent : 0);
        memSet.updateValue(data.mem || 0);

        theScreen.render();
    });

    // Quit on Escape, q, or Control-C.
    theScreen.key(['escape', 'q', 'C-c'], function(ch, key) {
        return process.exit(0);
    });

    // Focus our element.
    box.focus();

    // Render the screen.
    theScreen.render();

})();
开发者ID:fanch317,项目名称:cloudshell-lcd-blessed,代码行数:92,代码来源:app.ts


示例5:

 */
var mainScreen: any = blessed.screen();

/*
 * Create a box in top-left corner of the screen, sized just enough to hold a
 * TPC-C terminal's contents.
 */
var mainBox: any = blessed.box({
  parent: mainScreen, /* This box is the only child of the screen */
  top: 'top',
  left: 'left',
  width: '100%',
  height: '100%',
  tags: true,
  border: {
    type: 'line'
  },
  style: {
    fg: 'white',
    bg: 'black',
    border: {
      fg: '#f0f0f0',
    },
  }
});

/* Create a box to display license and warranty message at the bottom of the main box. */
var adminBox: any = blessed.box({
  parent: mainBox,
  left: 'center',
  bottom: 0,
  width: '100%',
开发者ID:llcoolchak,项目名称:DBYardstick,代码行数:32,代码来源:tpcc.ts



注:本文中的blessed.box函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript blessed.button函数代码示例发布时间:2022-05-25
下一篇:
TypeScript blessed.bigtext函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap