LoginSignup
1
1

More than 5 years have passed since last update.

blessed動かしてみた

Last updated at Posted at 2015-08-08

参考

環境準備

sudo apt-get install -y node npm
npm install blessed

サンプルコード

hello.js
var blessed = require('blessed');
// Create a screen object.
var screen = blessed.screen({
  autoPadding: true,
  smartCSR: true
});
screen.title = '初めてのWindow Title';
// Create a box perfectly centered horizontally and vertically.
var box = blessed.box({
  top: 'center',
  left: 'center',
  width: '50%',
  height: '50%',
  //日本語????になります。残念
  content: 'Hello {bold}world{/bold}!',
  tags: true,
  border: {
    type: 'line'
  },  
  style: {
    fg: 'white',
    bg: 'magenta',
    border: {
      fg: '#f0f0f0'
    },  
    hover: {
      bg: 'green'
    }   
  }
});

// 終了させるキーの設定。Escape, q, or Control-C.
screen.key(['escape', 'q', 'C-c'], function(ch, key) {
  //タイトルが残ってしまうのでクリア
  screen.title = ''; 
  return process.exit(0);
});

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

動かし方

nodejs a.js

upload.png

Escape, q, or Control-Cで終了します。

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1