]> jfr.im git - irc/xchat.git/commitdiff
fix the off by one error for the displayed count
authorlsitu <redacted>
Fri, 5 Jun 2009 01:41:39 +0000 (01:41 +0000)
committerlsitu <redacted>
Fri, 5 Jun 2009 01:41:39 +0000 (01:41 +0000)
git-svn-id: svn://svn.code.sf.net/p/xchat/svn@1350 893a96be-7f27-4fdf-9d1e-6aeec9d3cce1

plugins/perl/char_count.pl

index 0605f3cc97a39d65629d23412db56d927c0b9850..2d379d537e4047a2b1acdef8dbcfbc70b5e1db3b 100644 (file)
@@ -45,18 +45,22 @@ if( $input_box ) {
        my $hbox = get_hbox( $input_box );
        if( $hbox ) {
                my $label = Gtk2::Label->new();
+               $label->set_alignment( 0.5, ($label->get_alignment)[1] );
                $hbox->pack_end( $label, 0, 0, 5 );
                $label->show();
 
                hook_print( "Key Press",
                        sub {
                                my $ctx_type = context_info->{"type"};
-                               if( $ctx_type == 2 || $ctx_type == 3 ) {
-                                       my $count = length get_info "inputbox";
-                                       $label->set_text( $count ? $count : "" );
-                               } else {
-                                       $label->set_text( "" );
-                               }
+                               hook_timer( 0, sub {
+                                       if( $ctx_type == 2 || $ctx_type == 3 ) {
+                                               my $count = length get_info "inputbox";
+                                               $label->set_text( $count ? $count : "" );
+                                       } else {
+                                               $label->set_text( "" );
+                                       }
+                                       return REMOVE;
+                               });
                                return EAT_NONE;
                        }
                );