aboutsummaryrefslogtreecommitdiffstats
path: root/feature-tests/augment_inputline.pl
diff options
context:
space:
mode:
authorTom Feist <shabble@metavore.org>2010-10-14 20:42:31 +0000
committerTom Feist <shabble@metavore.org>2010-10-14 20:42:31 +0000
commit91585163e7f7cd886b2bce4c98dbc3d14b9d3c2e (patch)
treead714832c76eb1c72537db47c1a309261d2385ab /feature-tests/augment_inputline.pl
parentuberprompt: removed dead code from startup func. (diff)
downloadirssi-scripts-91585163e7f7cd886b2bce4c98dbc3d14b9d3c2e.tar.gz
irssi-scripts-91585163e7f7cd886b2bce4c98dbc3d14b9d3c2e.zip
misc: tidying up my working dir
Diffstat (limited to 'feature-tests/augment_inputline.pl')
-rw-r--r--feature-tests/augment_inputline.pl69
1 files changed, 69 insertions, 0 deletions
diff --git a/feature-tests/augment_inputline.pl b/feature-tests/augment_inputline.pl
new file mode 100644
index 0000000..577f756
--- /dev/null
+++ b/feature-tests/augment_inputline.pl
@@ -0,0 +1,69 @@
+use strict;
+use Irssi;
+use Irssi::TextUI; # for sbar_items_redraw
+use Term::Size;
+
+use vars qw($VERSION %IRSSI);
+$VERSION = "1.0.1";
+%IRSSI = (
+ authors => "shabble",
+ contact => 'shabble+irssi@metavore.org, shabble@#irssi/Freenode',
+ name => "",
+ description => "",
+ license => "Public Domain",
+ changed => ""
+);
+
+
+my $buf = '';
+
+Irssi::command_bind('dogui', \&print_to_input);
+Irssi::signal_add_last('gui key pressed', \&key_pressed);
+
+sub stuff {
+ my $win = Irssi::active_win;
+ my ($w, $h);
+ $w = $win->{width};
+ $h = $win->{height};
+
+ my ($term_w, $term_h) = Term::Size::chars *STDOUT{IO};
+ print "win size is $w,$h, term is $term_w, $term_h";
+ print "Prompt len is: ", Irssi::format_get_length("{prompt foo bar}");
+}
+
+sub key_pressed {
+ my ($key) = @_;
+ my $char = chr($key);
+ $buf .= $char;
+ my $str = Irssi::parse_special('$L');
+
+ print_to_input($str);
+
+}
+
+sub print_to_input {
+ my ($str) = @_;
+ $str = "%8$str%8";
+
+ my ($term_w, $term_h) = Term::Size::chars *STDOUT{IO};
+
+ my $prompt_offset = 11;
+ my $theme = Irssi::current_theme();
+ my $prompt = $theme->format_expand('{prompt $itemname $winname}',
+ Irssi::EXPAND_FLAG_RECURSIVE_MASK);
+ #print "Prompt is $prompt";
+ Irssi::gui_printtext($prompt_offset, $term_h, $str);
+}
+
+
+sub parse_theme_file {
+ my ($file) = @_;
+ open my $fh, '<', $file or die "Couldn't open $file for reading: $!";
+ while (my $line = <$fh>) {
+ next if $line =~ m/^\s*#/; # comment
+ if ($line =~ m/^\s*prompt\s*=\s*"([^"]+)";\s*$/) {
+ my $prompt = $1;
+ }
+ }
+ close $fh or die "Couldn't close fh for $file: $!";
+}