Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add line height config option #2858

Merged
merged 1 commit into from
Apr 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/config/config-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ module.exports = {
// font weight for bold characters: 'normal' or 'bold'
fontWeightBold: 'bold',

// line height as a relative unit
lineHeight: 1,

// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
cursorColor: 'rgba(248,28,229,0.8)',

Expand Down
1 change: 1 addition & 0 deletions lib/components/term-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class TermGroup_ extends React.PureComponent {
fontSmoothing: this.props.fontSmoothing,
fontWeight: this.props.fontWeight,
fontWeightBold: this.props.fontWeightBold,
lineHeight: this.props.lineHeight,
modifierKeys: this.props.modifierKeys,
padding: this.props.padding,
url: session.url,
Expand Down
7 changes: 6 additions & 1 deletion lib/components/term.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const getTermOptions = props => {
fontSize: props.fontSize,
fontWeight: props.fontWeight,
fontWeightBold: props.fontWeightBold,
lineHeight: props.lineHeight,
allowTransparency: needTransparency,
experimentalCharAtlas: 'dynamic',
theme: {
Expand Down Expand Up @@ -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
// character is
this.term.charMeasure.measure(this.termOptions);
Expand Down
1 change: 1 addition & 0 deletions lib/components/terms.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export default class Terms extends React.Component {
uiFontFamily: this.props.uiFontFamily,
fontWeight: this.props.fontWeight,
fontWeightBold: this.props.fontWeightBold,
lineHeight: this.props.lineHeight,
padding: this.props.padding,
bell: this.props.bell,
bellSoundURL: this.props.bellSoundURL,
Expand Down
1 change: 1 addition & 0 deletions lib/containers/terms.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const TermsContainer = connect(
fontFamily: state.ui.fontFamily,
fontWeight: state.ui.fontWeight,
fontWeightBold: state.ui.fontWeightBold,
lineHeight: state.ui.lineHeight,
uiFontFamily: state.ui.uiFontFamily,
fontSmoothing: state.ui.fontSmoothingOverride,
padding: state.ui.padding,
Expand Down
5 changes: 5 additions & 0 deletions lib/reducers/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const initial = Immutable({
fontSmoothingOverride: 'antialiased',
fontWeight: 'normal',
fontWeightBold: 'bold',
lineHeight: 1,
css: '',
termCSS: '',
openAt: {},
Expand Down Expand Up @@ -138,6 +139,10 @@ const reducer = (state = initial, action) => {
ret.fontWeightBold = config.fontWeightBold;
}

if (Number.isFinite(config.lineHeight)) {
ret.lineHeight = config.lineHeight;
}

if (config.uiFontFamily) {
ret.uiFontFamily = config.uiFontFamily;
}
Expand Down