Skip to content

Commit

Permalink
💎 Add Active process handle info in status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
princejwesley committed Feb 28, 2016
1 parent f6460bc commit ea5e080
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/common/ReplOutput.js
Expand Up @@ -221,7 +221,7 @@ class None {
return None.instance; return None.instance;
} }
getValue() { return void 0; } getValue() { return void 0; }
highlight(output) { highlight(output = '') {
let [first, ...rest] = (output.stack || output.toString()).split(EOL); let [first, ...rest] = (output.stack || output.toString()).split(EOL);
return { return {
formattedOutput: formattedOutput:
Expand Down
24 changes: 24 additions & 0 deletions src/components/ReplStatusBar.js
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import shell from 'shell'; import shell from 'shell';
import ReplPreferencesActions from '../actions/ReplPreferencesActions'; import ReplPreferencesActions from '../actions/ReplPreferencesActions';
import ReplStatusBarStore from '../stores/ReplStatusBarStore'; import ReplStatusBarStore from '../stores/ReplStatusBarStore';
import ReplCommon from '../common/ReplCommon';
import _ from 'lodash'; import _ from 'lodash';


export default class ReplStatusBar extends React.Component { export default class ReplStatusBar extends React.Component {
Expand All @@ -11,6 +12,7 @@ export default class ReplStatusBar extends React.Component {
this.onDownload = this.onDownload.bind(this); this.onDownload = this.onDownload.bind(this);
this.onTriggerPreferences = this.onTriggerPreferences.bind(this); this.onTriggerPreferences = this.onTriggerPreferences.bind(this);
this.onStoreChange = this.onStoreChange.bind(this); this.onStoreChange = this.onStoreChange.bind(this);
this.getActiveHandle = this.getActiveHandle.bind(this);
} }


componentDidMount() { componentDidMount() {
Expand Down Expand Up @@ -44,10 +46,28 @@ export default class ReplStatusBar extends React.Component {
ReplPreferencesActions.togglePreferences(); 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() { render() {
let {commands, errors} = this.extractStatusInfo(); let {commands, errors} = this.extractStatusInfo();
let runHelp = this.state.runCommand ? '⇧ + ↲' : '↲'; let runHelp = this.state.runCommand ? '⇧ + ↲' : '↲';
let imgURL = `./logos/${this.state.lang}.png`; let imgURL = `./logos/${this.state.lang}.png`;
let [handleCount, handleMsg] = this.getActiveHandle();
return ( return (
<div className='repl-status-bar'> <div className='repl-status-bar'>
<span className='repl-status-bar-preference' title='Preferences'> <span className='repl-status-bar-preference' title='Preferences'>
Expand All @@ -61,6 +81,10 @@ export default class ReplStatusBar extends React.Component {
<i className="fa fa-circle"></i> <i className="fa fa-circle"></i>
<span className='repl-status-bar-count'>{errors}</span> <span className='repl-status-bar-count'>{errors}</span>
</span> </span>
<span className='repl-status-bar-handles' title={handleMsg}>
<i className="fa fa-circle"></i>
<span className='repl-status-bar-count'>{handleCount}</span>
</span>
<span className='repl-status-bar-lang' title='REPL language'> <span className='repl-status-bar-lang' title='REPL language'>
<img className='repl-status-bar-img' src={imgURL}/> <img className='repl-status-bar-img' src={imgURL}/>
</span> </span>
Expand Down
1 change: 1 addition & 0 deletions stylesheets/dark-theme.scss
Expand Up @@ -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-background-color: #3E3D3D;
$dark-app-status-bar-command-color: rgb(73, 197, 73); $dark-app-status-bar-command-color: rgb(73, 197, 73);
$dark-app-status-bar-error-color: rgb(208, 95, 75); $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-message-color: rgb(173, 170, 170);
$dark-app-status-bar-mode-color: #CCCC4C; $dark-app-status-bar-mode-color: #CCCC4C;
$dark-app-status-bar-console-color: deepskyblue; $dark-app-status-bar-console-color: deepskyblue;
Expand Down
1 change: 1 addition & 0 deletions stylesheets/light-theme.scss
Expand Up @@ -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-background-color: darken(whitesmoke, 10%);
$lt-app-status-bar-command-color: rgb(73, 197, 73); $lt-app-status-bar-command-color: rgb(73, 197, 73);
$lt-app-status-bar-error-color: rgb(208, 95, 75); $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-message-color: #676464;
$lt-app-status-bar-mode-color: #C3C378; $lt-app-status-bar-mode-color: #C3C378;
$lt-app-status-bar-console-color: #0378F9; $lt-app-status-bar-console-color: #0378F9;
Expand Down
5 changes: 5 additions & 0 deletions stylesheets/repl-status-bar.scss
Expand Up @@ -66,6 +66,11 @@
padding: 0 5px; 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-count,
.repl-status-bar-message { .repl-status-bar-message {
pointer-events: none; pointer-events: none;
Expand Down

1 comment on commit ea5e080

@princejwesley
Copy link
Owner Author

Choose a reason for hiding this comment

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

image
image

Please sign in to comment.