in reply to how to call gtk3::vte::grab_text_range

I would say that this my $func = {sub => {return 1}}; should be my $func = sub { return 1 };, that's in the 2nd case.

Where is the source code of get_text_range()? You should start from there and see the whole chain of the complain it spewed. Logically, memory should be allocated in the buffer to accommodate the text which should be related to the row/col range you pass in. Are you sure they are OK?

Replies are listed 'Best First'.
Re^2: how to call gtk3::vte::grab_text_range
by hanspr (Sexton) on Sep 17, 2025 at 17:40 UTC

    Pardon me from the previous answer, you did help me a lot

    After searching for the current vte development at gitlab, found the solution

    get_text_range , is depreciated

    Using: get_text_range_format, works perfectly

    my ($string, $l) = $$self{_GUI}{_VTE}->get_text_range_format('VTE_FORM +AT_TEXT', 0, 0, 0, 20);

    Thanks a lot

Re^2: how to call gtk3::vte::grab_text_range
by hanspr (Sexton) on Sep 17, 2025 at 16:18 UTC

    Thanks for the answer

    The second case, was a test. fixing to $func = sub {return 1}, returns to the first case

    The only reason I mentioned is because, strangely it does not crash sending that parameter like that, which is weird for me

    Accessing the source code of the get_text_range(), must be in some place of the gitlab repos for gtk from the gnome project, written in C

    But in general by reading the Gtk documentation I have been able to work out everything, this is the first time I don't

    This link shows the parameters to send : https://api.gtkd.org/vte.Terminal.Terminal.getTextRange.html

    This link shows the function call : https://api.gtkd.org/vte.c.types.VteSelectionFunc.html

    This link shows the old gnome2 vte documentation : https://gtk2-perl.sourceforge.net/doc/pod/Gnome2/Vte/Terminal.html, from where I must of the basic code that I use, everything else still works

    I'm sure that I send the parameters correctly, because, I have tried a simple fixed call like this:

    # Right mouse click on VTE $$self{_GUI}{_VTE}->signal_connect( 'button_press_event' => sub { if ($right_click_deep) { return 0; # Bubble up, let VTE's original handler t +ake care of it. } my ($widget, $event) = @_; my $state = $event->get_state(); my $shift = $state * ['shift-mask']; if ($event->button eq 2) { if (!$$self{_CFG}{'environments'}{ $$self{_UUID} }{'se +nd slow'}) { return 0; } $$self{_GUI}{_VTE}->paste_primary(); $$self{FOCUS}->child_focus('GTK_DIR_TAB_FORWARD'); return 1; } elsif ($event->button eq 3 and $event->type eq 'button-p +ress') { # See #209 for all this hack. my $handled_by_vte = 0; if (!$shift) { $right_click_deep = 1; $handled_by_vte = $$self{_GUI}{_VTE}->event($eve +nt); $right_click_deep = 0; } if (!$handled_by_vte) { $$self{FOCUS}->child_focus('GTK_DIR_TAB_FORWARD'); $self->_vteMenu($event); } return 1; # One way or another, we've handled it. } elsif ($event->button eq 1 && $event->type eq 'button-pr +ess' && $shift) { my ($w, $h) = $$self{_WINDOWTERMINAL}->get_size(); my ($col, $row) = (int($event->x / $$self{_GUI}{_VTE}- +>get_char_width()), int($event->y / $$self{_GUI}{_VTE}->get_char_widt +h() - 1)); print "($col,$row)\n"; my $func = sub { return 1 }; #my $string = $$self{_GUI}{_VTE}->get_text_range($row, + $col, $row, int($w / $$self{_GUI}{_VTE}->get_char_width() + 0.5), $f +unc, my $data = undef); my $string = $$self{_GUI}{_VTE}->get_text_range(1, 0, +1, 5, $func, my $data = undef); #my @list = $$self{_GUI}{_VTE}->get_text(); #print "($row,$col):@list\n"; }

    In this case I send fixed values for row,col that I know have text in that range and still I get the error

    The other oddity of this is that this code crashes too

    my @list = $$self{_GUI}{_VTE}->get_text(); my @list = $$self{_GUI}{_VTE}->get_text($func = udef,$data = undef);

    Even when the documentation says that the 2 parameters are optional

    The other thing I'm not able to find is where is the documentation for the current Vte library is I just have this old link to use as a reference https://gtk2-perl.sourceforge.net/doc/pod/Gnome2/Vte/Terminal.html