当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript blessed.box函数代码示例

本文整理汇总了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;未经允许,请勿转载。