CabrilloRoboticsClub / cabrillo_rov_2023

Cabrillo College Robotics Club repo for the MATE ROV 2023 competition
GNU Affero General Public License v3.0
10 stars 5 forks source link

Term widget #214

Closed steph1111 closed 6 months ago

steph1111 commented 6 months ago

#212 should be merged before this PR

Summary

This pull request is for the merge of a terminal widget. The terminal widget provides a fully functional embedded terminal in the dashboard's debug tab.

https://github.com/CabrilloRoboticsClub/cabrillo_rov_2023/assets/96219204/e2d12471-7923-4ec9-87f5-a129d2db6d4c

Reason for merge

An embedded terminal within the dashboard will allow for rapid debugging The terminal fully supports ROS commands. This means we can run commands like ros2 topic echo without leaving the dashboard.

Detailed overview

General usage

The terminal includes a textbox which allows users to input commands. Upon entering a command, a QProcess is started executing the received command. The command's results are then displayed to the user. Upon successful execution, the command is outputted with a green arrow along with the command's result. If a command is not recognized, a red arrow is displayed with the text "command not found: invalid-cmd". A limit of 200 lines is displayed to the terminal. If this limit is exceeded, the lines ran at the beginning are cleared,

image

cd

cd can change directories within the terminal environment. If the change directory operation was successful, the path displayed is updated to reflect this.

clear

clear clears the contents output of previous commands displayed to the screen. The command history remains unmodified.

history

All commands ran in an session are stored. These commands can be listed using history as an indexed list. To rerun a specific command, the user may type !# where # is the index of the command. !! runs the last command. Previous commands can also be retrieved using the keyboard up and down arrows, as with a standard terminal . image

Special key sequences

Sequence Functionality
ctrl-c: Terminate process
ctrl-shift-c Copy selected text
ctrl-shift-v Paste text
ctrl-l Clear screen (same as clear command)
ctrl-a Move to the start of the line
ctrl-e Move to the end of the line
ctrl-b Move one character backward
ctrl-f Move one character forward
ctrl-w Delete the word before the cursor
ctrl-u Delete from the cursor to the start of the line
ctrl-k Delete from the cursor to the end of the line

Light mode

Much like the rest of the dashboard, this widget supports light mode

Testing

The widget has been tested with various commands (including the infamous find \ and behaves as expected. ROS commands all work. Shell specific commands do not have functionality which we decided was acceptable. There is one weird bug I cannot figure out how to resolve in which the scroll bar does not show up until the light mode is initiated. If light mode is then turned off again the scroll bar continues working. I'm unsure what this is from, but it is a very minor bug.