Tcl-pTk
view release on metacpan or search on metacpan
lib/Tcl/pTk/demos/widtrib/Gedi.pl view on Meta::CPAN
-geometry_manager => 'pack',
-title => 'GEDI Text Editor',
-iconname => 'GEDI',
);
$TOP->withdraw;
$text_frame = $TOP->Frame->pack
(-anchor=>'nw', -expand=>'yes', -fill => 'both'); # autosizing
$counter_frame = $TOP->Frame->pack(-anchor=>'nw');
$textwindow = $text_frame->Scrolled(
'TextEdit',
#exportselection => 'true', # 'sel' tag is associated with selections
# initial height, if it isnt 1, then autosizing fails
# once window shrinks below height
# and the line counters go off the screen.
# seems to be a problem with the Tk::pack command;
# height => 40,
-wrap=> 'none',
-setgrid => 'true', # use this for autosizing
-scrollbars =>'se')
-> pack(-expand => 'yes' , -fill => 'both'); # autosizing
$TOP->protocol('WM_DELETE_WINDOW'=>
sub{$textwindow->ConfirmExit;}
);
$SIG{INT} = sub {$textwindow->ConfirmExit;};
$current_line_label = $counter_frame
-> Label(-text=>'line: 1')
-> grid(-row=>1,-column=>1, -sticky=>'nw' );
$total_line_label = $counter_frame
-> Label(-text=>'total lines: 1')
-> grid(-row=>2,-column=>1, -sticky=>'nw' );
$current_column_label = $counter_frame
-> Label(-text=>'column: 0')
-> grid(-row=>3,-column=>1, -sticky=>'nw' );
$insert_overstrike_mode_label = $counter_frame
-> Label(-text=>' ')
-> grid(-row=>5,-column=>1, -sticky=>'nw' );
$textwindow->SetGUICallbacks (
[
\&update_indicators,
sub{$textwindow->HighlightAllPairsBracketingCursor}
]
);
$menu = $textwindow->menu;
$TOP->configure(-menu => $menu);
$help_menu = $menu->cascade(-label=>'~Help', -tearoff => 0, -menuitems => [
[Command => 'A~bout', -command => \&about_pop_up]
]);
#$TOP->minsize(30,1);
#$TOP->geometry("80x24");
while(<DATA>)
{$textwindow->insert('insert',$_);}
$textwindow->ResetUndo;
$textwindow->CallNextGUICallback;
# adjust height
$TOP->update;
# Tcl::pTk doesn't support the wrapper method, so we comment this out
#my $menuheight = ($TOP->wrapper)[1];
#my $TOPheight = 30 + $TOP->reqheight + $menuheight;
#if ($TOP->screenheight < $TOPheight) {
# $textwindow->GeometryRequest($textwindow->reqwidth, $textwindow->reqheight - ($TOPheight - $TOP->screenheight));
#}
$TOP->deiconify;
}
__DATA__
Tk800.015 contains many modifications to the
text based modules, as well as new text modules
and an application that uses them all.
Text.pm, TextUndo.pm, TextEdit.pm, and gedi
have all been updated since the release prior
to Tk800.015.
This demo contains a rundown of all the features
of the text modules, and
What is available in the text modules?
================================================
Text.pm
========
Text.pm is the base text editing module.
Beyond the core functionality of typing text,
Text.pm has built in menu support for basic
editing features such as Find/Replace text,
Copy/Cut/Paste, Goto Line Number, and What
Line Number queries.
These functions are available simply by right
clicking the mouse over the text area. Doing
so will cause a pop-up menu to appear which will
contain cascading menus to give access to all of
these new functions.
Many of these functions will create their own
pop-up windows. Find/Replace will create a pop-up
( run in 0.855 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )