Curses:...rchable(3)
π NAME π
okay so bestie, welcome to the Curses:...rchable(3) page from User Contributed Perl Documentation π
. This module is Curses::UI::Searchable β it adds less-like search abilities to a widget. Slay, honestly β¨.
π¦ CLASS HIERARCHY π¦
Curses::UI::Searchable β base class π
πΈ SYNOPSIS πΈ
package MyWidget;
use Curses::UI::Searchable;
use vars qw(@ISA);
@ISA = qw(Curses::UI::Searchable);
....
sub new () {
# Create class instance $this.
....
$this->set_routine('search-forward', \&search_forward);
$this->set_binding('search-forward', '/');
$this->set_routine('search-backward', \&search_backward);
$this->set_binding('search-backward', '?');
}
sub layout_content() {
my $this = shift;
# Layout your widget's content.
....
return $this;
}
sub number_of_lines() {
my $this = shift;
# Return the number of lines in
# the widget's content.
return ....
}
sub getline_at_ypos($;) {
my $this = shift;
my $ypos = shift;
# Return the content on the line
# where ypos = $ypos
return ....
}
β¨ DESCRIPTION β¨
Using Curses::UI::Searchable, you can add less-like search capabilities to your widget. It's giving search mode, but make it cursed and cute π₯.
To make your widget searchable using this class, your widget should meet the following requirements:
- make it a descendant of
Curses::UI::Searchableβ all methods for searching are inCurses::UI::Searchable. By making your class a descendant of this class, these methods are automatically inherited. no cap π. -yposdata member β the current vertical position in the widget should be identified by$this->{-ypos}. This y-position is the index of the line of content. Here's an example for a Listbox widget, bestie:
-ypos
|
v
+------+
0 |One |
1 |Two |
2 |Three |
+------+
- method:
number_of_lines ( )β your widget class should have a methodnumber_of_lines, which returns the total number of lines in the widget's content. So in the example above, this method would return the value3. periodt π . - method:
getline_at_ypos ( YPOS )β your widget class should have a methodgetline_at_ypos, which returns the line of content at-yposYPOS. So in the example above, this method would return the value"Two"forYPOS = 1. iconic π. - method:
layout_content ( )β the search routines will set the-yposof your widget if a match is found for the given search string. Yourlayout_contentroutine should make sure that the line of content at-yposwill be made visible if thedrawmethod is called. don't leave your match off-screen, that's not main character energy π. - method:
draw ( )β if the search routines find a match,$this->{-search_highlight}will be set to the-yposfor the line on which the match was found. If no match was found$this->{-search_highlight}will be undefined. If you want a matching line to be highlighted, in your widget, you can use this data member to do so (an example of a widget that uses this option is theCurses::UI::TextViewerwidget). highlight it like the star it is β. - bindings for searchroutines β there are two search routines. These are
search_forwardandsearch_backward. These have to be called in order to display the search prompt. The best way to do this is by creating bindings for them. Here's an example which will make'/'a forward search and'?'a backward search:
$this->set_routine('search-forward' , \&search_forward);
$this->set_binding('search-forward' , '/');
$this->set_routine('search-backward' , \&search_backward);
$this->set_binding('search-backward' , '?');
π SEE ALSO π
Curses::UI,
π AUTHOR π
Copyright (c) 2001-2002 Maurice Makaay. All rights reserved.
Maintained by Marcus Thiesen (marcus@cpan.thiesenweb.de)
This package is free software and is provided "as is" without express or implied warranty. It may be used, redistributed and/or modified under the same terms as perl itself.
mwah π that's the whole page, bestie! this one is from perl v5.42.2, dated 2023-07-03, and the manual name is Curses:...rchable(3). bye π«ΆπΈ
π¦ where this page comes from
- alpine 3.24: perl-curses-ui-doc 0.9609-r3 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms