How to use the text-buffer/lib/point.fromObject function in text-buffer

To help you get started, we’ve selected a few text-buffer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github slap-editor / slap / lib / ui / Editor.js View on Github external
Editor.prototype.visiblePos = function (pos) {
  var self = this;
  if (pos instanceof Range) return new Range(self.visiblePos(pos.start), self.visiblePos(pos.end));
  pos = Point.fromObject(pos, true);
  pos.column = self.lineWithEndingForRow(pos.row)
    .slice(0, Math.max(pos.column, 0))
    .replace(Editor._tabRegExp, _.repeat('\t', self.buffer.options.tabSize).join(''))
    .length;
  return pos;
};
Editor.prototype.realPos = function (pos) {
github slap-editor / slap / lib / ui / Editor.js View on Github external
Editor.prototype.realPos = function (pos) {
  var self = this;
  if (pos instanceof Range) return new Range(self.realPos(pos.start), self.realPos(pos.end));
  pos = self.textBuf.clipPosition(Point.fromObject(pos, true));
  pos.column = this.lineWithEndingForRow(pos.row)
    .replace(Editor._tabRegExp, _.repeat('\t', this.buffer.options.tabSize).join(''))
    .slice(0, Math.max(pos.column, 0))
    .replace(new RegExp('\\t{1,'+this.buffer.options.tabSize+'}', 'g'), '\t')
    .length;
  return pos;
};

text-buffer

A container for large mutable strings with annotated regions

MIT
Latest version published 4 years ago

Package Health Score

45 / 100
Full package analysis

Similar packages