| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -14,33 +14,47 @@ module.exports = function (opts) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  const input = TermInput(conn, screen) | 
					 | 
					 | 
					 | 
					  const input = TermInput(conn, screen) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  const termUpload = TermUpload(conn, input, screen) | 
					 | 
					 | 
					 | 
					  const termUpload = TermUpload(conn, input, screen) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  screen.input = input | 
					 | 
					 | 
					 | 
					  screen.input = input | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  screen.conn = conn | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  input.termUpload = termUpload | 
					 | 
					 | 
					 | 
					  input.termUpload = termUpload | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  // we delay the display of "connecting" to avoid flash when changing tabs with the terminal open
 | 
					 | 
					 | 
					 | 
					  let showSplashTimeout = null | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  let showConnectingTimeout = -1 | 
					 | 
					 | 
					 | 
					  let showSplash = (obj, delay = 250) => { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    clearTimeout(showSplashTimeout) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    showSplashTimeout = setTimeout(() => { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      screen.window.statusScreen = obj | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    }, delay) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  conn.on('open', () => { | 
					 | 
					 | 
					 | 
					  conn.on('open', () => { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    showConnectingTimeout = setTimeout(() => { | 
					 | 
					 | 
					 | 
					    // console.log('*open')
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      screen.window.statusScreen = { title: 'Connecting', loading: true } | 
					 | 
					 | 
					 | 
					    showSplash({ title: 'Connecting', loading: true }) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }, 250) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  }) | 
					 | 
					 | 
					 | 
					  }) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  conn.on('connect', () => { | 
					 | 
					 | 
					 | 
					  conn.on('connect', () => { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    clearTimeout(showConnectingTimeout) | 
					 | 
					 | 
					 | 
					    // console.log('*connect')
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    screen.window.statusScreen = { title: 'Waiting for content', loading: true } | 
					 | 
					 | 
					 | 
					    showSplash({ title: 'Waiting for content', loading: true }) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  }) | 
					 | 
					 | 
					 | 
					  }) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  conn.on('load', () => { | 
					 | 
					 | 
					 | 
					  conn.on('load', () => { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    // console.log('*load')
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    clearTimeout(showSplashTimeout) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if (screen.window.statusScreen) screen.window.statusScreen = null | 
					 | 
					 | 
					 | 
					    if (screen.window.statusScreen) screen.window.statusScreen = null | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  }) | 
					 | 
					 | 
					 | 
					  }) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  conn.on('disconnect', () => { | 
					 | 
					 | 
					 | 
					  conn.on('disconnect', () => { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    clearTimeout(showConnectingTimeout) | 
					 | 
					 | 
					 | 
					    // console.log('*disconnect')
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    screen.window.statusScreen = { title: 'Disconnected' } | 
					 | 
					 | 
					 | 
					    showSplash({ title: 'Disconnected' }) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    screen.screen = [] | 
					 | 
					 | 
					 | 
					    screen.screen = [] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    screen.screenFG = [] | 
					 | 
					 | 
					 | 
					    screen.screenFG = [] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    screen.screenBG = [] | 
					 | 
					 | 
					 | 
					    screen.screenBG = [] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    screen.screenAttrs = [] | 
					 | 
					 | 
					 | 
					    screen.screenAttrs = [] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  }) | 
					 | 
					 | 
					 | 
					  }) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  conn.on('silence', () => { screen.window.statusScreen = { title: 'Waiting for server', loading: true } }) | 
					 | 
					 | 
					 | 
					  conn.on('silence', () => { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    // console.log('*silence')
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    showSplash({ title: 'Waiting for server', loading: true }, 0) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  }) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  // conn.on('ping-fail', () => { screen.window.statusScreen = { title: 'Disconnected' } })
 | 
					 | 
					 | 
					 | 
					  // conn.on('ping-fail', () => { screen.window.statusScreen = { title: 'Disconnected' } })
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  conn.on('ping-success', () => { screen.window.statusScreen = { title: 'Re-connecting', loading: true } }) | 
					 | 
					 | 
					 | 
					  conn.on('ping-success', () => { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    // console.log('*ping-success')
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    showSplash({ title: 'Re-connecting', loading: true }, 0) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  }) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  conn.init() | 
					 | 
					 | 
					 | 
					  conn.init() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  input.init(opts) | 
					 | 
					 | 
					 | 
					  input.init(opts) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |