diff --git a/src/Console.js b/src/Console.js index 4dd40c8..907e0db 100644 --- a/src/Console.js +++ b/src/Console.js @@ -1,5 +1,6 @@ import React from 'react'; -import { XTerm } from 'xterm-for-react' +import { XTerm } from 'xterm-for-react'; +import { Terminal } from 'xterm'; export class Console extends React.Component { constructor(props) { @@ -16,14 +17,21 @@ export class Console extends React.Component { background: '#212121', brightGreen: '#15a179' }, - convertEol: true + convertEol: true, + rows: 30, + cols: 200 }} /> ; } componentDidMount() { - require('./emulator')(this.terminal.current); - this.terminal.current.terminal.focus(); + const term_ref = this.terminal.current; + require('./emulator')(term_ref); + + /** @type { Terminal } */ + const terminal = term_ref.terminal; + + terminal.focus(); } } \ No newline at end of file diff --git a/src/emulator/commands/clear.js b/src/emulator/commands/clear.js new file mode 100644 index 0000000..c366348 --- /dev/null +++ b/src/emulator/commands/clear.js @@ -0,0 +1,25 @@ +const { Terminal } = require("xterm"); +const package = require('../../../package.json'); + +/** + * + * @param {string[]} argv + * @param {Terminal} terminal + */ +module.exports = (argv, terminal) => { + if (argv.indexOf('--help') != -1) { + terminal.write( +`Usage: ${argv[0]} [options] + -V Print resume.js version +` + ); + return; + } + + if (argv.indexOf('-V') != -1) { + terminal.write(`resume.js version ${package.version} by ${package.author}\n`); + return; + } + + terminal.clear(); +} \ No newline at end of file diff --git a/src/emulator/commands/index.js b/src/emulator/commands/index.js index e4b0603..bbdff12 100644 --- a/src/emulator/commands/index.js +++ b/src/emulator/commands/index.js @@ -11,6 +11,7 @@ let cmds = { 'import_file': require('./import_file'), 'zsh': require('./zsh'), 'ps': require('./ps'), + 'clear': require('./clear'), // alias l='ls -l' 'l': (a,t) => {require('./ls')([...a, '-l'], t)},