mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
change font size with command shortcuts (#34)
* add standard behavior when you double click window title to maximize/unmaximize the window * increase/decrease font sizes with command + / - * DRY up code. added reset to reset font to original size. added window accelerators
This commit is contained in:
parent
cf0a5783c5
commit
55ac59c897
2 changed files with 66 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
27
index.js
27
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');
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue