App-MHFS

 view release on metacpan or  search on metacpan

share/public_html/static/hls.js  view on Meta::CPAN

  StyledUnicodeChar.prototype.copy = function copy(newChar) {
    this.uchar = newChar.uchar;
    this.penState.copy(newChar.penState);
  };

  StyledUnicodeChar.prototype.isEmpty = function isEmpty() {
    return this.uchar === ' ' && this.penState.isDefault();
  };

  return StyledUnicodeChar;
}();

/**
 * CEA-608 row consisting of NR_COLS instances of StyledUnicodeChar.
 * @constructor
 */


var Row = function () {
  function Row() {
    cea_608_parser__classCallCheck(this, Row);

    this.chars = [];
    for (var i = 0; i < NR_COLS; i++) {
      this.chars.push(new StyledUnicodeChar());
    }

    this.pos = 0;
    this.currPenState = new PenState();
  }

  Row.prototype.equals = function equals(other) {
    var equal = true;
    for (var i = 0; i < NR_COLS; i++) {
      if (!this.chars[i].equals(other.chars[i])) {
        equal = false;
        break;
      }
    }
    return equal;
  };

  Row.prototype.copy = function copy(other) {
    for (var i = 0; i < NR_COLS; i++) {
      this.chars[i].copy(other.chars[i]);
    }
  };

  Row.prototype.isEmpty = function isEmpty() {
    var empty = true;
    for (var i = 0; i < NR_COLS; i++) {
      if (!this.chars[i].isEmpty()) {
        empty = false;
        break;
      }
    }
    return empty;
  };

  /**
     *  Set the cursor to a valid column.
     */


  Row.prototype.setCursor = function setCursor(absPos) {
    if (this.pos !== absPos) {
      this.pos = absPos;
    }

    if (this.pos < 0) {
      cea_608_parser_logger.log('ERROR', 'Negative cursor position ' + this.pos);
      this.pos = 0;
    } else if (this.pos > NR_COLS) {
      cea_608_parser_logger.log('ERROR', 'Too large cursor position ' + this.pos);
      this.pos = NR_COLS;
    }
  };

  /**
     * Move the cursor relative to current position.
     */


  Row.prototype.moveCursor = function moveCursor(relPos) {
    var newPos = this.pos + relPos;
    if (relPos > 1) {
      for (var i = this.pos + 1; i < newPos + 1; i++) {
        this.chars[i].setPenState(this.currPenState);
      }
    }
    this.setCursor(newPos);
  };

  /**
     * Backspace, move one step back and clear character.
     */


  Row.prototype.backSpace = function backSpace() {
    this.moveCursor(-1);
    this.chars[this.pos].setChar(' ', this.currPenState);
  };

  Row.prototype.insertChar = function insertChar(byte) {
    if (byte >= 0x90) {
      // Extended char
      this.backSpace();
    }
    var char = getCharForByte(byte);
    if (this.pos >= NR_COLS) {
      cea_608_parser_logger.log('ERROR', 'Cannot insert ' + byte.toString(16) + ' (' + char + ') at position ' + this.pos + '. Skipping it!');
      return;
    }
    this.chars[this.pos].setChar(char, this.currPenState);
    this.moveCursor(1);
  };

  Row.prototype.clearFromPos = function clearFromPos(startPos) {
    var i = void 0;
    for (i = startPos; i < NR_COLS; i++) {
      this.chars[i].reset();
    }
  };

  Row.prototype.clear = function clear() {
    this.clearFromPos(0);
    this.pos = 0;
    this.currPenState.reset();
  };

  Row.prototype.clearToEndOfRow = function clearToEndOfRow() {
    this.clearFromPos(this.pos);
  };

  Row.prototype.getTextString = function getTextString() {
    var chars = [];
    var empty = true;
    for (var i = 0; i < NR_COLS; i++) {
      var char = this.chars[i].uchar;
      if (char !== ' ') {



( run in 2.060 seconds using v1.01-cache-2.11-cpan-140bd7fdf52 )