@jamie@TRon, thanks for the great advice.
Due to the limitations of stringgrid (for example, one line cannot automatically replace the next line when the input is full, instead of a simple carriage return), the input interface is not only used for input, but also needs to take string data for the next operation (such as setting the font and color of each paragraph). As I am a beginner, I still do not know much about stringgrid operation. It is estimated that it will not achieve the effect you want, but thank you for the advice of 2 masters.
I want to see if there are any other options. I found that the RichViewEdit control can do this, but it is not supported on linux systems.