Skip to content

Conversation

@janine9vn
Copy link
Contributor

No description provided.

jon-edward and others added 30 commits August 9, 2025 20:12
Merge GUI features to main
# Conflicts:
#	src/commands/load_image.py
#	src/terminal.py
added some exclusions in toml as well
Copy link
Contributor Author

@janine9vn janine9vn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Overall Picture

This was a very fun project to test out. Your overall project structure and organization is nicely done. It makes it easy to review and reason about the code. Your project functioned really well and everything was intuitive once you read through the basic commands. Things worked seamlessly which is very impressive given the time constraints. Overall, very well done!

README & Documentation

The README and Documentation are excellent. I think an area of improvement could be adding some example commands for each major feature to try out, or showcase one of the more complex commands. There are a few spots in the code where I think some comments are redundant and some other parts where an additional comment or two would be helpful. Typehints are well done. I think the docstrings on some of the busier functions could be improved a bit and include more information, but otherwise the class docstrings are well done and no other complaints.

Commits

The commits overall look good in terms of scope and messages. There are a few where the messages could be improved though. For instance "bugfixes" or "fixed ping" could be improved by either calling out specific bugs in the commit title or in the body if you need more space to detail things.

Code Quality

Overall the code quality is of a good level. There are a few places where dunders are used when there's more straight-forward syntax that can be used instead. Some formatting every-so-often was a bit odd and I think could be slightly improved. Overall your implementation is very class-heavy, but that's not a bad thing and makes sense with what your project deals with. Some of your functions were heavily indicated as "private" with the leading underscore, but across the project that was inconsistent.

from terminal import Terminal


class BaseCommand:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you looked into using the @abc.abstractmethod for this to require functions to be overridden by subclasses instead of the manual raising of the NotImplementedError?
Based on the docstrings for the functions it seems like that may be what you want.


match len(args):
case 0:
return " " + str(terminal.background_color.r)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An f-string would be good to use here: return f" {terminal.background_color.r}"

Comment on lines +59 to +65
if not (args[2].isdigit()):
terminal.output_error("Invalid radius.")
return False
rad = int(args[2])
if rad < 0:
terminal.output_error("Radius cannot be negative.")
return False
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice pre-emptive checking!

Comment on lines +37 to +40
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would indent this a level so it doesnt look like args to the init directly. I did a double take to see if there was a misplace " before I realized what the intent was.

Comment on lines +21 to +30
if command_verb:
self.text += command_verb.group(1)

command_verb_span.text = command_verb.group(2)
self.append_child(command_verb_span)

command_end = text[len(command_verb.group(0)) :]
command_end_span = Element(tag_name="span")
command_end_span.text = command_end
self.append_child(command_end_span)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either in the docstring or as a comment, some more context about the approach and the intent could be helpful.

Something like: If it's a command verb then we ...

natural_width = self.image_element["naturalWidth"]
natural_height = self.image_element["naturalHeight"]
intrinsic_mouse_x = int(
((event.clientX - self.image_element["offsetLeft"]) / self.image_element["clientWidth"]) * natural_width,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small formatting thing, but I prefer this to be formatted like: ((event.ClientX - self.image_element["offsetLeft"])/self.image_element["clientWidth"])*natural_width
It's a bit easier to parse with the precedence of the operators and brings it closer into alignment with PEP8

Comment on lines +160 to +161
else:
print("Warning: TerminalGui has no Terminal instance assigned.")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be worth raising an actual warning or error for?

def set_value(self, value: str) -> None:
"""Set the value of the text input."""
self.text_input["value"] = value
command = re.search(r"^(\s*)(\S+\b)", value)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment here to help explain the intent of the regex would be helpful.

Comment on lines +109 to +112
match = re.search(rf"^(\d+){sep}(\d+){sep}(\d+)(?:{sep}(\d+))?$", color_string) or re.search(
rf"^rgba?\((\d+){sep}(\d+){sep}(\d+)(?:{sep}(\d+))?\)$",
color_string,
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would format this a bit different for easier readability, something like this so that the regexes are a bit easier to compare to see what they're doing:

match = re.search(
        rf"^(\d+){sep}(\d+){sep}(\d+)(?:{sep}(\d+))?$",
        color_string
    ) or re.search(
        rf"^rgba?\((\d+){sep}(\d+){sep}(\d+)(?:{sep}(\d+))?\)$",
        color_string,
)

return Color(int(r), int(g), int(b), a if a else 255)


colors = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these pre-defined colors shown the user via the help command at some point? If not, that would be a good improvement to make.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants