## # # $Author: alex $ # $Revision: 1.34 $ # $Log: SuperText.pm,v $ # Revision 1.34 2001/01/17 17:35:51 alex # TextANSIColor.pm cool support and bug fixes by Jim Turner # # Revision 1.33 1999/07/11 09:43:51 alex # Fixed "\" matching char bug # # Revision 1.32 1999/07/11 09:40:01 alex # Fixed Win32 BackSpace bug thanks to Jim Turner # # Revision 1.31 1999/03/07 23:04:13 alex # Fixed Tk 800 core dump # # Revision 1.30 1999/02/19 17:12:06 alex # Unfixed Tk 800,mouse selection doesn't work # # Revision 1.29 1999/02/19 16:06:48 alex # Fixed use Tk 800 # # Revision 1.28 1999/02/19 13:14:07 alex # Fixed backward matching char search # # Revision 1.27 1999/02/18 23:48:59 alex # catched cut/copy/paste methods # # Revision 1.26 1999/02/18 20:55:08 alex # Speedup for matching and shifting # # Revision 1.25 1999/02/18 20:53:26 alex # Speedup for matching and shifting # # Revision 1.24 1999/02/13 20:32:40 alex # FIXME: block operations are slow!!!! # # Revision 1.10 1999/02/11 18:22:02 alex # Removed Stupid typo error # # Revision 1.9 1999/02/11 10:52:44 alex # Changed DefaultEvent to return e reference to a hash # # Revision 1.8 1999/02/10 16:59:25 alex # *** Empty log message *** # # Revision 1.7 1999/02/09 23:20:27 alex # Selection Scroll bux fixed # # Revision 1.6 1999/02/09 22:22:52 alex # added public methods,jumpToMatchingChar,fixed '-foreground' bug # # Revision 1.5 1999/02/09 16:28:53 alex # made virtual events associated methods public,removed some block und # # Revision 1.4 1999/02/05 13:54:29 alex # catch some errors on undo/redo pop # # Revision 1.3 1999/02/05 13:32:44 alex # Fixed undo/redo blocks # # Revision 1.2 1999/02/04 11:25:46 alex # First stable version # # Revision 1.1 1999/01/24 11:09:31 alex # Initial revision # ## package Tk::Text::SuperText; use AutoLoader; use Exporter (); use Tk qw(800 Ev); require Tk::Text; require Tk::Derived; #+20010117 JWT TextANSIColor support my $ansicolor = 0; eval 'use Term::ANSIColor; 1' or $ansicolor = -1; #+ use Carp; use strict; use vars qw($VERSION @ISA @EXPORT); @EXPORT = qw( mouseSetInsert mouseSelect mouseSelectWord mouseSelectLine mouseSelectAdd mouseSelectChar mouseSelectAddWord mouseSelectAddLine mouseSelectAutoScan mouseSelectAutoScanStop mouseMoveInsert mouseRectSelection mouseMovePageTo mouseMovePage mousePasteSelection moveLeft selectLeft selectRectLeft moveLeftWord selectLeftWord moveRight selectRight selectRectRight moveRightWord selectRightWord moveUp selectUp selectRectUp moveUpParagraph selectUpParagraph moveDown selectDown selectRectDown moveDownParagraph selectDownParagraph moveLineStart selectToLineStart moveTextStart selectToTextStart moveLineEnd selectToLineEnd moveTextEnd selectToTextEnd movePageUp selectToPageUp movePageLeft movePageDown selectToPageDown movePageRight setSelectionMark selectToMark selectAll selectionShiftLeft selectionShiftLeftTab selectionShiftRight selectionShiftRightTab ins enter autoIndentEnter noAutoIndentEnter del backSpace deleteToWordStart deleteToWordEnd deleteToLineStart deleteToLineEnd deleteWord deleteLine insertControlCode focusNext focusPrev flashMatchingChar removeMatch findMatchingChar jumpToMatchingChar escape tab leftTab copy cut paste inlinePaste undo redo destroy keyPress menuSelect noOP ); $VERSION = '0.9.4'; @ISA = qw(Tk::Derived Tk::Text Exporter); use base qw(Tk::Text); Construct Tk::Widget 'SuperText'; my (%fgcolors, %bgcolors, $clear, $code_bold, $code_uline, @colors); #+20010117 JWT TextANSIColor support unless ($ansicolor == -1) { $clear = color('clear'); # Code to reset control codes $code_bold = color('bold'); $code_uline= color('underline'); @colors = qw/black red green yellow blue magenta cyan white/; for (@colors) { my $fg = color($_); my $bg = color("on_$_"); $fgcolors{$fg} = "ANSIfg$_"; $bgcolors{$bg} = "ANSIbg$_"; } } #+ # returns an hash with the default events and key binds sub DefaultEvents { my (%events); %events = ( 'MouseSetInsert' => ['<1>'], 'MouseSelect' => [''], 'MouseSelectWord' => [''], 'MouseSelectLine' => [''], 'MouseSelectChar' => [''], #ADDED 1999/07 by JWT TO CAUSE RIGHT BUTTON TO EXTEND SELECT! 'MouseSelectAdd' => [''], 'MouseSelectAddWord' => [''], 'MouseSelectAddLine' => [''], 'MouseSelectAutoScan' => [''], 'MouseSelectAutoScanStop' => ['',''], 'MouseMoveInsert' => [''], 'MouseRectSelection' => [''], 'MouseMovePageTo' => ['<2>'], 'MouseMovePage' => [''], 'MousePasteSelection' => [''], 'MoveLeft' => [''], 'SelectLeft' => [''], 'SelectRectLeft' => [''], 'MoveLeftWord' => [''], 'SelectLeftWord' => [''], 'MoveRight' => [''], 'SelectRight' => [''], 'SelectRectRight' => [''], 'MoveRightWord' => [''], 'SelectRightWord' => [''], 'MoveUp' => [''], 'SelectUp' => [''], 'SelectRectUp' => [''], 'MoveUpParagraph' => [''], 'SelectUpParagraph' => [''], 'MoveDown' => [''], 'SelectDown' => [''], 'SelectRectDown' => [''], 'MoveDownParagraph' => [''], 'SelectDownParagraph' => [''], 'MoveLineStart' => [''], 'SelectToLineStart' => [''], 'MoveTextStart' => [''], 'SelectToTextStart' => [''], 'MoveLineEnd' => [''], 'SelectToLineEnd' => [''], 'MoveTextEnd' => [''], 'SelectToTextEnd' => [''], 'MovePageUp' => [''], 'SelectToPageUp' => [''], 'MovePageLeft' => [''], 'MovePageDown' => [''], 'SelectToPageDown' => [''], 'MovePageRight' => [''], 'SetSelectionMark' => ['','