Code coverage report for slap/lib/ui/GoLineForm.js

Statements: 63.64% (21 / 33)      Branches: 50% (6 / 12)      Functions: 40% (2 / 5)      Lines: 75% (21 / 28)      Ignored: none     

All files » slap/lib/ui/ » GoLineForm.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 561 1 1   1 1 1   1   1 1 1   1   1             1                         1   1 1 1 1 1                 1     1  
var blessed = require('blessed');
var _ = require('lazy.js');
var Point = require('text-buffer/lib/point');
 
var Slap = require('./Slap');
var BaseElement = require('./BaseElement');
var BaseFindForm = require('./BaseFindForm');
 
var markup = require('../markup');
 
GoLineForm._label = " line number: ";
function GoLineForm (opts) {
  var self = this;
 
  Iif (!(self instanceof blessed.Node)) return new GoLineForm(opts);
 
  BaseFindForm.call(self, _({
      findField: {left: GoLineForm._label.length}
    })
    .merge(Slap.global.options.form.goLine || {})
    .merge(opts || {})
    .toObject());
 
  self.goLineLabel = new BaseElement(_({
      parent: self,
      tags: true,
      content: GoLineForm._label,
      top: 0,
      height: 1,
      left: 0,
      width: GoLineForm._label.length,
      style: self.options.style
    })
    .merge(self.options.goLineLabel || {})
    .toObject());
}
GoLineForm.prototype.__proto__ = BaseFindForm.prototype;
 
GoLineForm.prototype._initHandlers = function () {
  var self = this;
  self.on('cancel', function () { self.resetEditor(); });
  self.on('show', function () { self.findField.textBuf.setText(''); });
  self.on('find', function (lineNumber, direction) {
    lineNumber = Number(lineNumber) - 1;
    if (lineNumber !== lineNumber) return; // isNaN(lineNumber)
    var selection = self.pane.editor.selection;
    selection.setHeadPosition(new Point(lineNumber, 0));
    selection.clearTail();
    if (direction) self.hide();
    return self;
  });
  return BaseFindForm.prototype._initHandlers.apply(self, arguments);
};
 
module.exports = GoLineForm;