From ea5e08022ab087eb1d5847f6d1d2c9c6502d88cb Mon Sep 17 00:00:00 2001 From: Prince J Wesley Date: Mon, 29 Feb 2016 02:46:09 +0530 Subject: [PATCH] :gem: Add Active process handle info in status bar --- src/common/ReplOutput.js | 2 +- src/components/ReplStatusBar.js | 24 ++++++++++++++++++++++++ stylesheets/dark-theme.scss | 1 + stylesheets/light-theme.scss | 1 + stylesheets/repl-status-bar.scss | 5 +++++ 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/common/ReplOutput.js b/src/common/ReplOutput.js index 72250f5..e425b92 100644 --- a/src/common/ReplOutput.js +++ b/src/common/ReplOutput.js @@ -221,7 +221,7 @@ class None { return None.instance; } getValue() { return void 0; } - highlight(output) { + highlight(output = '') { let [first, ...rest] = (output.stack || output.toString()).split(EOL); return { formattedOutput: diff --git a/src/components/ReplStatusBar.js b/src/components/ReplStatusBar.js index a1dd2de..a0f4a72 100644 --- a/src/components/ReplStatusBar.js +++ b/src/components/ReplStatusBar.js @@ -2,6 +2,7 @@ import React from 'react'; import shell from 'shell'; import ReplPreferencesActions from '../actions/ReplPreferencesActions'; import ReplStatusBarStore from '../stores/ReplStatusBarStore'; +import ReplCommon from '../common/ReplCommon'; import _ from 'lodash'; export default class ReplStatusBar extends React.Component { @@ -11,6 +12,7 @@ export default class ReplStatusBar extends React.Component { this.onDownload = this.onDownload.bind(this); this.onTriggerPreferences = this.onTriggerPreferences.bind(this); this.onStoreChange = this.onStoreChange.bind(this); + this.getActiveHandle = this.getActiveHandle.bind(this); } componentDidMount() { @@ -44,10 +46,28 @@ export default class ReplStatusBar extends React.Component { ReplPreferencesActions.togglePreferences(); } + getActiveHandle() { + let twoDigit = x => `${(x < 10 ? '0' : '')}${x}`; + let handles = process._getActiveHandles(); + let now = new Date(); + let [hh, mm, ss] = [now.getHours(), now.getMinutes(), now.getSeconds()]; + let ts = `${twoDigit(hh)}:${twoDigit(mm)}:${twoDigit(ss)}`; + let msg = _.chain(handles) + .map(h => ReplCommon.type(h)) + .sort() + .reduce((acc, h) => (acc[h] = acc[h] ? acc[h] + 1 : 1, acc), {}) + .map((v, k) => `${k}(${v})`) + .tap(o => o.join(', ')) + .value(); + return [handles.length, + `Active handles(at ${ts}): ${msg}`] + } + render() { let {commands, errors} = this.extractStatusInfo(); let runHelp = this.state.runCommand ? '⇧ + ↲' : '↲'; let imgURL = `./logos/${this.state.lang}.png`; + let [handleCount, handleMsg] = this.getActiveHandle(); return (
@@ -61,6 +81,10 @@ export default class ReplStatusBar extends React.Component { {errors} + + + {handleCount} + diff --git a/stylesheets/dark-theme.scss b/stylesheets/dark-theme.scss index 819b85a..8798e74 100644 --- a/stylesheets/dark-theme.scss +++ b/stylesheets/dark-theme.scss @@ -26,6 +26,7 @@ $dark-app-entry-status-minus-color: rgb(252, 181, 50); $dark-app-status-bar-background-color: #3E3D3D; $dark-app-status-bar-command-color: rgb(73, 197, 73); $dark-app-status-bar-error-color: rgb(208, 95, 75); +$dark-app-status-bar-handle-color: rgb(253, 190, 65); $dark-app-status-bar-message-color: rgb(173, 170, 170); $dark-app-status-bar-mode-color: #CCCC4C; $dark-app-status-bar-console-color: deepskyblue; diff --git a/stylesheets/light-theme.scss b/stylesheets/light-theme.scss index 52ed513..627894a 100644 --- a/stylesheets/light-theme.scss +++ b/stylesheets/light-theme.scss @@ -26,6 +26,7 @@ $lt-app-entry-status-minus-color: rgb(252, 181, 50); $lt-app-status-bar-background-color: darken(whitesmoke, 10%); $lt-app-status-bar-command-color: rgb(73, 197, 73); $lt-app-status-bar-error-color: rgb(208, 95, 75); +$lt-app-status-bar-handle-color: rgb(253, 190, 65); $lt-app-status-bar-message-color: #676464; $lt-app-status-bar-mode-color: #C3C378; $lt-app-status-bar-console-color: #0378F9; diff --git a/stylesheets/repl-status-bar.scss b/stylesheets/repl-status-bar.scss index 4de2a8c..0c98c30 100644 --- a/stylesheets/repl-status-bar.scss +++ b/stylesheets/repl-status-bar.scss @@ -66,6 +66,11 @@ padding: 0 5px; } + .repl-status-bar-handles { + color: if($theme == $dark-theme, $dark-app-status-bar-handle-color, $lt-app-status-bar-handle-color); + padding: 0 5px; + } + .repl-status-bar-count, .repl-status-bar-message { pointer-events: none;