hyper/app/lib/containers/terms.js
Mike b76e004309 Dynamically change the font-smoothing pref (#205)
* Dynamically change the `font-smoothing` pref

By default, hterm defaults to `font-smoothing: 'antialiased'`, which
works really well on retina displays. On non-retina displays, however,
the type looks very thin and is hard to read.

This will look at the devicePixelRatio of the device anytime the term
prefs are set, and change between `antialiased` and
`subpixel-antialiased` dynamically.

* Refactor to add the font smoothing override into state

This also subscribes to the electron `move` event to control when this
piece of state gets updated.

* Add UI_WINDOW_MOVE action with a side effect for font smoothing
2016-07-19 11:30:57 -07:00

62 lines
1.5 KiB
JavaScript

import Terms from '../components/terms';
import { values } from '../utils/object';
import { connect } from '../utils/plugins';
import {
resizeSession,
sendSessionData,
exitSessionBrowser,
setSessionXtermTitle,
setActiveSession
} from '../actions/sessions';
const TermsContainer = connect(
(state) => {
const sessions = state.sessions.sessions;
return {
cols: state.ui.cols,
rows: state.ui.rows,
sessions: values(sessions),
activeSession: state.sessions.activeUid,
customCSS: state.ui.termCSS,
write: state.sessions.write,
fontSize: state.ui.fontSizeOverride
? state.ui.fontSizeOverride
: state.ui.fontSize,
fontFamily: state.ui.fontFamily,
fontSmoothing: state.ui.fontSmoothingOverride,
padding: state.ui.padding,
cursorColor: state.ui.cursorColor,
borderColor: state.ui.borderColor,
colors: state.ui.colors,
foregroundColor: state.ui.foregroundColor,
backgroundColor: state.ui.backgroundColor
};
},
(dispatch) => {
return {
onData (uid, data) {
dispatch(sendSessionData(uid, data));
},
onTitle (uid, title) {
dispatch(setSessionXtermTitle(uid, title));
},
onResize (uid, cols, rows) {
dispatch(resizeSession(uid, cols, rows));
},
onURLAbort (uid) {
dispatch(exitSessionBrowser(uid));
},
onActive (uid) {
dispatch(setActiveSession(uid));
}
};
},
null,
{ withRef: true }
)(Terms, 'Terms');
export default TermsContainer;