hanspr has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks
I'm trying to read a range of text from Vte::Terminal
There is a very old reference of Gtk2::Vte on how to call this method at :
https://gtk2-perl.sourceforge.net/doc/pod/Gnome2/Vte/Terminal.html
And this link documents the function and its parameters
https://api.gtkd.org/vte.Terminal.Terminal.getTextRange.html
My problem is that I don't understand how to create the $func parameter
I have tried this code, but it fails with fatal errors
$$self{_GUI}{_VTE} = Vte::Terminal->new(); # more code my $func = sub { return 1 }; my $string = $$self{_GUI}{_VTE}->get_text_range($row, $col, $row, $end +_col, $func, my $data = undef);
ERROR:gperl-i11n-invoke-c.c:584:_allocate_out_mem: assertion failed: (interface_info) Bail out! ERROR:gperl-i11n-invoke-c.c:584:_allocate_out_mem: assertion failed: (interface_info)
And many other variants that make even less sense, and all of them fail. Inclusive passing the undef value to the function.
For example this line does not crash, but it does not work either
my $func = {sub => {return 1}}; my $string = $$self{_GUI}{_VTE}->get_text_range($row, $col, $row, $end +_col, $func, my $data = undef);
I need to be able to grab the text from a line where the user clicks, so I can test for the existence of a url and then try to open the url on a browser.
This is for the open source project asbru on github
If you need a working code, the only option I can offer is to clone the repo at : https://github.com/asbru-cm/asbru-cm
Edit PACTerminal.pm and around line 1141 you should see the button_press_event
In the button_press_event, you can add the line to grab the text with any fixed parameters at any point when the user clicks
Thanks
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: how to call gtk3::vte::grab_text_range
by bliako (Abbot) on Sep 17, 2025 at 13:07 UTC | |
by hanspr (Sexton) on Sep 17, 2025 at 17:40 UTC | |
by hanspr (Sexton) on Sep 17, 2025 at 16:18 UTC | |
Re: how to call gtk3::vte::grab_text_range
by Anonymous Monk on Sep 21, 2025 at 01:23 UTC |