#!/bin/perl5 use strict; use warnings; use Tk; my $mw = MainWindow->new(-title => 'bullets'); my $t = $mw->Text->pack; { local $/ = undef; $t->insert('1.0', ); } $t->tagConfigure( 'bullets', -lmargin1 => '30', -lmargin2 => '61', ); $mw->Button(-text => 'bullet', -command => \&bullets)->pack; MainLoop; sub bullets{ unless ($t->tagRanges('sel')){ print "Can't apply bullets - no text selected\n"; return; } my $first_index = $t->index('sel.first'); my $last_index = $t->index('sel.last'); my $first_line = line_number($first_index); my $last_line = line_number($last_index); $t->unselectAll; for my $line ($first_line..$last_line){ $t->GotoLineNumber($line); $t->insert("$line.0", "* "); } $t->tagAdd('bullets', "$first_index linestart", "$last_index lineend"); return; } sub line_number{ my $index = shift; my ($line) = $index =~ /^(\d+)\./; return $line; } __DATA__ Twas brillig, and the slithy toves Did gyre and gimble in the wabe: All mimsy were the borogoves, And the mome raths outgrabe.