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

change font size with command shortcuts #34

Merged
merged 4 commits into from Jul 5, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions app/hyperterm.js
Expand Up @@ -45,6 +45,8 @@ export default class HyperTerm extends Component {

this.moveLeft = this.moveLeft.bind(this);
this.moveRight = this.moveRight.bind(this);
this.increaseFontSize = this.increaseFontSize.bind(this);
this.decreaseFontSize = this.decreaseFontSize.bind(this);
}

render () {
Expand Down Expand Up @@ -263,6 +265,32 @@ export default class HyperTerm extends Component {
}
}

increaseFontSize () {
const uid = this.state.sessions[this.state.active];
const term = this.refs[`term-${uid}`];
if (term) {
try {
const size = term.term.prefs_.get('font-size');
term.term.prefs_.set('font-size', size + 1);
} catch (e) {
alert(e);
}
}
}

decreaseFontSize () {
const uid = this.state.sessions[this.state.active];
const term = this.refs[`term-${uid}`];
if (term) {
try {
const size = term.term.prefs_.get('font-size');
term.term.prefs_.set('font-size', size - 1);
} catch (e) {
alert(e);
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This functions are almost identical. I would DRY them up into one that accepted an argument of whether to increment or decrement.


onSessionExit ({ uid }) {
if (!~this.state.sessions.indexOf(uid)) {
console.log('ignore exit of', uid);
Expand Down Expand Up @@ -341,6 +369,8 @@ export default class HyperTerm extends Component {
keys.bind('command+shift+]', this.moveRight);
keys.bind('command+alt+left', this.moveLeft);
keys.bind('command+alt+right', this.moveRight);
keys.bind('command+=', this.increaseFontSize);
keys.bind('command+-', this.decreaseFontSize);

this.keys = keys;
}
Expand Down