<commit_before>_ = require 'underscore-plus'

module.exports =
class KillRing
  buffer:[]
  sealed: true
  limit: 16

  constructor: (limit=16)->
    @limit = limit

  put: (texts, forward=true) ->
    if @sealed
      @push texts
    else
      @update texts,forward

  seal: ->
    @sealed = true

  push: (texts) ->
    @buffer.push texts
    if @buffer.length > @limit then @buffer.shift()
    console.log _.last @buffer
    @sealed = false

  update: (texts,forward) ->
    concat = (t) -> if forward then t[0] + (t[1] or '') else (t[1] or '') + t[0]
    new_texts = ((concat t) for t in _.zip (_.last @buffer),texts)
    @buffer.pop
    @push new_texts

  top: ->
    _.last @buffer

  list: ->
    @buffer<commit_msg>Added clipboard sync to kill-ring class<commit_after>_ = require 'underscore-plus'

module.exports =
class KillRing
  buffer:[]
  sealed: true
  limit: 16

  constructor: (limit=16)->
    @limit = limit

  put: (texts, forward=true) ->
    if @sealed
      @push texts
    else
      @update texts,forward

  seal: ->
    @sealed = true

  push: (texts) ->
    @buffer.push texts
    atom.clipboard.write texts.join '\n'
    console.log atom.clipboard.read()
    if @buffer.length > @limit then @buffer.shift()
    console.log _.last @buffer
    @sealed = false

  update: (texts,forward) ->
    concat = (t) -> if forward then t[0] + (t[1] or '') else (t[1] or '') + t[0]
    new_texts = ((concat t) for t in _.zip (_.last @buffer),texts)
    @buffer.pop()
    @push new_texts

  top: ->
    _.last @list()

  list: ->
    last = _.last @buffer
    last ?= [""]
    if atom.clipboard.md5(last.join '\n') != atom.clipboard.signatureForMetadata
      @push [atom.clipboard.read()]
    @buffer
{'fraction_non_alphanumeric': 0.15393586005830903, 'fraction_numerical': 0.009912536443148687, 'mean_word_length': 2.575, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4078947', 'n_tokens_mistral': 630, 'n_tokens_neox': 608, 'n_words': 165}