Add letter spacing configuration option (#3002)

This commit is contained in:
Ricardo Amaral 2018-05-10 11:54:00 +01:00 committed by CHaBou
parent 3f88e96847
commit 1940e931ed
6 changed files with 14 additions and 1 deletions

View file

@ -23,6 +23,9 @@ module.exports = {
// line height as a relative unit // line height as a relative unit
lineHeight: 1, lineHeight: 1,
// letter spacing as a relative unit
letterSpacing: 0,
// 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

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

View file

@ -33,6 +33,7 @@ const getTermOptions = props => {
fontWeight: props.fontWeight, fontWeight: props.fontWeight,
fontWeightBold: props.fontWeightBold, fontWeightBold: props.fontWeightBold,
lineHeight: props.lineHeight, lineHeight: props.lineHeight,
letterSpacing: props.letterSpacing,
allowTransparency: needTransparency, allowTransparency: needTransparency,
experimentalCharAtlas: 'dynamic', experimentalCharAtlas: 'dynamic',
theme: { theme: {
@ -267,7 +268,8 @@ export default class Term extends React.PureComponent {
if ( if (
this.props.fontSize !== nextProps.fontSize || this.props.fontSize !== nextProps.fontSize ||
this.props.fontFamily !== nextProps.fontFamily || this.props.fontFamily !== nextProps.fontFamily ||
this.props.lineHeight !== nextProps.lineHeight this.props.lineHeight !== nextProps.lineHeight ||
this.props.letterSpacing !== nextProps.letterSpacing
) { ) {
// invalidate xterm cache about how wide each // invalidate xterm cache about how wide each
// character is // character is

View file

@ -102,6 +102,7 @@ export default class Terms extends React.Component {
fontWeight: this.props.fontWeight, fontWeight: this.props.fontWeight,
fontWeightBold: this.props.fontWeightBold, fontWeightBold: this.props.fontWeightBold,
lineHeight: this.props.lineHeight, lineHeight: this.props.lineHeight,
letterSpacing: this.props.letterSpacing,
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

@ -27,6 +27,7 @@ const TermsContainer = connect(
fontWeight: state.ui.fontWeight, fontWeight: state.ui.fontWeight,
fontWeightBold: state.ui.fontWeightBold, fontWeightBold: state.ui.fontWeightBold,
lineHeight: state.ui.lineHeight, lineHeight: state.ui.lineHeight,
letterSpacing: state.ui.letterSpacing,
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

@ -48,6 +48,7 @@ const initial = Immutable({
fontWeight: 'normal', fontWeight: 'normal',
fontWeightBold: 'bold', fontWeightBold: 'bold',
lineHeight: 1, lineHeight: 1,
letterSpacing: 0,
css: '', css: '',
termCSS: '', termCSS: '',
openAt: {}, openAt: {},
@ -143,6 +144,10 @@ const reducer = (state = initial, action) => {
ret.lineHeight = config.lineHeight; ret.lineHeight = config.lineHeight;
} }
if (Number.isFinite(config.letterSpacing)) {
ret.letterSpacing = config.letterSpacing;
}
if (config.uiFontFamily) { if (config.uiFontFamily) {
ret.uiFontFamily = config.uiFontFamily; ret.uiFontFamily = config.uiFontFamily;
} }