问题
Any one know how i can create a text area which displays lines of text which can not be edited but allows you to edit the bottom most line for text.
basically in a similar fashion to embedded consoles inside applications that allow you to run code direct on the application.
currently using a textview i can go and edit the code above and the output response are also editable.
回答1:
It's possible using a GtkTextView
, but not trivial. You have to create a tag that makes the text uneditable, and apply it from the beginning of the buffer to just before the end position. Then when you receive and process input, extend or re-apply the tag to cover that line of input and your program's response to it.
Here's an example of it being done:
- creating the tag
- applying the tag
来源:https://stackoverflow.com/questions/19242200/how-can-i-create-a-textarea-that-has-read-and-write-lines-using-gtk