TGTextEdit Help

I’m currently making a GUI that’s utilizing a TGTextEdit widget to assist in generating some files. The details of the files aren’t really important except that what I ideally want to be able to do is be able to click some place in the TGTextEdit widget, click a button, and have that button select a chunk of text surrounding the current cursor position in the widget that starts with some unique starting text (e.g. CHUNK_START) and ends with some unique ending text (e.g. CHUNK_END). Is there any easy way to grab the selected line or neighboring lines at the current TGTextEdit position and begin parsing these for the start and end of the block that someone knows of? I’ve scanned the documentation a bit, but nothing obvious popped out at me.
Thanks in advance,
Chris

Hi Chris,

I don’t see a simple way to do what you ask for, but maybe one of the following signals can help you to implement what you need:

   virtual void Marked(Bool_t mark) { Emit("Marked(Bool_t)", mark); } // *SIGNAL*
   virtual void Clicked(const char *word) { Emit("Clicked(char *)", word); }  //*SIGNAL*
   virtual void DoubleClicked(const char *word) { Emit("DoubleClicked(char *)", word); }  //*SIGNAL*

If I have another idea I’ll let you know.

Cheers, Bertrand.

Thanks for the help Bertrand. I ended up patching together something function by moving the text edit cursor up and down from the starting position and processing each line to check for the tags. Now I need a nice way to clean up after myself, however. Any idea how to delete the current line from a TGTextEdit widget? I can use the GetText() method, and use TGText’s DelLine() function, but it doesn’t show in the the text edit (I have to highlight the region before I notice it’s missing). Is there some easy way to call a repaint() equivalent?

Hi Chris,

There is no method to remove the current line, you can only delete the selection. And to redraw (update) the TGTextEdit, the method TGTextEdit::Update() (inherited from TGTextView) should do it :wink:

Cheers,Bertrand.

Cool, thanks for that. Unfortunately, it’s not clearing the text that is below the new end of file. That is to say, I’m encountering a weird case where if I try to delete the last line, the line appears to get bumped to some unreachable buffer beyond where I can select text, and if I enter a newline, it moves the old text one line further. If I enter enough newlines to move the old unreachable text off the screen and then delete all those newlines to bring the cursor back up, the old unreachable text is gone. Not really sure what to do about that #-o

Hi Chris,

Could you post a running macro showing the problem? Then I can try to see what you do and maybe how to solve it…

Cheers, Bertrand.