function repeat(string, times) {
for (var i = 0; i < times; i++)
function TextCell(text) {
this.text = text.split("\n");
TextCell.prototype.minWidth = function() {
return this.text.reduce(function(width, line) {
return Math.max(width, line.length);
TextCell.prototype.minHeight = function() {
TextCell.prototype.draw = function(width, height) {
for (var i = 0; i < height; i++) {
var line = this.text[i] || "";
result.push(line + repeat(" ", width - line.length));