mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
handle resize between app and tutorial
This commit is contained in:
parent
46d193ebfe
commit
e31b56cf24
3 changed files with 12 additions and 9 deletions
|
@ -35,6 +35,7 @@ html
|
|||
$('.try-demo').click(function(event){
|
||||
event.stopPropagation();
|
||||
$('.inspec-tutorial').show()
|
||||
window.dispatchEvent(new Event('resizeTerminal'));
|
||||
$('.quit-inspec-tutorial').click(function(event){
|
||||
event.stopPropagation();
|
||||
$('.inspec-tutorial').hide()
|
||||
|
|
|
@ -55,10 +55,6 @@ export class AppComponent implements OnInit {
|
|||
this.loadCommands();
|
||||
}
|
||||
|
||||
ngAfterViewChecked() {
|
||||
// window.scrollTo( 0, document.body.scrollHeight );
|
||||
}
|
||||
|
||||
// determines all commands that are not part of the tutorial
|
||||
extraCmds() {
|
||||
let extra = this.commands.filter(function(item){
|
||||
|
@ -129,7 +125,6 @@ export class AppComponent implements OnInit {
|
|||
// and if it is respond appropriately ('could not fetch inspec profile in ''), otherwise
|
||||
// respond with 'invalid command' and the command entered
|
||||
if (matchFound === false) {
|
||||
console.log('no match found')
|
||||
if (command.match(/^inspec exec\s*.*/)) {
|
||||
let target = command.match(/^inspec exec\s*(.*)/)
|
||||
response = this.red + "Could not fetch inspec profile in '" + target[1] + "' " + this.black;
|
||||
|
|
|
@ -64,7 +64,7 @@ export class XtermTerminalComponent implements OnInit, OnChanges{
|
|||
|
||||
updateTerminalSize() {
|
||||
// recalculate cols and rows
|
||||
let charwidth = 24;
|
||||
let charwidth = 30;
|
||||
// read size from parent wrapping element
|
||||
let cols = 80
|
||||
let rows = Math.floor(this.terminalContainer.parentElement.clientHeight / charwidth)
|
||||
|
@ -90,9 +90,6 @@ export class XtermTerminalComponent implements OnInit, OnChanges{
|
|||
this.term._initialized = true;
|
||||
this.writePrompt();
|
||||
|
||||
// determine rows for terminal
|
||||
this.updateTerminalSize()
|
||||
|
||||
let self = this
|
||||
// raw data
|
||||
this.term.on('data', function(data){
|
||||
|
@ -110,6 +107,16 @@ export class XtermTerminalComponent implements OnInit, OnChanges{
|
|||
}, function(err) {
|
||||
console.error(err)
|
||||
})
|
||||
|
||||
// determine rows for terminal
|
||||
this.updateTerminalSize()
|
||||
|
||||
// TODO: hack, find a better way
|
||||
// this allows outside tiggers via
|
||||
// window.dispatchEvent(new Event('resizeTerminal'));
|
||||
window.addEventListener('resizeTerminal', function (e) {
|
||||
self.updateTerminalSize();
|
||||
}, false);
|
||||
}
|
||||
|
||||
// this writes the raw buffer and includes invisible charaters
|
||||
|
|
Loading…
Reference in a new issue