diff options
author | Tom Feist <shabble@metavore.org> | 2010-10-06 21:02:12 +0000 |
---|---|---|
committer | Tom Feist <shabble@metavore.org> | 2010-10-06 21:02:12 +0000 |
commit | 72052b70195a3f44839d1c0c54d4281c94c05162 (patch) | |
tree | 9961dae1c2135b4dafd34dc9fa106f026656ebac /prompt_info | |
parent | renamed a lot of things, it's now 'uberprompt', which can be set from within (diff) | |
download | irssi-scripts-72052b70195a3f44839d1c0c54d4281c94c05162.tar.gz irssi-scripts-72052b70195a3f44839d1c0c54d4281c94c05162.zip |
moved most of the overlay stuff out into overlays.pl for another time.
Diffstat (limited to '')
-rw-r--r-- | prompt_info/overlays.pl | 89 | ||||
-rw-r--r-- | prompt_info/prompt_replace.pl | 85 |
2 files changed, 89 insertions, 85 deletions
diff --git a/prompt_info/overlays.pl b/prompt_info/overlays.pl new file mode 100644 index 0000000..47a3eef --- /dev/null +++ b/prompt_info/overlays.pl @@ -0,0 +1,89 @@ +# temp place for dumping all the stuff that doesn't belong in uberprompt. + +# overlay := { $num1 => line1, $num2 => line2 } +# line := [ region, region, region ] +# region := { start => x, end => y, ...? } + +my $overlay; + + + +sub _add_overlay_region { + my ($line, $start, $end, $text, $len) = @_; + my $region = { start => $start, + end => $end, + text => $text, + len => $len }; + + my $o_line = $overlay->{$line}; + + unless (defined $o_line) { + $o_line = []; + $overlay->{$line} = $o_line; + } + + foreach my $cur_region (@$o_line) { + if (_region_overlaps($cur_region, $region)) { + # do something. + print "Region overlaps"; + last; + } + } + + push @$o_line, $region; + +} + +sub _remove_overlay_region { + my ($line, $start, $end) = @_; + + my $o_line = $overlay->{$line}; + return unless $o_line; + + my $i = 0; + foreach my $region (@$o_line) { + if ($region->{start} == $start && $region->{end} == $end) { + last; + } + $i++; + } + splice @$o_line, $i, 1, (); # remove it. +} + +sub _redraw_overlay { + foreach my $line_num (sort keys %$overlay) { + my $line = $overlay->{$line_num}; + + foreach my $region (@$line) { + Irssi::gui_printtext($region->{start}, $line_num, + $region->{text}); + } + } +} + +sub init { + +} +sub _clear_overlay { + Irssi::active_win->view->redraw(); +} + +sub _draw_overlay_menu { + + my $w = 10; + + my @lines = ( + '%7+' . ('-' x $w) . '+%n', + sprintf('%%7|%%n%*s%%7|%%n', $w, 'bacon'), + sprintf('|%*s|', $w, 'bacon'), + sprintf('|%*s|', $w, 'bacon'), + sprintf('|%*s|', $w, 'bacon'), + sprintf('|%*s|', $w, 'bacon'), + sprintf('|%*s|', $w, 'bacon'), + '%7+' . ('-' x $w) . '+%n', + ); + my $i = 10; # start vert offset. + for my $line (@lines) { + Irssi::gui_printtext(int ($term_w / 2), $i++, $line); + } +} diff --git a/prompt_info/prompt_replace.pl b/prompt_info/prompt_replace.pl index 3b28a05..93558de 100644 --- a/prompt_info/prompt_replace.pl +++ b/prompt_info/prompt_replace.pl @@ -31,70 +31,10 @@ my ($term_w, $term_h) = (0, 0); my ($region_start, $region_end) = (0, 0); -# overlay := { $num1 => line1, $num2 => line2 } -# line := [ region, region, region ] -# region := { start => x, end => y, ...? } - -my $overlay; my $prompt_format; my $prompt_format_str = ''; - -sub _add_overlay_region { - my ($line, $start, $end, $text, $len) = @_; - my $region = { start => $start, - end => $end, - text => $text, - len => $len }; - - my $o_line = $overlay->{$line}; - - unless (defined $o_line) { - $o_line = []; - $overlay->{$line} = $o_line; - } - - foreach my $cur_region (@$o_line) { - if (_region_overlaps($cur_region, $region)) { - # do something. - print "Region overlaps"; - last; - } - } - - push @$o_line, $region; - -} - -sub _remove_overlay_region { - my ($line, $start, $end) = @_; - - my $o_line = $overlay->{$line}; - return unless $o_line; - - my $i = 0; - foreach my $region (@$o_line) { - if ($region->{start} == $start && $region->{end} == $end) { - last; - } - $i++; - } - splice @$o_line, $i, 1, (); # remove it. -} - -sub _redraw_overlay { - foreach my $line_num (sort keys %$overlay) { - my $line = $overlay->{$line_num}; - - foreach my $region (@$line) { - Irssi::gui_printtext($region->{start}, $line_num, - $region->{text}); - } - } -} - - init(); sub update_terminal_size { @@ -281,31 +221,6 @@ sub _draw_overlay { Irssi::gui_printtext($offset, $term_h, $text); } -sub _clear_overlay { - Irssi::active_win->view->redraw(); -} - -sub _draw_overlay_menu { - - my $w = 10; - - my @lines = ( - '%7+' . ('-' x $w) . '+%n', - sprintf('%%7|%%n%*s%%7|%%n', $w, 'bacon'), - sprintf('|%*s|', $w, 'bacon'), - sprintf('|%*s|', $w, 'bacon'), - sprintf('|%*s|', $w, 'bacon'), - sprintf('|%*s|', $w, 'bacon'), - sprintf('|%*s|', $w, 'bacon'), - '%7+' . ('-' x $w) . '+%n', - ); - my $i = 10; # start vert offset. - for my $line (@lines) { - Irssi::gui_printtext(int ($term_w / 2), $i++, $line); - } -} - - sub replace_prompt_items { # remove existing ones. print "Removing original prompt" if DEBUG; |