code: function getCoords(ev) {
      var x, y, w, h, el;
  
      // ignore browsers without pageX for now
      if (ev.pageX == null) return;
  
      x = ev.pageX;
      y = ev.pageY;
      el = self.element;
  
      // should probably check offsetParent
      // but this is more portable
      while (el && el !== self.document.documentElement) {
        x -= el.offsetLeft;
        y -= el.offsetTop;
        el = 'offsetParent' in el
          ? el.offsetParent
          : el.parentNode;
      }
  
      // convert to cols/rows
      w = self.element.clientWidth;
      h = self.element.clientHeight;
      x = Math.round((x / w) * self.cols);
      y = Math.round((y / h) * self.rows);
  
      // be sure to avoid sending
      // bad positions to the program
      if (x < 0) x = 0;
      if (x > self.cols) x = self.cols;
      if (y < 0) y = 0;
      if (y > self.rows) y = self.rows;
  
      // xterm sends raw bytes and
      // starts at 32 (SP) for each.
      x += 32;
      y += 32;
  
      return {
        x: x,
        y: y,
        type: ev.type === wheelEvent
          ? 'mousewheel'
          : ev.type
      };
    }
docs: mouse coordinates measured in cols/rows