line.js 935 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * line.js - line element for blessed
  3. * Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
  4. * https://github.com/chjj/blessed
  5. */
  6. /**
  7. * Modules
  8. */
  9. var Node = require('./node');
  10. var Box = require('./box');
  11. /**
  12. * Line
  13. */
  14. function Line(options) {
  15. if (!(this instanceof Node)) {
  16. return new Line(options);
  17. }
  18. options = options || {};
  19. var orientation = options.orientation || 'vertical';
  20. delete options.orientation;
  21. if (orientation === 'vertical') {
  22. options.width = 1;
  23. } else {
  24. options.height = 1;
  25. }
  26. Box.call(this, options);
  27. this.ch = !options.type || options.type === 'line'
  28. ? orientation === 'horizontal' ? '─' : '│'
  29. : options.ch || ' ';
  30. this.border = {
  31. type: 'bg',
  32. __proto__: this
  33. };
  34. this.style.border = this.style;
  35. }
  36. Line.prototype.__proto__ = Box.prototype;
  37. Line.prototype.type = 'line';
  38. /**
  39. * Expose
  40. */
  41. module.exports = Line;