mirror of
https://github.com/inspec/inspec
synced 2024-11-27 07:00:39 +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){
|
$('.try-demo').click(function(event){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
$('.inspec-tutorial').show()
|
$('.inspec-tutorial').show()
|
||||||
|
window.dispatchEvent(new Event('resizeTerminal'));
|
||||||
$('.quit-inspec-tutorial').click(function(event){
|
$('.quit-inspec-tutorial').click(function(event){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
$('.inspec-tutorial').hide()
|
$('.inspec-tutorial').hide()
|
||||||
|
|
|
@ -55,10 +55,6 @@ export class AppComponent implements OnInit {
|
||||||
this.loadCommands();
|
this.loadCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewChecked() {
|
|
||||||
// window.scrollTo( 0, document.body.scrollHeight );
|
|
||||||
}
|
|
||||||
|
|
||||||
// determines all commands that are not part of the tutorial
|
// determines all commands that are not part of the tutorial
|
||||||
extraCmds() {
|
extraCmds() {
|
||||||
let extra = this.commands.filter(function(item){
|
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
|
// and if it is respond appropriately ('could not fetch inspec profile in ''), otherwise
|
||||||
// respond with 'invalid command' and the command entered
|
// respond with 'invalid command' and the command entered
|
||||||
if (matchFound === false) {
|
if (matchFound === false) {
|
||||||
console.log('no match found')
|
|
||||||
if (command.match(/^inspec exec\s*.*/)) {
|
if (command.match(/^inspec exec\s*.*/)) {
|
||||||
let target = 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;
|
response = this.red + "Could not fetch inspec profile in '" + target[1] + "' " + this.black;
|
||||||
|
|
|
@ -64,7 +64,7 @@ export class XtermTerminalComponent implements OnInit, OnChanges{
|
||||||
|
|
||||||
updateTerminalSize() {
|
updateTerminalSize() {
|
||||||
// recalculate cols and rows
|
// recalculate cols and rows
|
||||||
let charwidth = 24;
|
let charwidth = 30;
|
||||||
// read size from parent wrapping element
|
// read size from parent wrapping element
|
||||||
let cols = 80
|
let cols = 80
|
||||||
let rows = Math.floor(this.terminalContainer.parentElement.clientHeight / charwidth)
|
let rows = Math.floor(this.terminalContainer.parentElement.clientHeight / charwidth)
|
||||||
|
@ -90,9 +90,6 @@ export class XtermTerminalComponent implements OnInit, OnChanges{
|
||||||
this.term._initialized = true;
|
this.term._initialized = true;
|
||||||
this.writePrompt();
|
this.writePrompt();
|
||||||
|
|
||||||
// determine rows for terminal
|
|
||||||
this.updateTerminalSize()
|
|
||||||
|
|
||||||
let self = this
|
let self = this
|
||||||
// raw data
|
// raw data
|
||||||
this.term.on('data', function(data){
|
this.term.on('data', function(data){
|
||||||
|
@ -110,6 +107,16 @@ export class XtermTerminalComponent implements OnInit, OnChanges{
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
console.error(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
|
// this writes the raw buffer and includes invisible charaters
|
||||||
|
|
Loading…
Reference in a new issue