mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
Display the renderer type in the About dialog (#3441)
* Now displaying the renderer type in the About dialog * Show the number of renderers per type in the About dialog * Use values instead of entries (key is unused) Co-Authored-By: onecamp <juancampa@gmail.com>
This commit is contained in:
parent
0dc8fb9ed4
commit
8733ecc84a
4 changed files with 47 additions and 1 deletions
|
|
@ -13,6 +13,7 @@ const helpMenu = require('./menus/help');
|
|||
const darwinMenu = require('./menus/darwin');
|
||||
const {getDecoratedKeymaps} = require('../plugins');
|
||||
const {execCommand} = require('../commands');
|
||||
const {getRendererTypes} = require('../utils/renderer-utils');
|
||||
|
||||
const appName = app.getName();
|
||||
const appVersion = app.getVersion();
|
||||
|
|
@ -39,10 +40,18 @@ exports.createMenu = (createWindow, getLoadedPluginVersions) => {
|
|||
const pluginList =
|
||||
loadedPlugins.length === 0 ? 'none' : loadedPlugins.map(plugin => `\n ${plugin.name} (${plugin.version})`);
|
||||
|
||||
const rendererCounts = Object.values(getRendererTypes()).reduce((acc, type) => {
|
||||
acc[type] = acc[type] ? acc[type] + 1 : 1;
|
||||
return acc;
|
||||
}, {});
|
||||
const renderers = Object.entries(rendererCounts)
|
||||
.map(([type, count]) => type + (count > 1 ? ` (${count})` : ''))
|
||||
.join(', ');
|
||||
|
||||
dialog.showMessageBox({
|
||||
title: `About ${appName}`,
|
||||
message: `${appName} ${appVersion} (${updateChannel})`,
|
||||
detail: `Plugins: ${pluginList}\n\nCreated by Guillermo Rauch\nCopyright © 2018 ZEIT, Inc.`,
|
||||
detail: `Renderers: ${renderers}\nPlugins: ${pluginList}\n\nCreated by Guillermo Rauch\nCopyright © 2018 ZEIT, Inc.`,
|
||||
buttons: [],
|
||||
icon
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ const fetchNotifications = require('../notifications');
|
|||
const Session = require('../session');
|
||||
const contextMenuTemplate = require('./contextmenu');
|
||||
const {execCommand} = require('../commands');
|
||||
const {setRendererType, unsetRendererType} = require('../utils/renderer-utils');
|
||||
|
||||
module.exports = class Window {
|
||||
constructor(options_, cfg, fn) {
|
||||
|
|
@ -153,6 +154,7 @@ module.exports = class Window {
|
|||
|
||||
session.on('exit', () => {
|
||||
rpc.emit('session exit', {uid: options.uid});
|
||||
unsetRendererType(options.uid);
|
||||
sessions.delete(options.uid);
|
||||
});
|
||||
});
|
||||
|
|
@ -192,6 +194,10 @@ module.exports = class Window {
|
|||
}
|
||||
}
|
||||
});
|
||||
rpc.on('info renderer', ({uid, type}) => {
|
||||
// Used in the "About" dialog
|
||||
setRendererType(uid, type);
|
||||
});
|
||||
rpc.on('open external', ({url}) => {
|
||||
shell.openExternal(url);
|
||||
});
|
||||
|
|
|
|||
19
app/utils/renderer-utils.js
Normal file
19
app/utils/renderer-utils.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
const rendererTypes = {};
|
||||
|
||||
function getRendererTypes() {
|
||||
return rendererTypes;
|
||||
}
|
||||
|
||||
function setRendererType(uid, type) {
|
||||
rendererTypes[uid] = type;
|
||||
}
|
||||
|
||||
function unsetRendererType(uid) {
|
||||
delete rendererTypes[uid];
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getRendererTypes,
|
||||
setRendererType,
|
||||
unsetRendererType
|
||||
};
|
||||
|
|
@ -52,6 +52,8 @@ const getTermOptions = props => {
|
|||
useWebGL = true;
|
||||
}
|
||||
}
|
||||
Term.reportRenderer(props.uid, useWebGL ? 'WebGL' : 'Canvas');
|
||||
|
||||
return {
|
||||
macOptionIsMeta: props.modifierKeys.altIsMeta,
|
||||
scrollback: props.scrollback,
|
||||
|
|
@ -110,6 +112,16 @@ export default class Term extends React.PureComponent {
|
|||
this.disposableListeners = [];
|
||||
}
|
||||
|
||||
// The main process shows this in the About dialog
|
||||
static reportRenderer(uid, type) {
|
||||
const rendererTypes = Term.rendererTypes || {};
|
||||
if (rendererTypes[uid] !== type) {
|
||||
rendererTypes[uid] = type;
|
||||
Term.rendererTypes = rendererTypes;
|
||||
window.rpc.emit('info renderer', {uid, type});
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const {props} = this;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue