2015-05-02 00:52:20 +00:00
|
|
|
var fs = require('fs')
|
|
|
|
, blessed = require('../')
|
|
|
|
, unicode = blessed.unicode;
|
2015-04-14 22:35:16 +00:00
|
|
|
|
2015-05-02 00:52:20 +00:00
|
|
|
var screen = blessed.screen({
|
|
|
|
dump: __dirname + '/logs/unicode.log',
|
2015-04-14 22:35:16 +00:00
|
|
|
smartCSR: true,
|
|
|
|
dockBorders: true,
|
2015-04-16 21:38:36 +00:00
|
|
|
useBCE: true,
|
2015-07-22 02:23:57 +00:00
|
|
|
fullUnicode: ~process.argv.indexOf('-') ? false : true,
|
|
|
|
warnings: true
|
2015-04-14 22:35:16 +00:00
|
|
|
});
|
|
|
|
|
2015-05-02 00:52:20 +00:00
|
|
|
/**
|
|
|
|
* Unicode Characters
|
|
|
|
*/
|
|
|
|
|
2015-04-26 12:36:30 +00:00
|
|
|
// var DU = '杜';
|
2015-04-26 13:54:07 +00:00
|
|
|
var DU = unicode.fromCodePoint(0x675C);
|
|
|
|
|
2015-04-26 12:36:30 +00:00
|
|
|
// var JUAN = '鹃';
|
2015-04-26 13:54:07 +00:00
|
|
|
var JUAN = unicode.fromCodePoint(0x9E43);
|
2015-04-15 17:05:34 +00:00
|
|
|
|
2015-04-18 04:17:11 +00:00
|
|
|
// one flew over the 杜鹃's nest.
|
2015-04-26 12:36:30 +00:00
|
|
|
// var DOUBLE = '杜鹃';
|
|
|
|
var DOUBLE = DU + JUAN;
|
2015-04-18 04:17:11 +00:00
|
|
|
|
2015-04-15 17:05:34 +00:00
|
|
|
// var SURROGATE_DOUBLE = '𰀀';
|
2015-04-26 13:54:07 +00:00
|
|
|
// var SURROGATE_DOUBLE = String.fromCharCode(0xD880, 0xDC00);
|
2015-04-27 18:58:44 +00:00
|
|
|
// var SURROGATE_DOUBLE = unicode.fromCodePoint(0x30000);
|
2015-04-15 17:05:34 +00:00
|
|
|
|
2015-04-27 18:58:44 +00:00
|
|
|
// var SURROGATE_DOUBLE = '𠀀';
|
|
|
|
// var SURROGATE_DOUBLE = String.fromCharCode(0xd840, 0xdc00);
|
|
|
|
var SURROGATE_DOUBLE = unicode.fromCodePoint(0x20000);
|
|
|
|
|
|
|
|
// var SURROGATE_DOUBLE = '🉐';
|
|
|
|
// var SURROGATE_DOUBLE = String.fromCharCode(0xD83C, 0xDE50);
|
|
|
|
// var SURROGATE_DOUBLE = unicode.fromCodePoint(0x1F250);
|
2015-04-26 12:36:30 +00:00
|
|
|
|
2015-04-15 17:05:34 +00:00
|
|
|
// var SURROGATE_SINGLE = '𝌆';
|
2015-04-26 13:54:07 +00:00
|
|
|
// var SURROGATE_SINGLE = String.fromCharCode(0xD834, 0xDF06);
|
|
|
|
var SURROGATE_SINGLE = unicode.fromCodePoint(0x1D306);
|
2015-04-14 22:35:16 +00:00
|
|
|
|
2015-04-26 12:36:30 +00:00
|
|
|
// var COMBINE_NONSURROGATE = 's̀'.substring(1); // s + combining
|
2015-04-26 13:54:07 +00:00
|
|
|
var COMBINE_NONSURROGATE = unicode.fromCodePoint(0x0300);
|
2015-04-16 18:23:53 +00:00
|
|
|
|
2015-04-26 12:36:30 +00:00
|
|
|
// var COMBINE = 's𐨁'.substring(1); // s + combining
|
2015-04-26 13:54:07 +00:00
|
|
|
// var COMBINE = String.fromCharCode(0xD802, 0xDE01);
|
|
|
|
var COMBINE = unicode.fromCodePoint(0x10A01);
|
2015-04-16 18:23:53 +00:00
|
|
|
|
2015-05-02 00:52:20 +00:00
|
|
|
/**
|
|
|
|
* Content
|
|
|
|
*/
|
|
|
|
|
|
|
|
var lorem = fs.readFileSync(__dirname + '/lorem.txt', 'utf8');
|
2015-04-14 22:35:16 +00:00
|
|
|
|
2015-04-15 17:05:34 +00:00
|
|
|
lorem = lorem.replace(/e/gi, DOUBLE);
|
2015-04-18 04:17:11 +00:00
|
|
|
//lorem = lorem.replace(/e/gi, DU);
|
|
|
|
//lorem = lorem.replace(/r/gi, JUAN);
|
2015-04-27 21:49:36 +00:00
|
|
|
lorem = lorem.replace(/a/gi, SURROGATE_DOUBLE);
|
2015-04-15 17:05:34 +00:00
|
|
|
lorem = lorem.replace(/o/gi, SURROGATE_SINGLE);
|
2015-04-16 19:26:31 +00:00
|
|
|
if (~process.argv.indexOf('s')) {
|
|
|
|
lorem = lorem.replace(/s/gi, 's' + COMBINE);
|
2015-05-02 00:52:20 +00:00
|
|
|
} else {
|
|
|
|
lorem = lorem.replace('s', 's' + COMBINE);
|
2015-04-16 19:26:31 +00:00
|
|
|
}
|
2015-04-14 22:35:16 +00:00
|
|
|
|
2015-05-01 23:47:05 +00:00
|
|
|
// Surrogate pair emoticons from the SMP:
|
|
|
|
lorem += '\n';
|
|
|
|
lorem += 'emoticons: ';
|
|
|
|
for (var point = 0x1f600; point <= 0x1f64f; point++) {
|
|
|
|
// These are technically single-width,
|
|
|
|
// but they _look_ like they should be
|
|
|
|
// double-width in gnome-terminal (they overlap).
|
|
|
|
var emoticon = unicode.fromCodePoint(point);
|
|
|
|
lorem += emoticon + ' ';
|
|
|
|
}
|
|
|
|
|
2015-05-02 00:52:20 +00:00
|
|
|
/**
|
|
|
|
* UI
|
|
|
|
*/
|
|
|
|
|
2015-04-14 22:35:16 +00:00
|
|
|
var main = blessed.box({
|
|
|
|
parent: screen,
|
|
|
|
left: 'center',
|
|
|
|
top: 'center',
|
|
|
|
width: '50%',
|
|
|
|
height: '50%',
|
|
|
|
style: {
|
2015-05-02 00:52:20 +00:00
|
|
|
bg: 'grey'
|
2015-04-14 22:35:16 +00:00
|
|
|
},
|
|
|
|
border: 'line',
|
|
|
|
draggable: true,
|
|
|
|
tags: true,
|
2015-04-26 12:51:56 +00:00
|
|
|
// content: '{black-bg}{blue-fg}{bold}' + lorem + '{/}',
|
|
|
|
// XXX {bold} breaks JUAN!
|
|
|
|
content: '{black-bg}{light-blue-fg}' + lorem + '{/}',
|
2015-04-14 22:35:16 +00:00
|
|
|
scrollable: true,
|
|
|
|
alwaysScroll: true,
|
|
|
|
keys: true,
|
|
|
|
vi: true,
|
|
|
|
mouse: true
|
|
|
|
});
|
|
|
|
|
|
|
|
main.focus();
|
|
|
|
|
|
|
|
screen.key('q', function() {
|
|
|
|
return process.exit(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
screen.render();
|