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


In reply to how to call gtk3::vte::grab_text_range by hanspr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.