Commit ff7e8f3a authored by ibuler's avatar ibuler

[Update] 根据操作系统调整terminal 行高

parent 88619fc4
......@@ -2,6 +2,7 @@ import {Component, Input, OnInit, OnChanges} from '@angular/core';
import {Terminal} from 'xterm';
import {HttpService, LogService} from '@app/services';
import {Replay} from '@app/model';
import {newTerminal} from '@app/utils/common';
function zeroPad(num, minLength) {
let str = num.toString();
......@@ -80,14 +81,7 @@ export class ElementReplayJsonComponent implements OnInit {
constructor(private _http: HttpService) {}
ngOnInit() {
this.term = new Terminal({
fontFamily: '"Monaco", "Consolas", "monospace"',
fontSize: 14,
rightClickSelectsWord: true,
theme: {
background: '#1f1b1b'
}
});
this.term = newTerminal(14);
if (this.replay.src !== 'READY') {
this._http.getReplayData(this.replay.src)
.subscribe(
......
......@@ -4,6 +4,7 @@ import {View} from '@app/model';
import {LogService, SettingService, UUIDService} from '@app/services';
import {Socket} from '@app/utils/socket';
import {getWsSocket, translate} from '@app/globals';
import {newTerminal} from '@app/utils/common';
@Component({
......@@ -38,15 +39,7 @@ export class ElementSshTermComponent implements OnInit, OnDestroy {
newTerm() {
const fontSize = this.settingSvc.setting.fontSize;
this.term = new Terminal({
fontFamily: 'monaco, Consolas, "Lucida Console", monospace',
lineHeight: 1.2,
fontSize: fontSize,
rightClickSelectsWord: true,
theme: {
background: '#1f1b1b'
}
});
this.term = newTerminal(fontSize);
this.view.Term = this.term;
this.term.attachCustomKeyEventHandler(e => {
if (e.ctrlKey && e.key === 'c' && this.term.hasSelection()) {
......
import {Terminal} from 'xterm';
export function groupBy(array, f) {
const groups = {};
array.forEach( function( o ) {
......@@ -9,3 +11,23 @@ export function groupBy(array, f) {
return groups[group];
});
}
export function newTerminal(fontSize?: number) {
if (!fontSize || fontSize < 5 || fontSize > 50) {
fontSize = 13;
}
const ua = navigator.userAgent.toLowerCase();
let lineHeight = 1;
if (ua.indexOf('windows') !== -1) {
lineHeight = 1.2;
}
return new Terminal({
fontFamily: 'monaco, Consolas, "Lucida Console", monospace',
lineHeight: lineHeight,
fontSize: fontSize,
rightClickSelectsWord: true,
theme: {
background: '#1f1b1b'
}
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment