Add line height config (#2858)

Fixes #2858
This commit is contained in:
Brad Dougherty 2018-04-20 18:22:34 -04:00 committed by CHaBou
parent 35cf8c8068
commit bba14f6324
6 changed files with 17 additions and 1 deletions

View file

@ -20,6 +20,9 @@ module.exports = {
// font weight for bold characters: 'normal' or 'bold' // font weight for bold characters: 'normal' or 'bold'
fontWeightBold: 'bold', fontWeightBold: 'bold',
// line height as a relative unit
lineHeight: 1,
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk) // terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
cursorColor: 'rgba(248,28,229,0.8)', cursorColor: 'rgba(248,28,229,0.8)',

View file

@ -71,6 +71,7 @@ class TermGroup_ extends React.PureComponent {
fontSmoothing: this.props.fontSmoothing, fontSmoothing: this.props.fontSmoothing,
fontWeight: this.props.fontWeight, fontWeight: this.props.fontWeight,
fontWeightBold: this.props.fontWeightBold, fontWeightBold: this.props.fontWeightBold,
lineHeight: this.props.lineHeight,
modifierKeys: this.props.modifierKeys, modifierKeys: this.props.modifierKeys,
padding: this.props.padding, padding: this.props.padding,
url: session.url, url: session.url,

View file

@ -32,6 +32,7 @@ const getTermOptions = props => {
fontSize: props.fontSize, fontSize: props.fontSize,
fontWeight: props.fontWeight, fontWeight: props.fontWeight,
fontWeightBold: props.fontWeightBold, fontWeightBold: props.fontWeightBold,
lineHeight: props.lineHeight,
allowTransparency: needTransparency, allowTransparency: needTransparency,
experimentalCharAtlas: 'dynamic', experimentalCharAtlas: 'dynamic',
theme: { theme: {
@ -263,7 +264,11 @@ export default class Term extends React.PureComponent {
}); });
} }
if (this.props.fontSize !== nextProps.fontSize || this.props.fontFamily !== nextProps.fontFamily) { if (
this.props.fontSize !== nextProps.fontSize ||
this.props.fontFamily !== nextProps.fontFamily ||
this.props.lineHeight !== nextProps.lineHeight
) {
// invalidate xterm cache about how wide each // invalidate xterm cache about how wide each
// character is // character is
this.term.charMeasure.measure(this.termOptions); this.term.charMeasure.measure(this.termOptions);

View file

@ -101,6 +101,7 @@ export default class Terms extends React.Component {
uiFontFamily: this.props.uiFontFamily, uiFontFamily: this.props.uiFontFamily,
fontWeight: this.props.fontWeight, fontWeight: this.props.fontWeight,
fontWeightBold: this.props.fontWeightBold, fontWeightBold: this.props.fontWeightBold,
lineHeight: this.props.lineHeight,
padding: this.props.padding, padding: this.props.padding,
bell: this.props.bell, bell: this.props.bell,
bellSoundURL: this.props.bellSoundURL, bellSoundURL: this.props.bellSoundURL,

View file

@ -26,6 +26,7 @@ const TermsContainer = connect(
fontFamily: state.ui.fontFamily, fontFamily: state.ui.fontFamily,
fontWeight: state.ui.fontWeight, fontWeight: state.ui.fontWeight,
fontWeightBold: state.ui.fontWeightBold, fontWeightBold: state.ui.fontWeightBold,
lineHeight: state.ui.lineHeight,
uiFontFamily: state.ui.uiFontFamily, uiFontFamily: state.ui.uiFontFamily,
fontSmoothing: state.ui.fontSmoothingOverride, fontSmoothing: state.ui.fontSmoothingOverride,
padding: state.ui.padding, padding: state.ui.padding,

View file

@ -47,6 +47,7 @@ const initial = Immutable({
fontSmoothingOverride: 'antialiased', fontSmoothingOverride: 'antialiased',
fontWeight: 'normal', fontWeight: 'normal',
fontWeightBold: 'bold', fontWeightBold: 'bold',
lineHeight: 1,
css: '', css: '',
termCSS: '', termCSS: '',
openAt: {}, openAt: {},
@ -138,6 +139,10 @@ const reducer = (state = initial, action) => {
ret.fontWeightBold = config.fontWeightBold; ret.fontWeightBold = config.fontWeightBold;
} }
if (Number.isFinite(config.lineHeight)) {
ret.lineHeight = config.lineHeight;
}
if (config.uiFontFamily) { if (config.uiFontFamily) {
ret.uiFontFamily = config.uiFontFamily; ret.uiFontFamily = config.uiFontFamily;
} }