mirror of
https://github.com/paradoxxxzero/butterfly.git
synced 2025-01-03 08:58:32 +00:00
30 lines
766 B
CoffeeScript
30 lines
766 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()
|
|
|
|
Terminal.on 'clear', ->
|
|
newHist = document.createElement 'div'
|
|
newHist.id = 'packed'
|
|
hist = document.getElementById 'packed'
|
|
butterfly.body.replaceChild newHist, hist
|