Last active
March 5, 2019 21:18
-
-
Save mamachanko/eb42d9fb389277a3a67389f8e908ad18 to your computer and use it in GitHub Desktop.
Node, typescript, blessed "Hello World" - `npx ts-node hello-world.ts`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {screen, box} from 'blessed'; | |
// Create a screen object. | |
var screen2 = screen({ | |
smartCSR: true | |
}); | |
screen2.title = 'my window title'; | |
// Create a box perfectly centered horizontally and vertically. | |
var box2 = box({ | |
top: 'center', | |
left: 'center', | |
width: '50%', | |
height: '50%', | |
content: 'Hello {bold}terminal{/bold}!', | |
tags: true, | |
border: { | |
type: 'line' | |
}, | |
style: { | |
fg: 'white', | |
bg: 'magenta', | |
border: { | |
fg: '#f0f0f0' | |
}, | |
hover: { | |
bg: 'green' | |
} | |
} | |
}); | |
// Append our box to the screen. | |
screen2.append(box2); | |
// Add a png icon to the box | |
// var icon = blessed.image({ | |
// parent: box, | |
// top: 0, | |
// left: 0, | |
// type: 'overlay', | |
// width: 'shrink', | |
// height: 'shrink', | |
// file: __dirname + '/my-program-icon.png', | |
// search: false | |
// }); | |
// If our box is clicked, change the content. | |
box2.on('click', function(data) { | |
box2.setContent('{center}Some different {red-fg}content{/red-fg}.{/center}'); | |
screen2.render(); | |
}); | |
// If box is focused, handle `enter`/`return` and give us some more content. | |
box2.key('enter', function(ch, key) { | |
box2.setContent('{right}Even different {black-fg}content{/black-fg}.{/right}\n'); | |
box2.setLine(1, 'bar'); | |
box2.insertLine(1, 'foo'); | |
screen2.render(); | |
}); | |
// Quit on Escape, q, or Control-C. | |
screen2.key(['escape', 'q', 'C-c'], function(ch, key) { | |
return process.exit(0); | |
}); | |
// Focus our element. | |
box2.focus(); | |
// Render the screen. | |
screen2.render(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"ts-node": "^8.0.2", | |
"typescript": "^3.3.3333", | |
"@types/blessed": "^0.1.10", | |
"@types/node": "^11.10.4", | |
"blessed": "^0.1.81" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | |
# yarn lockfile v1 | |
"@types/blessed@^0.1.10": | |
version "0.1.10" | |
resolved "https://registry.yarnpkg.com/@types/blessed/-/blessed-0.1.10.tgz#9d60bdb49ef54ad91a80a1a15477759fd787a6d0" | |
integrity sha512-lCpkGnCq2lj9RBPwh/RH/ZJegYV6JdyyRHmURIW1DwMdtNhRRxYeHllqaMu8K6bDf6zhO7PpHsmEqlYMDPlmhw== | |
dependencies: | |
"@types/events" "*" | |
"@types/node" "*" | |
"@types/events@*": | |
version "3.0.0" | |
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7" | |
integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g== | |
"@types/node@*", "@types/node@^11.10.4": | |
version "11.10.4" | |
resolved "https://registry.yarnpkg.com/@types/node/-/node-11.10.4.tgz#3f5fc4f0f322805f009e00ab35a2ff3d6b778e42" | |
integrity sha512-wa09itaLE8L705aXd8F80jnFpxz3Y1/KRHfKsYL2bPc0XF+wEWu8sR9n5bmeu8Ba1N9z2GRNzm/YdHcghLkLKg== | |
arg@^4.1.0: | |
version "4.1.0" | |
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.0.tgz#583c518199419e0037abb74062c37f8519e575f0" | |
integrity sha512-ZWc51jO3qegGkVh8Hwpv636EkbesNV5ZNQPCtRa+0qytRYPEs9IYT9qITY9buezqUH5uqyzlWLcufrzU2rffdg== | |
blessed@^0.1.81: | |
version "0.1.81" | |
resolved "https://registry.yarnpkg.com/blessed/-/blessed-0.1.81.tgz#f962d687ec2c369570ae71af843256e6d0ca1129" | |
integrity sha1-+WLWh+wsNpVwrnGvhDJW5tDKESk= | |
buffer-from@^1.0.0: | |
version "1.1.1" | |
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" | |
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== | |
diff@^3.1.0: | |
version "3.5.0" | |
resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" | |
integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== | |
make-error@^1.1.1: | |
version "1.3.5" | |
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8" | |
integrity sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g== | |
source-map-support@^0.5.6: | |
version "0.5.10" | |
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.10.tgz#2214080bc9d51832511ee2bab96e3c2f9353120c" | |
integrity sha512-YfQ3tQFTK/yzlGJuX8pTwa4tifQj4QS2Mj7UegOu8jAz59MqIiMGPXxQhVQiIMNzayuUSF/jEuVnfFF5JqybmQ== | |
dependencies: | |
buffer-from "^1.0.0" | |
source-map "^0.6.0" | |
source-map@^0.6.0: | |
version "0.6.1" | |
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" | |
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== | |
ts-node@^8.0.2: | |
version "8.0.2" | |
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.0.2.tgz#9ecdf8d782a0ca4c80d1d641cbb236af4ac1b756" | |
integrity sha512-MosTrinKmaAcWgO8tqMjMJB22h+sp3Rd1i4fdoWY4mhBDekOwIAKI/bzmRi7IcbCmjquccYg2gcF6NBkLgr0Tw== | |
dependencies: | |
arg "^4.1.0" | |
diff "^3.1.0" | |
make-error "^1.1.1" | |
source-map-support "^0.5.6" | |
yn "^3.0.0" | |
typescript@^3.3.3333: | |
version "3.3.3333" | |
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.3.3333.tgz#171b2c5af66c59e9431199117a3bcadc66fdcfd6" | |
integrity sha512-JjSKsAfuHBE/fB2oZ8NxtRTk5iGcg6hkYXMnZ3Wc+b2RSqejEqTaem11mHASMnFilHrax3sLK0GDzcJrekZYLw== | |
yn@^3.0.0: | |
version "3.0.0" | |
resolved "https://registry.yarnpkg.com/yn/-/yn-3.0.0.tgz#0073c6b56e92aed652fbdfd62431f2d6b9a7a091" | |
integrity sha512-+Wo/p5VRfxUgBUGy2j/6KX2mj9AYJWOHuhMjMcbBFc3y54o9/4buK1ksBvuiK01C3kby8DH9lSmJdSxw+4G/2Q== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment