From 8d11075b891ca2dd7aaeb2777a4e6e632d3875e8 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 5 May 2015 23:20:28 -0700 Subject: [PATCH] improve lib/blessed.js --- lib/widget.js | 70 +++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/lib/widget.js b/lib/widget.js index 743f397..a43c797 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -4,33 +4,43 @@ * https://github.com/chjj/blessed */ -exports.Node = exports.node = require('./widgets/node'); -exports.Screen = exports.screen = require('./widgets/screen'); -exports.Element = exports.element = require('./widgets/element'); -exports.Box = exports.box = require('./widgets/box'); -exports.Text = exports.text = require('./widgets/text'); -exports.Line = exports.line = require('./widgets/line'); -exports.ScrollableBox = exports.scrollablebox = require('./widgets/scrollablebox'); -exports.ScrollableText = exports.scrollabletext = require('./widgets/scrollabletext'); -exports.List = exports.list = require('./widgets/list'); -exports.Form = exports.form = require('./widgets/form'); -exports.Input = exports.input = require('./widgets/input'); -exports.Textarea = exports.textarea = require('./widgets/textarea'); -exports.Textbox = exports.textbox = require('./widgets/textbox'); -exports.Button = exports.button = require('./widgets/button'); -exports.ProgressBar = exports.progressbar = require('./widgets/progressbar'); -exports.FileManager = exports.filemanager = require('./widgets/filemanager'); -exports.Checkbox = exports.checkbox = require('./widgets/checkbox'); -exports.RadioSet = exports.radioset = require('./widgets/radioset'); -exports.RadioButton = exports.radiobutton = require('./widgets/radiobutton'); -exports.Prompt = exports.prompt = require('./widgets/prompt'); -exports.Question = exports.question = require('./widgets/question'); -exports.Message = exports.message = require('./widgets/message'); -exports.Loading = exports.loading = require('./widgets/loading'); -exports.Listbar = exports.listbar = require('./widgets/listbar'); -exports.Log = exports.log = require('./widgets/log'); -exports.Table = exports.table = require('./widgets/table'); -exports.ListTable = exports.listtable = require('./widgets/listtable'); -exports.Terminal = exports.terminal = require('./widgets/terminal'); -exports.Image = exports.image = require('./widgets/image'); -exports.helpers = require('./helpers'); +var widget = exports; + +widget.classes = [ + 'Node', + 'Screen', + 'Element', + 'Box', + 'Text', + 'Line', + 'ScrollableBox', + 'ScrollableText', + 'List', + 'Form', + 'Input', + 'Textarea', + 'Textbox', + 'Button', + 'ProgressBar', + 'FileManager', + 'Checkbox', + 'RadioSet', + 'RadioButton', + 'Prompt', + 'Question', + 'Message', + 'Loading', + 'Listbar', + 'Log', + 'Table', + 'ListTable', + 'Terminal', + 'Image' +]; + +widget.classes.forEach(function(name) { + var file = name.toLowerCase(); + widget[name] = widget[file] = require('./widgets/' + file); +}); + +widget.helpers = require('./helpers');