-
Notifications
You must be signed in to change notification settings - Fork 10
Edited the teminal movements #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements cursor movement functionality in the terminal component, allowing users to navigate left and right within their input text and edit at any position.
- Added cursor position tracking with left/right arrow key navigation
- Enhanced backspace functionality to work with cursor positioning
- Implemented text insertion at cursor position for both regular characters and spaces
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| term.write(`\x1b[${charsToMoveBack}D`); | ||
| } | ||
| } | ||
| else if(domEvent.key == 'ArrowLeft'){ |
Copilot
AI
Sep 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use strict equality (===) instead of loose equality (==) for comparison. This prevents type coercion issues and follows JavaScript best practices.
| else if(domEvent.key == 'ArrowLeft'){ | |
| else if(domEvent.key === 'ArrowLeft'){ |
| term.write('\x1b[D'); | ||
| } | ||
| } | ||
| else if(domEvent.key == 'ArrowRight'){ |
Copilot
AI
Sep 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use strict equality (===) instead of loose equality (==) for comparison. This prevents type coercion issues and follows JavaScript best practices.
| else if(domEvent.key == 'ArrowRight'){ | |
| else if(domEvent.key === 'ArrowRight'){ |
| else if(domEvent.key == 'ArrowLeft'){ | ||
| if(cursorPos > 0){ | ||
| cursorPos--; | ||
| term.write('\x1b[D'); | ||
| } | ||
| } | ||
| else if(domEvent.key == 'ArrowRight'){ | ||
| if(cursorPos < input.length){ | ||
| cursorPos++; | ||
| term.write('\x1b[C'); | ||
| } | ||
| } |
Copilot
AI
Sep 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent spacing around parentheses and braces. Add spaces after 'if' and around parentheses for consistency with the rest of the codebase.
|
|
||
| let input = ''; | ||
| let currentDir = 'home'; | ||
| let cursorPos = 0; |
Copilot
AI
Sep 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cursorPos variable should be reset to 0 when input is cleared (after Enter key is pressed) to maintain proper cursor positioning for new commands.
edited the terminal movement like moving left and right in the terminal . and editing the text after movement.