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


TypeScript blessed.screen函数代码示例

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


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

示例1: Setup

export function Setup(authTokens: Auth.IAuthResult) {
     const screen = Blessed.screen();
     const grid = new Contrib.grid({rows: 12, cols: 12, screen: screen});
     const deviceTable = grid.set(0, 0, 9, 8, Contrib.table,  { 
         keys: true
        , fg: "white"
        , selectedFg: "white"
        , selectedBg: "blue"
        , interactive: true
        , label: "Devices - 'd' to focus"
        , border: {type: "line", fg: "cyan"}
        , columnSpacing: 1
        , columnWidth: [35, 20, 40, 7]
    });
    const groupTable = grid.set(0, 6, 9, 9, Contrib.table,  { 
         keys: true
        , fg: "white"
        , selectedFg: "white"
        , selectedBg: "blue"
        , interactive: true
        , label: "Groups - 'g' to focus"
        , border: {type: "line", fg: "cyan"}
        , columnSpacing: 1
        , columnWidth: [20, 7]
    });
    const robotTable = grid.set(0, 8, 9, 12, Contrib.table,  { 
         keys: true
        , fg: "white"
        , selectedFg: "white"
        , selectedBg: "blue"
        , interactive: true
        , label: "Robots - 'r' to focus"
        , border: {type: "line", fg: "cyan"}
        , columnSpacing: 1
        , columnWidth: [30, 20]
    });
    const log = grid.set(8, 0, 4, 12, Contrib.log, { fg: "green"
      , selectedFg: "green"
      , label: "Log"});
   
   const uiLogger = (message) => {
       log.log(message);
   };
   
   Logger.logEmitter.addListener("log", uiLogger);
   
   Logger.Log.Info(`using access token: ${Array(20).join("*") + authTokens.AccessToken.substring(20, authTokens.AccessToken.length)}`);
    
  
   screen.key(["C-c", "escape", "q"], (ch, key) => {
     return process.exit(0);
   });

   screen.key(["r", "R"], (ch, key) => {
     robotTable.focus();
   });
   screen.key(["d", "D"], (ch, key) => {
     deviceTable.focus();
   });
   screen.key(["g", "G"], (ch, key) => {
     groupTable.focus();
   });
   screen.key(["y", "Y"], (ch, key) => {
     RefreshData(authTokens).then( (data) => {
       DrawUi(data);
       Logger.Log.Info("refreshed data...");
     });
   });

   deviceTable.rows.on("select", (data, index) => {
       const device : Devices.Device = devicesLookup[index];
       Logger.Log.Info(`selected device with id ${device.Id}`);
       Devices.toggleDeviceState(authTokens, device); /*.then((result) => {
            setTimeout(
                () => {
                    RefreshData(authTokens).then((data) => {
                        DrawUi(data);
                        Logger.Log.Info("refreshed data...");
                    });
                }, 3000);         
       });*/
   });
   
   groupTable.rows.on("select", (data, index) => {
       const group : Groups.Group = groupsLookup[index];
       Logger.Log.Info(`selected group with id ${group.Id}`);
       Groups.toggleGroupState(authTokens, group);
   });
   
   robotTable.rows.on("select", (data, index) => {
       const robot : Robots.Robot = robotsLookup[index];
       Logger.Log.Info(`selected robot with id ${robot.Id}`);
       Robots.toggleRobotState(authTokens, robot);
   });

   const DrawUi = (data) => {
        const deviceData = [];
        data[0].forEach((device) => {
            deviceData.push(device.ToDisplayArray());
        });
//.........这里部分代码省略.........
开发者ID:landonbass,项目名称:winky,代码行数:101,代码来源:ui.ts

示例2:

import * as blessed from "blessed";
import { readFileSync } from "fs";
import { inspect } from "util";

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"
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:31,代码来源:blessed-tests.ts

示例3: 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

示例4:

/**
 * Wechaty Twins Bot + Blessed Contrib Demo
 * Credit: https://github.com/yaronn/blessed-contrib/blob/06a05f107a3b54c91b5200a041ad8c15e6489de9/examples/dashboard.js
 */
import * as blessed from 'blessed'
import * as contrib from 'blessed-contrib'

import { generate } from 'qrcode-terminal'

import {
  Wechaty,
}               from '../../src/'

const screen = blessed.screen({
  smartCSR:     true,
  fullUnicode:  true,  // https://github.com/chjj/blessed/issues/226#issuecomment-188777457
})

// create layout and widgets

const grid = new contrib.grid({rows: 12, cols: 12, screen: screen})

/**
 * Donut Options
 *   self.options.radius = options.radius || 14; // how wide is it? over 5 is best
 *   self.options.arcWidth = options.arcWidth || 4; //width of the donut
 *   self.options.yPadding = options.yPadding || 2; //padding from the top
 */
const donut = grid.set(8, 8, 4, 2, contrib.donut,
  {
  label: 'Percent Donut',
开发者ID:miggame,项目名称:wechaty,代码行数:31,代码来源:index.ts

示例5: require

var winston = require('winston');
var g_logger = new (winston.Logger)({ exitOnError: false })
g_logger.handleExceptions(new winston.transports.File({ filename: '/tmp/tpcc_exceptions.log' }))    /* XXX This doesn't seem to do anything when an exception occurs! */
g_logger.add(winston.transports.File, { filename: uvp_log_file });

g_logger.log('info', 'Beginning TPC-C run.');

/* Create a screen */
/*
 * XXX: For some inexplicable reason, if this variable is named 'screen', it
 * causes `tsc` to emit an error, and no amount of diagnosis resolved the error.
 *
 * TODO: Create a definition file for blessed and contribute it to
 * DefinitelyTyped repo.
 */
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'
  },
开发者ID:llcoolchak,项目名称:DBYardstick,代码行数:31,代码来源:tpcc.ts


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