How to use the blessed.program function in blessed

To help you get started, we’ve selected a few blessed examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github radareorg / radare2-extras / blessr2 / index.js View on Github external
#!/usr/bin/env node

/*
 * ----------------
 * Blessr2 frontend
 * ----------------
 * author: pancake@nopcode.org 
 * date: 2015-12-25
 */
'use strict';

const r2pipe = require('r2pipe');
const process = require('process');
const blessed = require('blessed');
const contrib = require('blessed-contrib');
const program = blessed.program();

/* global vars (must die at some point) */
var regs = undefined;
var offsetStack = [];

//const target = 'http://cloud.radare.org/cmd/';

function parseOptions() {
    var config = {};
    const argv = require('optimist').argv;
    if (argv.h) {
        console.log(`Usage:

  blessr2 [-HtnwdD] [file|url]

Examples:
github aviaryan / chattt / tui.js View on Github external
const io = require('socket.io-client');
const blessed = require('blessed');

let program = blessed.program();
let screen = require('./ui/screen');
let box = require('./ui/box.js');
let input = require('./ui/input');

/** Server URL **/
// const URL = 'https://chattt.glitch.me';
const URL = 'http://localhost:3000';

const socket = io(URL);
let channel, user;


// Append our box to the screen.
screen.append(box.box);
screen.append(input.input);
box.screen = screen;
github MrRio / vtop / app.js View on Github external
const App = ((() => {
  // Load in required libs
  const Canvas = require('drawille')
  const blessed = require('blessed')
  const os = require('os')
  const cli = require('commander')
  const upgrade = require('./upgrade.js')
  const VERSION = require('./package.json').version
  const childProcess = require('child_process')
  const glob = require('glob')
  const path = require('path')
  let themes = ''
  let program = blessed.program()

  const files = glob.sync(path.join(__dirname, 'themes', '*.json'))
  for (var i = 0; i < files.length; i++) {
    let themeName = files[i].replace(path.join(__dirname, 'themes') + path.sep, '').replace('.json', '')
    themes += `${themeName}|`
  }
  themes = themes.slice(0, -1)

  // Set up the commander instance and add the required options
  cli
    .option('-t, --theme  [name]', `set the vtop theme [${themes}]`, 'parallax')
    .option('--no-mouse', 'Disables mouse interactivity')
    .option('--quit-after [seconds]', 'Quits vtop after interval', '0')
    .option('--update-interval [milliseconds]', 'Interval between updates', '300')
    .version(VERSION)
    .parse(process.argv)
github dctucker / octoterm / gh.js View on Github external
#!/usr/bin/env node
'use strict';

const blessed = require('blessed')
const Agenda = require('./Agenda')
const AgendaView = require('./AgendaView')
const Bar = require('./Bar')

// main
var program = blessed.program()
var screen = blessed.screen({
	program: program,
	fullUnicode: true,
	smartCSR: true,
});
screen.key(['C-c'], (ch, key) => {
	return screen.destroy()
})

var model = new Agenda
var view = new AgendaView(screen, model)
var bar = Bar({view, screen})

screen.append(bar)
screen.append(view.list)
screen.append(view.cmdline)
github MrRio / vtop / app.js View on Github external
charts[2].plugin.sort = 'mem'
          charts[2].plugin.poll()
          setTimeout(() => {
            processListSelection.select(0)
          }, 200)
        }
        lastKey = key.name

        if (key.name === 'u' && upgrading === false) {
          upgrading = true
          // Clear all intervals
          for (const interval in intervals) {
            clearInterval(intervals[interval])
          }
          processListSelection.detach()
          program = blessed.program()
          program.clear()
          program.disableMouse()
          program.showCursor()
          program.normalBuffer()

          // @todo: show changelog  AND  smush existing data into it :D
          upgrade.install('vtop', [
            {
              'theme': theme
            }
          ])
        }

        if ((key.name === 'left' || key.name === 'h') && graphScale < 8) {
          graphScale *= 2
        } else if ((key.name === 'right' || key.name === 'l') && graphScale > 0.125) {
github aviaryan / chattt / index.js View on Github external
#!/usr/bin/env node

const io = require('socket.io-client');
const colors = require('./lib/solarized');
const blessed = require('blessed');

let program = blessed.program();
let screen = require('./ui/screen');
let box = require('./ui/box.js');
let input = require('./ui/input');
let list = require('./ui/userlist');

/** Server URL **/
// const URL = 'https://chattt.glitch.me';
const URL = 'http://localhost:3000';

// server connection
const socket = io(URL);
let channel, user;

// Append elements to the screen.
screen.append(box.box);
screen.append(input.input);
github mscdex / ssh2 / examples / server-chat.js View on Github external
}).once('shell', function(accept, reject) {
        stream = accept();
        users.push(stream);

        stream.name = name;
        stream.rows = rows || 24;
        stream.columns = cols || 80;
        stream.isTTY = true;
        stream.setRawMode = noop;
        stream.on('error', noop);

        var screen = new blessed.screen({
          autoPadding: true,
          smartCSR: true,
          program: new blessed.program({
            input: stream,
            output: stream
          }),
          terminal: term || 'ansi'
        });

        screen.title = 'SSH Chatting as ' + name;
        // Disable local echo
        screen.program.attr('invisible', true);

        var output = stream.output = new blessed.log({
          screen: screen,
          top: 0,
          left: 0,
          width: '100%',
          bottom: 2,
github yaronn / blessed-contrib / lib / server-utils.js View on Github external
function createScreen(req, res) {
  var query = url.parse(req.url, true).query;

  var cols = query.cols || 250;
  var rows = query.rows || 50;

  if (cols<=35 || cols>=500 || rows<=5 || rows>=300) {
    serverError(req, res, 'cols must be bigger than 35 and rows must be bigger than 5');
    return null;
  }

  res.writeHead(200, {'Content-Type': 'text/plain'});

  var output = new contrib.OutputBuffer({res: res, cols: cols, rows: rows});
  var input = new contrib.InputBuffer(); //required to run under forever since it replaces stdin to non-tty
  var program = blessed.program({output: output, input: input});

  if (query.terminal) program.terminal = query.terminal;
  if (query.isOSX) program.isOSXTerm = query.isOSX;
  if (query.isiTerm2) program.isiTerm2 = query.isiTerm2;

  var screen = blessed.screen({program: program});
  return screen;
}
github heapwolf / lev / lib / ui / connections.js View on Github external
var blessed = require('blessed')
var Output = require('./output')
var keylist = require('./keylist')
var commands = require('./commands')
var utils = require('../utils')
var fs = require('fs')
var path = require('path')
var program = blessed.program()
var list

function Connections(screen, config, client) {

  var connections = Connections.connections
  var sidePanelWidth = 25

  if (connections) {
    connections.detach()
    screen.append(connections)
    return connections
  }

  connections = Connections.connections = blessed.box({
    parent: screen,
    mouse: true,
github heapwolf / lev / lib / ui / editor.js View on Github external
function Editor(screen, parent, save) {

  if (!(this instanceof Editor)) {
    return new Editor(screen, parent, save)
  }

  this.screen = screen
  this.parent = parent
  this.save = save
  this.parent.keys = false
  this.program = blessed.program()

  this.parent.on('focus', this.focus.bind(this))
  this.parent.on('blur', this.blur.bind(this))

  this.parent.key('up', this.up.bind(this))
  this.parent.key('down', this.down.bind(this))
  this.parent.key('right', this.right.bind(this))
  this.parent.key('left', this.left.bind(this))

  parent.key('enter', this.enter.bind(this))
  parent.key('backspace', this.backspace.bind(this))
  parent.on('keypress', this.insert.bind(this))
}