Shellminator V3.0.1
Simple Terminal
|
Modern terminals come with a super useful feature that helps guide your eyes while typing or debugging—colorization! Since we find this feature incredibly helpful, we designed Shellminator in a way that allows you to easily attach different colorization solutions to it.
The easiest way to try this out is by enabling our pre-made colorizer, which is compatible with Commander-style syntax. To do this, simply create an instance of the CommanderColorizer
object like this:
Next, you need to tell your shell object to use this colorizer whenever you type a character. You can do that with the attachColorizer
method:
And that’s it! Now, try typing this command in the demo below:
This command doesn’t do anything particularly useful, but you’ll notice that your input is nicely colorized as you type. The colorizer also helps catch syntax errors! For example, try typing:
Oops! The colorizer highlights this mistake with a red background because spaces are not allowed after --
.
Everyone has different tastes, and maybe these colors don’t quite fit your preferences. That’s totally fine—everyone sees things differently! But this raises an interesting question: Can we create our own custom colorizer?
The answer is yes, of course! However, we should mention upfront that if you're new to C++, this challenge might not be the smoothest ride. But don’t worry—we’ll leave you with some tips and guidance to help you along the way.
Every Colorizer is built upon the base class DefaultColorizer. To create your own custom colorizer, you’ll need to inherit from this base class—just like we did with CommanderColorizer.
If you want to see how it works, feel free to check out the source code in Shellminator-Commander-Interface.hpp, where you’ll find its full implementation.