Skip to content

Commit 102ad37

Browse files
committed
fix(terminal): fix terminal output
1 parent 450c672 commit 102ad37

File tree

3 files changed

+64
-48
lines changed

3 files changed

+64
-48
lines changed
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
<div class="window-terminal-container dracula-ansi-theme" [ngClass]="{ large: options.size === 'large' }" slimScroll [options]="scrollOptions" [scrollEvents]="scrollEvents">
1+
<div class="window-terminal-container batman-ansi-theme" [ngClass]="{ large: options.size === 'large' }" slimScroll [options]="scrollOptions" [scrollEvents]="scrollEvents">
22
<div class="terminal" *ngFor="let cmd of commands; let i = index;" [id]="i">
3-
<span class="icon">
4-
<img *ngIf="cmd.visible" src="images/icons/collapse.svg" (click)="toogleCommand(i)">
5-
<img *ngIf="!cmd.visible" src="images/icons/expand.svg" (click)="toogleCommand(i)">
6-
</span>
7-
<span class="command" [innerHTML]="cmd.command"></span>
3+
<div class="command-line" (click)="toogleCommand(i)">
4+
<span class="icon">
5+
<img *ngIf="cmd.visible" src="images/icons/collapse.svg">
6+
<img *ngIf="!cmd.visible" src="images/icons/expand.svg">
7+
</span>
8+
<span class="command" [innerHTML]="cmd.command"></span>
9+
</div>
810
<pre class="output" [class.is-hidden]="!cmd.visible" [innerHTML]="cmd.output"></pre>
911
</div>
1012
</div>

src/app/components/app-terminal/app-terminal.component.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ export class AppTerminalComponent implements OnInit {
1919
this.scrollOptions = {
2020
position: 'right',
2121
barBackground: '#11121A',
22-
barOpacity: '0.8',
22+
barOpacity: '0.2',
2323
barWidth: '10',
24-
barBorderRadius: '10',
24+
barBorderRadius: '0',
2525
barMargin: '2px 2px 2px 0',
2626
gridBackground: '#282a36',
2727
gridOpacity: '1',
2828
gridWidth: '10',
2929
gridBorderRadius: '0',
3030
gridMargin: '2px 2px 2px 0',
31-
alwaysVisible: true
31+
alwaysVisible: false
3232
};
3333

3434
this.scrollEvents = new EventEmitter<SlimScrollEvent>();
@@ -62,8 +62,16 @@ export class AppTerminalComponent implements OnInit {
6262
}
6363

6464
this.commands = commands.reduce((acc, curr, i) => {
65-
const next = commands[i + 1] || '';
66-
const re = new RegExp('(' + curr + ')(' + '[\\s\\S]*' + ')(' + next + ')');
65+
let next = commands[i + 1] || '';
66+
next = next.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
67+
const c = curr.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
68+
let re = new RegExp('(' + c + ')(' + '[\\s\\S]+' + ')(' + next + ')');
69+
if (!output.match(re)) {
70+
re = new RegExp('(' + c + ')' + '[\\s\\S]+');
71+
}
72+
73+
console.log(re);
74+
6775
return acc.concat({
6876
command: curr,
6977
visible: i === commands.length - 1 ? true : false,
@@ -72,12 +80,13 @@ export class AppTerminalComponent implements OnInit {
7280
}, this.commands);
7381
} else {
7482
this.commands[this.commands.length - 1].output += output;
75-
this.commands = this.commands.map((cmd, i) => {
76-
cmd.visible = i === this.commands.length - 1 ? true : false;
77-
return cmd;
78-
});
7983
}
8084

85+
this.commands = this.commands.map((cmd, i) => {
86+
cmd.visible = i === this.commands.length - 1 ? true : false;
87+
return cmd;
88+
});
89+
8190
const recalculateEvent = new SlimScrollEvent({ type: 'recalculate' });
8291
const bottomEvent = new SlimScrollEvent({ type: 'scrollToBottom', duration: 300 });
8392

src/app/styles/terminal.sass

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
.window-terminal-container
55
position: relative
66
display: block
7-
color: #e5e5e5
7+
color: #F0F0F0
88
margin: 0
99
font-family: monaco, monospace
10-
font-size: 12px
1110
padding: 10px 0
1211
height: 400px
13-
background: #111111
12+
background: #1D2021
1413
border-radius: 4px
1514
box-shadow: 1px 2px 10px rgba($background, 0.7)
1615
border: 1px solid $divider
@@ -19,38 +18,44 @@
1918
&.large
2019
height: 700px
2120

22-
.terminal
23-
display: inline-block
24-
text-align: left
25-
padding: 0
26-
margin: 0
27-
width: 100%
28-
29-
.icon
21+
.terminal
3022
display: block
31-
float: left
23+
text-align: left
3224
padding: 0
3325
margin: 0
34-
35-
img
36-
width: 24px
37-
height: 24px
38-
39-
.output
40-
display: inline-block
4126
width: 100%
42-
color: #e5e5e5
43-
margin: 0 !important
44-
font-family: monaco, monospace
45-
font-size: 12px
46-
padding: 0 20px !important
47-
background: #111111
48-
49-
.command
50-
display: block
51-
float: left
5227

53-
.ansi-yellow-fg
54-
color: #FFEE58 !important
55-
font-weight: bold !important
56-
font-size: 13px
28+
.command-line
29+
display: flex
30+
align-items: center
31+
background: #282a36
32+
margin: 2px 5px
33+
padding: 1px 5px
34+
border-radius: 10px
35+
cursor: pointer
36+
37+
.icon
38+
margin-top: 8px
39+
40+
img
41+
width: 24px
42+
height: 24px
43+
44+
.command
45+
46+
span
47+
font-size: 12px
48+
color: #FFEE58
49+
font-weight: bold
50+
51+
.output
52+
display: inline-block
53+
width: 100%
54+
color: #F0F0F0
55+
margin: 0 !important
56+
font-family: Monaco, monospace
57+
font-size: 12px
58+
padding: 10px 20px !important
59+
background: #1D2021
60+
white-space: pre-wrap
61+
word-wrap: break-word

0 commit comments

Comments
 (0)