launcher: limit terminal history size to prevent slowdown/freeze

This commit is contained in:
bordun 2019-11-24 17:59:25 +01:00
parent a016af9025
commit 4a4d312f52
2 changed files with 20 additions and 1 deletions

View file

@ -1,5 +1,10 @@
# Changelog
## 0.48.4
- bug fixes
- launcher: limit terminal history size to prevent slowdown/freeze
## 0.48.3
- bug fixes

View file

@ -9,7 +9,8 @@ var {remote, ipcRenderer, shell} = eval('require(\'electron\')'),
argv_remote = settings.read('argv'),
ansiHTML = require('ansi-html'),
argv = {},
$ = require('jquery/dist/jquery.slim.min.js')
$ = require('jquery/dist/jquery.slim.min.js'),
TERMINAL_LENGTH = 400
for (i in argv_remote) {
argv[i] = argv_remote[i]
@ -216,6 +217,7 @@ $(document).ready(()=>{
var terminal = $('<div class="terminal"></div>').appendTo(form).hide(),
autoscroll = true
ipcRenderer.on('stdout', function(e, msg){
terminal.append(`<div class="log">${ansiHTML(msg)}</div>`)
if (autoscroll) scrollBottom()
@ -227,6 +229,18 @@ $(document).ready(()=>{
})
function purgeTerminal(){
var len = terminal.children().length
if (len > TERMINAL_LENGTH) {
var children = terminal.children()
for (var i = 0; i < len - TERMINAL_LENGTH; i++){
children[i].remove()
}
}
}
setInterval(purgeTerminal, 2000)
// context-menu
menu.append(new MenuItem({role: 'copy'}))