-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Milestone
Description
Task Description
Set up an abstract class for the terminal which should define the methods and the APIs for a terminal in TPF learning section's tutorials.
In the context of TPF, a terminal should have the following behaviour:
- Accept an HTML Div Element and mount to it while initializing
- Accept custom styles when initializing and should also allow for customization after initialization.
- Should allow the user to type and execute commands
- Should accept a callback function during initialization which will be called whenever a command is executed.
- Should accept an instance of a file system while initializing and use it for executing filesystem related commands.
- Should keep track of previously executed commands
- Should allow for navigating across previously executed commands.
- Should have a method for toggling the state of the waiting/executing state of the terminal.
- Should have a method for programmatically writing to the terminal via external programs (basically for displaying the output of executed commands)
- Should have a method for minimizing
- Should have a method for closing
Acceptance criteria for task
- Check that the implementations of the class have a private method named
mount
- Check that the implementations of the class have a public method named
style
. - Check that the implementations of the class have a private variable named
filesystem
- Check that the implementations of the class have a public method named
toggleWaitignState
- Check that the implementations of the class have a public method named
writeToOut
- Check that the implementations of the class have a public method method
minimize
- Check that the implementations of the class have a public method named
close
Additional context
Shiva Raju has a very good implementation for the abstract class in Javascript. Refer to this if you are unsure about how to do it.
class PFEditorAbstractClass {
constructor() {
if (this.constructor === PFEditorAbstractClass) {
throw new TypeError('Abstract class "PFEditorAbstractClass" cannot be instantiated directly.');
}
//abstract method for mounting an Editor into a DOM Elemement must be implemented
if(!typeof this.mountEditorToDOMElement === 'function'){
throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
}
if (this.content === undefined) {
throw new TypeError('Classes implementing PFEditorAbstractClass must have the content as an attribute')
}
//abstract method for storing one or more variables in local storage must be implemented
if(!this.saveContent === 'function'){
throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
}]
//abstract method for retrieving one or more variables from local storage must be implemented
if(!typeof this. this.getContent === 'function'){
throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
}
//abstract method for closing the Editor after necessary cleanup operations must be implemented
if(!typeof this.closeEditor === 'function'){
throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
}
//abstract method for minimizing the Editor after necessary saving operations must be implemented
if(!typeof this.minimizeEditor === 'function'){
throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
}
}
}
Metadata
Metadata
Assignees
Labels
No labels