Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
var Blessed = require('blessed');
var screen = Blessed.screen({
smartCSR: true,
useBCE: true
var ChatHistory = function (options) {
if (!(this instanceof Blessed.Node)) {
return new ChatHistory(options);
options = options || {};
options.shrink = true;, options);
ChatHistory.prototype = Object.create(Blessed.Element.prototype);
ChatHistory.prototype.type = 'chatHistory';
// Define a instance property called `messages` that will store the message list.
ChatHistory.prototype._messages = [];
* Add a message to the history.
* @param {String} msg
ChatHistory.prototype.addMessage = function (msg) {
var self = this;
// Store the message into the widget list.
ChatHistory.prototype.render = function () {
// Set the widget content.
// Call the super.
return this._render();
// Create a new `ChatHistory` instance.
var chat = ChatHistory({
height: '100%',
padding: 1,
tags: true,
width: '100%'
// Display dummy messages.
chat.addMessage('People assume that time is a strict progression of cause to effect,');
chat.addMessage('but {underline}actually{/underline} from a non-linear, non-subjective viewpoint -');
chat.addMessage('it\'s more like a big ball of wibbly wobbly... time-y wimey... stuff.');
// Append the chat to the screen.
// Render the screen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment