diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 205ee835..9378e71d 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -50,6 +50,7 @@ The terminal has several options you can use to change the behaviour of it. All | readOnly | Hides the entire prompt, thus setting the terminal to read-only mode. | Boolean | `false` | | styleEchoBack | Inherit style for command echoes (Terminal outputs of any commands entered) from prompt (Fully or partially, i.e. label or text only), or style them as regular messages. Omitting this prop enables default behaviour. | String<'labelOnly'/'textOnly'/'fullInherit'/'messageInherit'\> | `undefined` | | welcomeMessage | The terminal welcome message. Set to `false` to disable, `true` to show the default, or supply a string (Or an array of them) to set a custom one. | Boolean/String/Array | `false` | +| maxOutput | The maximum amount of output lines in the terminal. Set to integer to cap output lines at that amount, set to 0 for there to be no cap. Omitting this prop enables default behaviour. | Number | `0` | ### Re-styling diff --git a/src/Terminal.jsx b/src/Terminal.jsx index 49bbe720..525970f6 100644 --- a/src/Terminal.jsx +++ b/src/Terminal.jsx @@ -90,7 +90,8 @@ export default class Terminal extends Component { const { stdout } = this.state if (this.props.locked) stdout.pop() - + if (this.props.maxOutput && stdout.length >= this.props.maxOutput) stdout.shift() + stdout.push({ message, isEcho: options?.isEcho || false }) /* istanbul ignore next: Covered by interactivity tests */ diff --git a/src/defs/types/Terminal.js b/src/defs/types/Terminal.js index 3747a182..7243a104 100644 --- a/src/defs/types/Terminal.js +++ b/src/defs/types/Terminal.js @@ -39,7 +39,8 @@ const optionTypes = { noEchoBack: PropTypes.bool, noHistory: PropTypes.bool, noAutoScroll: PropTypes.bool, - noNewlineParsing: PropTypes.bool + noNewlineParsing: PropTypes.bool, + maxOutput: PropTypes.number } const labelTypes = {