#!/usr/bin/perl use warnings; no warnings 'redefine'; use strict; #right click for menus use Tk; use Tk::TextEdit; use Tk::TextUndo; my $top = new MainWindow; my $textedit = $top->TextEdit->pack; $textedit->SetGUICallbacks([sub {}]); MainLoop; sub Tk::TextUndo::insertStringAtStartOfSelectedLines{ my ($w,$insert_string)=@_; $w->addGlobStart; my @sel_lines = $w->SelectedLineNumbers; $w->MarkSelectionsSavePositions; foreach my $line (@sel_lines){ $w->insert($line.'.0', $insert_string); } $w->RestoreSelectionsMarkedSaved; $w->addGlobEnd; } sub Tk::TextUndo::deleteStringAtStartOfSelectedLines{ my ($w,$insert_string)=@_; $w->addGlobStart; my @sel_lines = $w->SelectedLineNumbers; $w->MarkSelectionsSavePositions; my $length = length($insert_string); foreach my $line (@sel_lines){ my $start = $line.'.0'; my $end = $line.'.'.$length; my $current_text = $w->get($start, $end); next unless ($current_text eq $insert_string); $w->delete($start, $end); } $w->RestoreSelectionsMarkedSaved; $w->addGlobEnd; }
In reply to Re: Editors written in Perl
by zentara
in thread Editors written in Perl
by alexxxm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |