<commit_before>Scribe = require('../scribe')


_applyDelta = (delta) ->
  _.defer( =>
    delta.apply((index, text, formatting) =>
      this.shiftCursors(index, text.length, formatting['author'])
    , (index, length) =>
      this.shiftCursors(index, -1 * length)
    , (index, length, name, value) =>
      this.shiftCursors(index, 0)
    )
  )

_buildCursor = (userId, name, color) ->
  cursor = @container.ownerDocument.createElement('span')
  cursor.classList.add('cursor')
  cursor.classList.add(Scribe.DOM.EXTERNAL_CLASS)
  cursor.id = Scribe.Editor.CURSOR_PREFIX + userId
  inner = @container.ownerDocument.createElement('span')
  inner.classList.add('cursor-inner')
  nameNode = @container.ownerDocument.createElement('span')
  nameNode.classList.add('cursor-name')
  nameNode.textContent = name
  inner.style.backgroundColor = nameNode.style.backgroundColor = color
  cursor.appendChild(nameNode)
  cursor.appendChild(inner)
  return cursor

_moveCursor = (cursor, referenceNode) ->
  cursor.elem.style.top = referenceNode.offsetTop
  cursor.elem.style.left = referenceNode.offsetLeft
  cursor.elem.querySelector('.cursor-inner').style.height = referenceNode.offsetHeight
  if parseInt(cursor.elem.style.top) <= 5
    cursor.elem.classList.add('top')
  else
    cursor.elem.classList.remove('top')

_setCursor = (userId, index, name, color) ->
  unless @cursors[userId]?
    @cursors[userId] = { name: name, color: color, userId: userId }
    @cursors[userId].elem = _buildCursor.call(this, userId, name, color)
    @container.appendChild(@cursors[userId].elem)
  @cursors[userId].index = index
  @editor.doSilently( =>
    position = new Scribe.Position(@editor, index)
    span = @container.ownerDocument.createElement('span')
    span.textContent = Scribe.DOM.NOBREAK_SPACE
    if !position.leafNode.firstChild?<commit_msg>fix style bug<commit_after>Scribe = require('../scribe')


_applyDelta = (delta) ->
  _.defer( =>
    delta.apply((index, text, formatting) =>
      this.shiftCursors(index, text.length, formatting['author'])
    , (index, length) =>
      this.shiftCursors(index, -1 * length)
    , (index, length, name, value) =>
      this.shiftCursors(index, 0)
    )
  )

_buildCursor = (userId, name, color) ->
  cursor = @container.ownerDocument.createElement('span')
  cursor.classList.add('cursor')
  cursor.classList.add(Scribe.DOM.EXTERNAL_CLASS)
  cursor.id = Scribe.Editor.CURSOR_PREFIX + userId
  inner = @container.ownerDocument.createElement('span')
  inner.classList.add('cursor-inner')
  nameNode = @container.ownerDocument.createElement('span')
  nameNode.classList.add('cursor-name')
  nameNode.textContent = name
  inner.style.backgroundColor = nameNode.style.backgroundColor = color
  cursor.appendChild(nameNode)
  cursor.appendChild(inner)
  return cursor

_moveCursor = (cursor, referenceNode) ->
  cursor.elem.style.top = referenceNode.offsetTop
  cursor.elem.style.left = referenceNode.offsetLeft
  cursorInner = cursor.elem.querySelector('.cursor-inner')
  cursorName = cursor.elem.querySelector('.cursor-name')
  cursorInner.style.height = cursorName.style.top = referenceNode.offsetHeight
  if parseInt(cursor.elem.style.top) <= 5
    cursor.elem.classList.add('top')
  else
    cursor.elem.classList.remove('top')

_setCursor = (userId, index, name, color) ->
  unless @cursors[userId]?
    @cursors[userId] = { name: name, color: color, userId: userId }
    @cursors[userId].elem = _buildCursor.call(this, userId, name, color)
    @container.appendChild(@cursors[userId].elem)
  @cursors[userId].index = index
  @editor.doSilently( =>
    position = new Scribe.Position(@editor, index)
    span = @container.ownerDocument.createElement('span')
    span.textContent = Scribe.DOM.NOBREAK_SPACE
    if !position.leafNode.firstChild?
{'fraction_non_alphanumeric': 0.1425171866737176, 'fraction_numerical': 0.0015864621893178213, 'mean_word_length': 4.474674384949349, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1328665', 'n_tokens_mistral': 1179, 'n_tokens_neox': 1199, 'n_words': 198}