Skip to content

Commit

Permalink
added some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nitin42 committed Jul 13, 2017
1 parent 36bbc0d commit 8cac62a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions components/Terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class Terminal extends Component {
};
}

// Prepare the symbol
componentWillMount = () => {
this.setState({ prompt: this.props.promptSymbol });
};
Expand All @@ -159,7 +160,7 @@ class Terminal extends Component {
}
};

// Show the content on basis of the toggling
// Show the content on toggling
getAppContent = () => {
const { show, minimise } = this.state;
if (!show) {
Expand All @@ -171,7 +172,7 @@ class Terminal extends Component {
return this.getContent();
};

// Shows the everything (normal window)
// Shows everything (normal window)
getContent = () => {
const { backgroundColor, color, style, barColor, prompt } = this.props;

Expand Down Expand Up @@ -259,8 +260,10 @@ class Terminal extends Component {
this.setState({ promptPrefix });
};

// Hide window
setFalse = name => () => this.setState({ [name]: false });

// Show window
setTrue = name => () => this.setState({ [name]: true });

/**
Expand All @@ -277,7 +280,7 @@ class Terminal extends Component {

toggleState = name => () => this.setState({ [name]: !this.state[name] });

// Prepare built-in commands
// Prepare the built-in commands
assembleCommands = () => {
let commands = {
show: this.showMsg,
Expand Down Expand Up @@ -352,10 +355,12 @@ class Terminal extends Component {
return inputRef.value;
}

// Refresh or clear the screen
clearScreen = () => {
this.setState({ summary: [] });
};

// edit-line command
editLine = (args) => {
const { summary } = this.state;
let index = args.line;
Expand Down Expand Up @@ -425,7 +430,7 @@ class Terminal extends Component {
}
}

// Plugins (beta)
// Plugins
loadPlugins = () => {
this.props.plugins.forEach((plugin) => {
try {
Expand All @@ -448,7 +453,7 @@ class Terminal extends Component {
this.setState({ summary });
};

// Exec commands
// Execute the commands
runCommand = (inputText) => {
const inputArray = inputText.split(' ');
const input = inputArray[0];
Expand Down Expand Up @@ -481,6 +486,7 @@ class Terminal extends Component {
// handleLogging('error', this.printLine);
};

// List all the commands (state + user defined)
showHelp = () => {
const options = Object.keys(this.state.commands);
const descriptions = this.state.descriptions;
Expand All @@ -492,6 +498,7 @@ class Terminal extends Component {
}
};

// Show the msg (prop msg)
showMsg = () => {
this.printLine(this.props.msg);
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "terminal-in-react",
"version": "3.0.0",
"version": "3.0.1",
"description": "A component for making a terminal in React",
"main": "index.js",
"repository": "https://www.github.com/nitin42/terminal-in-react",
Expand Down

0 comments on commit 8cac62a

Please sign in to comment.