Skip to content

Instantly share code, notes, and snippets.

@mbroadst
Created December 2, 2015 22:32
Show Gist options
  • Save mbroadst/ba09bf5089e11a99ffb2 to your computer and use it in GitHub Desktop.
Save mbroadst/ba09bf5089e11a99ffb2 to your computer and use it in GitHub Desktop.
idea/desire for box layouts
var blessed = require('blessed');
var form = blessed.form({ width: 200, height: 200 });
var formLayout = blessed.boxlayout({ direction: 'vertical' });
formLayout.append(blessed.label({ content: 'Name:' }));
formLayout.append(blessed.textbox({ name: 'name' }));
formLayout.append(blessed.label({ content: 'Birthday:' }));
formLayout.append(blessed.textbox({ name: 'birthday' }));
formLayout.append(blessed.line({ direction: 'horizontal' }));
var buttonLayout = blessed.boxLayout({ direction: 'horizontal' });
buttonLayout.addStretch();
buttonLayout.append(blessed.button({ name: 'cancel', /* ... */ }));
buttonLayout.append(blessed.button({ name: 'submit', /* ... */ }));
formLayout.appendLayout(buttonLayout);
/*
This would generate a form that looked sort of like this:
|-------------------------------|
| Name: |
| [ ] |
| |
| Birthday: |
| [ ] |
| _____________________________ |
| |
| [cancel] [submit] |
|-------------------------------|
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment