{ my ($line, $char); BEGIN { ($line, $char) = (1, 0) } sub text_show { my ($text, $str) = @_; if (0 == index $str, "\r") { $str = substr $str, 1; $text->delete("$line.0", "$line.$char"); $char = 0; } $text->insert("$line.$char" => $str); if (-1 < index $str, "\n") { $line += $str =~ y/\n//; $char = length(substr $str, rindex $str, "\n") - 1; } else { $char += length $str; } $text->see("$line.$char"); } }