Files
butterfly/coffees/ext/pack.coffee
Florian Mounier 3624962d3c Historize by ext
2016-10-13 16:11:44 +02:00

24 lines
590 B
CoffeeScript

tid = null
packSize = 1000
histSize = 100
maybePack = ->
return unless butterfly.term.childElementCount > packSize + butterfly.rows
hist = document.getElementById 'packed'
packfrag = document.createDocumentFragment 'fragment'
for i in [0..packSize]
packfrag.appendChild butterfly.term.firstChild
pack = document.createElement 'div'
pack.classList.add 'pack'
pack.appendChild packfrag
hist.appendChild pack
hist.firstChild.remove() if hist.childElementCount > histSize
tid = setTimeout maybePack
Terminal.on 'refresh', ->
clearTimeout tid if tid
maybePack()