diff --git a/app/hyperterm.js b/app/hyperterm.js index cc05bea383f1..3b362d0fb452 100644 --- a/app/hyperterm.js +++ b/app/hyperterm.js @@ -45,6 +45,9 @@ export default class HyperTerm extends Component { this.moveLeft = this.moveLeft.bind(this); this.moveRight = this.moveRight.bind(this); + this.resetFontSize = this.resetFontSize.bind(this); + this.increaseFontSize = this.increaseFontSize.bind(this); + this.decreaseFontSize = this.decreaseFontSize.bind(this); } render () { @@ -224,6 +227,9 @@ export default class HyperTerm extends Component { this.rpc.on('move left', this.moveLeft); this.rpc.on('move right', this.moveRight); + this.rpc.on('increase font size', this.increaseFontSize); + this.rpc.on('decrease font size', this.decreaseFontSize); + this.rpc.on('reset font size', this.resetFontSize); } clearCurrentTerm () { @@ -263,6 +269,36 @@ export default class HyperTerm extends Component { } } + changeFontSize (value) { + 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 + value); + } catch (e) { + alert(e); + } + } + } + + resetFontSize () { + const uid = this.state.sessions[this.state.active]; + const term = this.refs[`term-${uid}`]; + if (term) { + //TODO: once we have preferences, we need to read from it + term.term.prefs_.set('font-size', 12); + } + } + + increaseFontSize () { + this.changeFontSize(1); + } + + decreaseFontSize () { + this.changeFontSize(-1); + } + onSessionExit ({ uid }) { if (!~this.state.sessions.indexOf(uid)) { console.log('ignore exit of', uid); @@ -341,6 +377,9 @@ 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); + keys.bind('command+0', this.resetFontSize); this.keys = keys; } diff --git a/index.js b/index.js index 8835cbc519a1..64a8cfe523b9 100644 --- a/index.js +++ b/index.js @@ -230,6 +230,33 @@ app.on('ready', () => { }, { role: 'togglefullscreen' + }, + { + label: 'Actual Size', + accelerator: 'CmdOrCtrl+0', + click (item, focusedWindow) { + if (focusedWindow) { + focusedWindow.rpc.emit('reset font size'); + } + } + }, + { + label: 'Zoom In', + accelerator: 'CmdOrCtrl+plus', + click (item, focusedWindow) { + if (focusedWindow) { + focusedWindow.rpc.emit('increase font size'); + } + } + }, + { + label: 'Zoom Out', + accelerator: 'CmdOrCtrl+-', + click (item, focusedWindow) { + if (focusedWindow) { + focusedWindow.rpc.emit('decrease font size'); + } + } } ] },