Tk

 view release on metacpan or  search on metacpan

Change.log  view on Meta::CPAN

------------------------------------------------------------------------
r11044 | srezic | 2008-04-02 20:00:22 +0200 (Wed, 02 Apr 2008) | 3 lines

 r2042@biokovo:  eserte | 2008-03-29 16:51:16 +0100
 * added Test::More as prerequisite

------------------------------------------------------------------------
r11043 | srezic | 2008-04-02 20:00:11 +0200 (Wed, 02 Apr 2008) | 3 lines

 r2041@biokovo:  eserte | 2008-03-23 22:30:04 +0100
 * clipboardGet change

------------------------------------------------------------------------
r11042 | srezic | 2008-04-02 20:00:01 +0200 (Wed, 02 Apr 2008) | 5 lines

 r2040@biokovo:  eserte | 2008-03-23 22:29:04 +0100
 * clipboardGet was documented, but did not work (though clipboard('get')
   always worked)
 * fixed typo in clipboardGet documentation (SelectionGet, not selectionGet)

------------------------------------------------------------------------
r11041 | srezic | 2008-04-02 19:59:48 +0200 (Wed, 02 Apr 2008) | 4 lines

 r2039@biokovo:  eserte | 2008-03-12 21:48:22 +0100
 * larger intervals permitted in after test
 

------------------------------------------------------------------------
r11040 | srezic | 2008-04-02 19:59:36 +0200 (Wed, 02 Apr 2008) | 4 lines

Change.log  view on Meta::CPAN

r10722 | srezic | 2008-02-11 23:18:42 +0100 (Mon, 11 Feb 2008) | 4 lines

 r2017@biokovo-amd64:  eserte | 2008-02-11 23:18:20 +0100
 * bindDump support for Canvas (http://rt.cpan.org/Ticket/Display.html?id=33064)
 * new test t/bind.t

------------------------------------------------------------------------
r10721 | srezic | 2008-02-11 23:18:29 +0100 (Mon, 11 Feb 2008) | 4 lines

 r2016@biokovo-amd64:  eserte | 2008-02-10 23:57:34 +0100
 * clipboard selection example is possibly flawed
 

------------------------------------------------------------------------
r10716 | srezic | 2008-02-10 21:51:00 +0100 (Sun, 10 Feb 2008) | 4 lines

 r2014@biokovo-amd64:  eserte | 2008-02-10 21:50:47 +0100
 * more for 804.029
 

------------------------------------------------------------------------

Changes  view on Meta::CPAN

 http://rt.cpan.org/Public/Bug/Display.html?id=31989

 Added different location of rgb.txt on Mac OS X 10.5.1 systems

 Fixed a makedepend issue, reported by marek.rouchal

 A BusyRecurse issue [rt.cpan.org #32858]

 Fixed Tk::ColorEditor problem with OpenBSD (another rgb.txt location)

 clipboardGet was documented, but did not work (note that clipboard("get")
 always worked)

 Tk::After::Cancelled needs also a dummy cancel() method

 Fixed event handling for newer X servers
 http://rt.cpan.org/Public/Bug/Display.html?id=38746

 Permission issue [rt.cpan.org #39038]

 Support for changed regexp-related functions and structures in perl

DragDrop/Win32Site/Win32Site.pm  view on Meta::CPAN

 # print join(',',@_),"\n";
 my ($w,$site,$msg,$wParam,$lParam) = @_;
 my ($x,$y,@files) = DropInfo($wParam);
 my $cb = $site->{'-dropcommand'};
 $site->Apply(-entercommand => $x, $y, 1);
 if ($cb)
  {
   foreach my $file (@files)
    {
     # print "$file @ $x,$y\n";
     $w->clipboardClear;
     $w->clipboardAppend('--',$file);
     $cb->Call('CLIPBOARD',Win32Drop => ['STRING'],$x,$y);
    }
  }
 $site->Apply(-entercommand => $x, $y, 0);
 return 0;
}

1;
__END__

Entry/Entry.pm  view on Meta::CPAN

 $mw->bind($class,'<BackSpace>','Backspace');

 $mw->bind($class,'<Control-space>',['selectionFrom','insert']);
 $mw->bind($class,'<Select>',['selectionFrom','insert']);
 $mw->bind($class,'<Control-Shift-space>',['selectionAdjust','insert']);
 $mw->bind($class,'<Shift-Select>',['selectionAdjust','insert']);

 $mw->bind($class,'<Control-slash>',['selectionRange',0,'end']);
 $mw->bind($class,'<Control-backslash>','selectionClear');

 # $class->clipboardOperations($mw,qw[Copy Cut Paste]);

 $mw->bind($class,'<KeyPress>', ['Insert',Ev('A')]);

 # Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
 # Otherwise, if a widget binding for one of these is defined, the
 # <KeyPress> class binding will also fire and insert the character,
 # which is wrong.  Ditto for Return, and Tab.

 $mw->bind($class,'<Alt-KeyPress>' ,'NoOp');
 $mw->bind($class,'<Meta-KeyPress>' ,'NoOp');

Listbox/Listbox.pm  view on Meta::CPAN

 $mw->bind($class,'<Control-Prior>', ['xview', 'scroll', -1, 'pages']);
 $mw->bind($class,'<Control-Next>',  ['xview', 'scroll',  1, 'pages']);
 # <Home> and <End> defined in XscrollBind
 $mw->bind($class,'<Control-Home>','Cntrl_Home');
 ;
 $mw->bind($class,'<Shift-Control-Home>',['DataExtend',0]);
 $mw->bind($class,'<Control-End>','Cntrl_End');
 ;
 $mw->bind($class,'<Shift-Control-End>',['DataExtend','end']);
 # XXX What about <<Copy>>? Already handled in Tk::Clipboard?
 # $class->clipboardOperations($mw,'Copy');
 $mw->bind($class,'<space>',['BeginSelect',Ev('index','active')]);
 $mw->bind($class,'<Select>',['BeginSelect',Ev('index','active')]);
 $mw->bind($class,'<Control-Shift-space>',['BeginExtend',Ev('index','active')]);
 $mw->bind($class,'<Shift-Select>',['BeginExtend',Ev('index','active')]);
 $mw->bind($class,'<Escape>','Cancel');
 $mw->bind($class,'<Control-slash>','SelectAll');
 $mw->bind($class,'<Control-backslash>','Cntrl_backslash');
 ;
 # Additional Tk bindings that aren't part of the Motif look and feel:
 $mw->bind($class,'<2>',['scan','mark',Ev('x'),Ev('y')]);

Listbox/Listbox.pm  view on Meta::CPAN

sub deleteSelected
{
 my $w = shift;
 my $i;
 foreach $i (reverse $w->curselection)
  {
   $w->delete($i);
  }
}

sub clipboardPaste
{
 my $w = shift;
 my $index = $w->index('active') || $w->index($w->XEvent->xy);
 my $str;
 eval {local $SIG{__DIE__}; $str = $w->clipboardGet };
 return if $@;
 foreach (split("\n",$str))
  {
   $w->insert($index++,$_);
  }
}

sub getSelected
{
 my ($w) = @_;

README.cygwin  view on Meta::CPAN

        + Motif look and feel
        + Scroll wheel does not work with X11 (config?)
        + Global grabs only affect X11 windows (config?)
        + Menus, normal style
          - Alt+x does not post menus (config?)
        + $Tk::platform => unix

    Win32

        + Windows look and feel
        + Uses Win32 clipboard
        + Help on menu bar not all the way to the right
        + Tear-off menus placed at upper-left instead of near pointer
        + Tile and Transparent, no tiled camels, third window not
          transparent
        + Menus, normal style
          - File - "Error: unknown option "-label" at Tk.pm line 217
        + Menus, Perl/Tk style
          - Menus do not drop as traverse with button press
          - Alt+x does not post menus
        + Native Win32 FileSelect dialog, FileSelect/FBox the same

Text/Text.pm  view on Meta::CPAN

 $class->bindRdOnly($mw);

 $mw->bind($class,'<Tab>', 'insertTab');
 $mw->bind($class,'<Control-i>', ['Insert',"\t"]);
 $mw->bind($class,'<Return>', ['Insert',"\n"]);
 $mw->bind($class,'<Delete>','Delete');
 $mw->bind($class,'<BackSpace>','Backspace');
 $mw->bind($class,'<Insert>', \&ToggleInsertMode ) ;
 $mw->bind($class,'<KeyPress>',['InsertKeypress',Ev('A')]);

 $mw->bind($class,'<F1>', 'clipboardColumnCopy');
 $mw->bind($class,'<F2>', 'clipboardColumnCut');
 $mw->bind($class,'<F3>', 'clipboardColumnPaste');

 # Additional emacs-like bindings:

 if (!$Tk::strictMotif)
  {
   $mw->bind($class,'<Control-d>',['delete','insert']);
   $mw->bind($class,'<Control-k>','deleteToEndofLine') ;
   $mw->bind($class,'<Control-o>','openLine');
   $mw->bind($class,'<Control-t>','Transpose');
   $mw->bind($class,'<Meta-d>',['delete','insert','insert wordend']);

Text/Text.pm  view on Meta::CPAN

  $find_entry->bind("<Return>" => [$button_find, 'invoke']);
  $find_entry->bind("<Escape>" => [$button_cancel, 'invoke']);

 $find_entry->bind("<Return>" => [$button_find, 'invoke']);
 $find_entry->bind("<Escape>" => [$button_cancel, 'invoke']);

 $pop->resizable('yes','no');
 return $pop;
}

# paste clipboard into current location
sub clipboardPaste
{
 my ($w) = @_;
 local $@;
 Tk::catch { $w->Insert($w->clipboardGet) };
}

########################################################################
# Insert --
# Insert a string into a text at the point of the insertion cursor.
# If there is a selection in the text, and it covers the point of the
# insertion cursor, then delete the selection before inserting.
#
# Arguments:
# w - The text window in which to insert the string

Text/Text.pm  view on Meta::CPAN

    ['command'=>'~Replace',       -command => [$w => 'FindAndReplacePopUp']]
   ];
}

sub EditMenuItems
{
 my ($w) = @_;
 my @items = ();
 foreach my $op ($w->clipEvents)
  {
   push(@items,['command' => "~$op", -command => [ $w => "clipboard$op"]]);
  }
 push(@items,
    '-',
    ['command'=>'Select All', -command   => [$w => 'selectAll']],
    ['command'=>'Unselect All', -command => [$w => 'unselectAll']],
  );
 return \@items;
}

sub ViewMenuItems

Text/Text.pm  view on Meta::CPAN

    ['command'=>'~Which Line?',  -command =>  [$w => 'WhatLineNumberPopUp']],
    ['cascade'=> 'Wrap', -tearoff => 0, -menuitems => [
      [radiobutton => 'Word', -variable => \$v, -value => 'word'],
      [radiobutton => 'Character', -variable => \$v, -value => 'char'],
      [radiobutton => 'None', -variable => \$v, -value => 'none'],
    ]],
  ];
}

########################################################################
sub clipboardColumnCopy
{
 my ($w) = @_;
 $w->Column_Copy_or_Cut(0);
}

sub clipboardColumnCut
{
 my ($w) = @_;
 $w->Column_Copy_or_Cut(1);
}

########################################################################
sub Column_Copy_or_Cut
{
 my ($w, $cut) = @_;
 my @ranges = $w->tagRanges('sel');

Text/Text.pm  view on Meta::CPAN

 $string = $w->get($end_line.'.0', $end_line.'.0 lineend');
 $string = substr($string, 0, $end_column);
 $string = expand($string);
 my $tab_end_column = length($string);

 my $length = $tab_end_column - $tab_start_column;

 $selection_start_index = $start_line . '.' . $tab_start_column;
 $selection_end_index   = $end_line   . '.' . $tab_end_column;

 # clear the clipboard
 $w->clipboardClear;
 my ($clipstring, $startstring, $endstring);
 my $padded_string = ' 'x$tab_end_column;
 for(my $line = $start_line; $line <= $end_line; $line++)
  {
  $string = $w->get($line.'.0', $line.'.0 lineend');
  $string = expand($string) . $padded_string;
  $clipstring = substr($string, $tab_start_column, $length);
  #$clipstring = unexpand($clipstring);
  $w->clipboardAppend($clipstring."\n");

  if ($cut)
   {
   $startstring = substr($string, 0, $tab_start_column);
   $startstring = unexpand($startstring);
   $start_column = length($startstring);

   $endstring = substr($string, 0, $tab_end_column );
   $endstring = unexpand($endstring);
   $end_column = length($endstring);

   $w->delete($line.'.'.$start_column,  $line.'.'.$end_column);
   }
  }
}

########################################################################

sub clipboardColumnPaste
{
 my ($w) = @_;
 my @ranges = $w->tagRanges('sel');
 my $range_total = @ranges;
 if ($range_total)
  {
  warn " there cannot be any selections during clipboardColumnPaste. \n";
  $w->bell;
  return;
  }

 my $clipboard_text;
 eval
  {
  $clipboard_text = $w->SelectionGet(-selection => "CLIPBOARD");
  };

 return unless (defined($clipboard_text));
 return unless (length($clipboard_text));
 my $string;

 my $current_index = $w->index('insert');
 my ($current_line, $current_column) = split(/\./,$current_index);
 $string = $w->get($current_line.'.0', $current_line.'.'.$current_column);
 $string = expand($string);
 $current_column = length($string);

 my @clipboard_lines = split(/\n/,$clipboard_text);
 my $length;
 my $end_index;
 my ($delete_start_column, $delete_end_column, $insert_column_index);
 foreach my $line (@clipboard_lines)
  {
  if ($w->OverstrikeMode)
   {
   #figure out start and end indexes to delete, compensating for tabs.
   $string = $w->get($current_line.'.0', $current_line.'.0 lineend');
   $string = expand($string);
   $string = substr($string, 0, $current_column);
   $string = unexpand($string);
   $delete_start_column = length($string);

TextList/TextList.pm  view on Meta::CPAN


 $mw->XscrollBind($class);
 $mw->PriorNextBind($class);

 $mw->bind($class,'<Control-Home>','Cntrl_Home');

 $mw->bind($class,'<Shift-Control-Home>',['DataExtend',0]);
 $mw->bind($class,'<Control-End>','Cntrl_End');

 $mw->bind($class,'<Shift-Control-End>',['DataExtend','end']);
 $class->clipboardOperations($mw,'Copy');
 $mw->bind($class,'<space>',['BeginSelect',Ev('index','active')]);
 $mw->bind($class,'<Select>',['BeginSelect',Ev('index','active')]);
 $mw->bind($class,'<Control-Shift-space>',['BeginExtend',Ev('index','active')]);
 $mw->bind($class,'<Shift-Select>',['BeginExtend',Ev('index','active')]);
 $mw->bind($class,'<Escape>','Cancel');
 $mw->bind($class,'<Control-slash>','SelectAll');
 $mw->bind($class,'<Control-backslash>','Cntrl_backslash');
 ;
 # Additional Tk bindings that aren't part of the Motif look and feel:
 $mw->bind($class,'<2>',['scan','mark',Ev('x'),Ev('y')]);

TextList/TextList.pm  view on Meta::CPAN

sub deleteSelected
{
 my $w = shift;
 my $i;
 foreach $i (reverse $w->curselection)
  {
   $w->delete($i);
  }
}

sub clipboardPaste
{
 my $w = shift;
 my $element = $w->index('active') || $w->index($w->XEvent->xy);
 my $str;
 eval {local $SIG{__DIE__}; $str = $w->clipboardGet };
 return if $@;
 foreach (split("\n",$str))
  {
   $w->insert($element++,$_);
  }
}

sub getSelected
{
 my ($w) = @_;

Tk.pm  view on Meta::CPAN


bootstrap Tk;

my $boot_time = timeofday();

# This is a workround for Solaris X11 locale handling
Preload(DynaLoader::dl_findfile('-L/usr/openwin/lib','-lX11'))
  if (NeedPreload() && -d '/usr/openwin/lib');

use Tk::Submethods ('option'    =>  [qw(add get clear readfile)],
                    'clipboard' =>  [qw(clear append get)]
                   );

#
# Next few routines are here as perl code as doing caller()
# in XS code is very complicated - so instead C code calls BackTrace
#
sub _backTrace
{
 my $w = shift;
 my $i = 1;

Tk.pm  view on Meta::CPAN

 my $cmd    = shift;
 croak 'Use SelectionOwn/SelectionOwner' if ($cmd eq 'own');
 croak "Use Selection\u$cmd()";
}

# If we have sub Clipboard in Tk then use base qw(Tk::Clipboard ....)
# calls it when it does its eval "require $base"
#sub Clipboard
#{my $w = shift;
# my $cmd    = shift;
# croak "Use clipboard\u$cmd()";
#}

sub Receive
{
 my $w = shift;
 warn 'Receive(' . join(',',@_) .')';
 die 'Tk rejects send(' . join(',',@_) .")\n";
}

sub break

Tk/Clipboard.pm  view on Meta::CPAN

sub clipEvents
{
 return qw[Copy Cut Paste];
}

sub ClassInit
{
 my ($class,$mw) = @_;
 foreach my $op ($class->clipEvents)
  {
   $mw->Tk::bind($class,"<<$op>>","clipboard$op");
  }
 return $class;
}

sub clipboardSet
{
 my $w = shift;
 $w->clipboardClear;
 $w->clipboardAppend(@_);
}

sub clipboardCopy
{
 my $w = shift;
 my $val = $w->getSelected;
 if (defined $val)
  {
   $w->clipboardSet('--',$val);
  }
 return $val;
}

sub clipboardCut
{
 my $w = shift;
 my $val = $w->clipboardCopy;
 if (defined $val)
  {
   $w->deleteSelected;
  }
 return $val;
}

sub clipboardGet
{
 my $w = shift;
 $w->SelectionGet('-selection','CLIPBOARD',@_);
}

sub clipboardPaste
{
 my $w = shift;
 local $@;
 catch
  {
## Different from Tcl/Tk version:
#    if ($w->windowingsystem eq 'x11')
#     {
#      catch
#       {
#        $w->deleteSelected;
#       };
#     }
   $w->insert("insert", $w->clipboardGet);
   $w->SeeInsert if $w->can('SeeInsert');
  };
}

sub clipboardOperations
{
 my @class = ();
 my $mw    = shift;
 if (ref $mw)
  {
   $mw = $mw->DelegateFor('bind');
  }
 else
  {
   push(@class,$mw);
   $mw = shift;
  }
 while (@_)
  {
   my $op = shift;
   $mw->Tk::bind(@class,"<<$op>>","clipboard$op");
  }
}

# These methods work for Entry and Text
# and can be overridden where they don't work

sub deleteSelected
{
 my $w = shift;
 catch { $w->delete('sel.first','sel.last') };

Tk/ROText.pm  view on Meta::CPAN

}

sub ClassInit
{
 my ($class,$mw) = @_;
 my $val = $class->bindRdOnly($mw);
 my $cb  = $mw->bind($class,'<Next>');
 $mw->bind($class,'<space>',$cb) if (defined $cb);
 $cb  = $mw->bind($class,'<Prior>');
 $mw->bind($class,'<BackSpace>',$cb) if (defined $cb);
 $class->clipboardOperations($mw,'Copy');
 return $val;
}

sub Populate
{
 my($self,$args) = @_;
 $self->SUPER::Populate($args);
 my $m = $self->menu->entrycget($self->menu->index('Search'), '-menu');
 $m->delete($m->index('Replace'));
 $self->ConfigSpecs(-background => ['SELF'],

Tk/TextUndo.pm  view on Meta::CPAN

}

sub FindAndReplaceAll
{
 my $w = shift;
 $w->addGlobStart;
 $w->SUPER::FindAndReplaceAll(@_);
 $w->addGlobEnd;
}

sub clipboardCut
{
 my $w = shift;
 $w->addGlobStart;
 $w->SUPER::clipboardCut(@_);
 $w->addGlobEnd;
}

sub clipboardPaste
{
 my $w = shift;
 $w->addGlobStart;
 $w->SUPER::clipboardPaste(@_);
 $w->addGlobEnd;
}

sub clipboardColumnCut
{
 my $w = shift;
 $w->addGlobStart;
 $w->SUPER::clipboardColumnCut(@_);
 $w->addGlobEnd;
}

sub clipboardColumnPaste
{
 my $w = shift;
 $w->addGlobStart;
 $w->SUPER::clipboardColumnPaste(@_);
 $w->addGlobEnd;
}

# Greg: this method is more tightly coupled to the base class
# than I would prefer, but I know of no other way to do it.

sub Insert
{
 my ($w,$char)=@_;
 return if $char eq '';

Tk/Widget.pm  view on Meta::CPAN

     else
      {
       untie ${$hash->{$key}};
      }
    }
  }
}



# clipboardKeysyms --
# This procedure is invoked to identify the keys that correspond to
# the "copy", "cut", and "paste" functions for the clipboard.
#
# Arguments:
# copy - Name of the key (keysym name plus modifiers, if any,
# such as "Meta-y") used for the copy operation.
# cut - Name of the key used for the cut operation.
# paste - Name of the key used for the paste operation.
#
# This method is obsolete use clipboardOperations and abstract
# event types instead. See Clipboard.pm and Mainwindow.pm

sub clipboardKeysyms
{
 my @class = ();
 my $mw    = shift;
 if (ref $mw)
  {
   $mw = $mw->DelegateFor('bind');
  }
 else
  {
   push(@class,$mw);
   $mw = shift;
  }
 if (@_)
  {
   my $copy  = shift;
   $mw->Tk::bind(@class,"<$copy>",'clipboardCopy')   if (defined $copy);
  }
 if (@_)
  {
   my $cut   = shift;
   $mw->Tk::bind(@class,"<$cut>",'clipboardCut')     if (defined $cut);
  }
 if (@_)
  {
   my $paste = shift;
   $mw->Tk::bind(@class,"<$paste>",'clipboardPaste') if (defined $paste);
  }
}

sub pathname
{
 my ($w,$id) = @_;
 my $x = $w->winfo('pathname',-displayof  => oct($id));
 return $x->PathName;
}

TkXSUB.def  view on Meta::CPAN

MkXSUB("Tk::place", XS_Tk_place, XStoAfterSub, Tk_PlaceObjCmd)
MkXSUB("Tk::form", XS_Tk_form, XStoAfterSub, Tix_FormCmd)
MkXSUB("Tk::itemstyle", XS_Tk_itemstyle, XStoTclCmd, Tix_ItemStyleCmd)
MkXSUB("Tk::winfo", XS_Tk_winfo, XStoSubCmd, Tk_WinfoObjCmd)
MkXSUB("Tk::font", XS_Tk_font, XStoFont, Tk_FontObjCmd)
MkXSUB("Tk::wm", XS_Tk_wm, XStoAfterSub, Tk_WmObjCmd)
MkXSUB("Tk::grab", XS_Tk_grab, XStoSubCmd, Tk_GrabObjCmd)
MkXSUB("Tk::focus", XS_Tk_focus, XStoSubCmd, Tk_FocusObjCmd)
MkXSUB("Tk::event", XS_Tk_event, XStoEvent, Tk_EventObjCmd)
MkXSUB("Tk::property", XS_Tk_property, XStoSubCmd, Tk_PropertyCmd)
MkXSUB("Tk::clipboard", XS_Tk_clipboard, XStoDisplayof, Tk_ClipboardObjCmd)
MkXSUB("Tk::bell", XS_Tk_bell, XStoDisplayof, Tk_BellObjCmd)
MkXSUB("Tk::bindtags", XS_Tk_bindtags, XStoTk, Tk_BindtagsObjCmd)
MkXSUB("Tk::destroy", XS_Tk_destroy, XStoTk, Tk_DestroyObjCmd)
MkXSUB("Tk::raise", XS_Tk_raise, XStoTk, Tk_RaiseObjCmd)
MkXSUB("Tk::lower", XS_Tk_lower, XStoTk, Tk_LowerObjCmd)
MkXSUB("Tk::option", XS_Tk_option, XStoOption, Tk_OptionObjCmd)
MkXSUB("Tk::image", XS_Tk_image, XStoImage, Tk_ImageObjCmd)
MkXSUB("Tk::selection", XS_Tk_selection, XStoTk, Tk_SelectionObjCmd)

#if defined(__WIN32__) || defined(MAC_TCL)

demos/demos/widtrib/Gedi.pl  view on Meta::CPAN

features.

Insert and Overstrike modes are also supported
in the Text.pm module. Pressing the <Insert>
key will toggle modes back and forth.

Column based copy/cut/paste features are also
available in the Text.pm module. They are bound
to the following keys:

<F1> clipboardColumnCopy
<F2> clipboardColumnCut
<F3> clipboardColumnPaste

Currently, column based operations are beta versions.
They compensate for tabs, but they will not behave
properly unless the text is all the same font, and
is the same width per character.

Hopefully some future version of Text.pm will correct
for this deficiency.

Column paste should work with overstrike mode.

pTk/mTk/generic/tkBind.c  view on Meta::CPAN

 */

void
TkBindDeadWindow(winPtr)
    TkWindow *winPtr;		/* The window that is being deleted. */
{
    BindInfo *bindInfoPtr;
    PendingBinding *curPtr;

    /*
     * Certain special windows like those used for send and clipboard
     * have no mainPtr.
     */
    if (winPtr->mainPtr == NULL)
        return;

    bindInfoPtr = (BindInfo *) winPtr->mainPtr->bindInfo;
    curPtr = bindInfoPtr->pendingList;
    while (curPtr != NULL) {
	if (curPtr->tkwin == (Tk_Window) winPtr) {
	    curPtr->deleted = 1;

pTk/mTk/generic/tkClipboard.c  view on Meta::CPAN

/*
 * tkClipboard.c --
 *
 * 	This file manages the clipboard for the Tk toolkit,
 * 	maintaining a collection of data buffers that will be
 * 	supplied on demand to requesting applications.
 *
 * Copyright (c) 1994 The Regents of the University of California.
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tkClipboard.c,v 1.12 2002/08/05 04:30:38 dgp Exp $

pTk/mTk/generic/tkClipboard.c  view on Meta::CPAN

static void		ClipboardLostSel _ANSI_ARGS_((ClientData clientData));
static int		ClipboardGetProc _ANSI_ARGS_((ClientData clientData,
			    Tcl_Interp *interp, char *portion));

/*
 *----------------------------------------------------------------------
 *
 * ClipboardHandler --
 *
 *	This procedure acts as selection handler for the
 *	clipboard manager.  It extracts the required chunk of
 *	data from the buffer chain for a given selection target.
 *
 * Results:
 *	The return value is a count of the number of bytes
 *	actually stored at buffer.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------

pTk/mTk/generic/tkClipboard.c  view on Meta::CPAN

    return count;
}

/*
 *----------------------------------------------------------------------
 *
 * ClipboardAppHandler --
 *
 *	This procedure acts as selection handler for retrievals of type
 *	TK_APPLICATION.  It returns the name of the application that
 *	owns the clipboard.  Note:  we can't use the default Tk
 *	selection handler for this selection type, because the clipboard
 *	window isn't a "real" window and doesn't have the necessary
 *	information.
 *
 * Results:
 *	The return value is a count of the number of bytes
 *	actually stored at buffer.
 *
 * Side effects:
 *	None.
 *

pTk/mTk/generic/tkClipboard.c  view on Meta::CPAN

    ClientData clientData;	/* Pointer to TkDisplay structure. */
    int offset;			/* Return selection bytes starting at this
				 * offset. */
    char *buffer;		/* Place to store converted selection. */
    int maxBytes;		/* Maximum # of bytes to store at buffer. */
{
    TkDisplay *dispPtr = (TkDisplay *) clientData;
    size_t length;
    CONST char *p;

    p = dispPtr->clipboardAppPtr->winPtr->nameUid;
    length = strlen(p);
    length -= offset;
    if (length <= 0) {
	return 0;
    }
    if (length > (size_t) maxBytes) {
	length = maxBytes;
    }
    strncpy(buffer, p, length);
    return length;
}

/*
 *----------------------------------------------------------------------
 *
 * ClipboardWindowHandler --
 *
 *	This procedure acts as selection handler for retrievals of
 *	type TK_WINDOW.  Since the clipboard doesn't correspond to
 *	any particular window, we just return ".".  We can't use Tk's
 *	default handler for this selection type, because the clipboard
 *	window isn't a valid window.
 *
 * Results:
 *	The return value is 1, the number of non-null bytes stored
 *	at buffer.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------

pTk/mTk/generic/tkClipboard.c  view on Meta::CPAN

    buffer[0] = '.';
    buffer[1] = 0;
    return 1;
}

/*
 *----------------------------------------------------------------------
 *
 * ClipboardLostSel --
 *
 *	This procedure is invoked whenever clipboard ownership is
 *	claimed by another window.  It just sets a flag so that we
 *	know the clipboard was taken away.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	The clipboard is marked as inactive.
 *
 *----------------------------------------------------------------------
 */

static void
ClipboardLostSel(clientData)
    ClientData clientData;		/* Pointer to TkDisplay structure. */
{
    TkDisplay *dispPtr = (TkDisplay*) clientData;

    dispPtr->clipboardActive = 0;
}

/*
 *----------------------------------------------------------------------
 *
 * Tk_ClipboardClear --
 *
 *	Take control of the clipboard and clear out the previous
 *	contents.  This procedure must be invoked before any
 *	calls to Tk_ClipboardAppend.
 *
 * Results:
 *	A standard Tcl result.  If an error occurs, an error message is
 *	left in the interp's result.
 *
 * Side effects:
 *	From now on, requests for the CLIPBOARD selection will be
 *	directed to the clipboard manager routines associated with
 *	clipWindow for the display of tkwin.  In order to guarantee
 *	atomicity, no event handling should occur between
 *	Tk_ClipboardClear and the following Tk_ClipboardAppend
 *	calls.  This procedure may cause a user-defined LostSel command
 * 	to be invoked when the CLIPBOARD is claimed, so any calling
 *	function should be reentrant at the point Tk_ClipboardClear is
 *	invoked.
 *
 *----------------------------------------------------------------------
 */

int
Tk_ClipboardClear(interp, tkwin)
    Tcl_Interp *interp;		/* Interpreter to use for error reporting. */
    Tk_Window tkwin;		/* Window in application that is clearing
				 * clipboard;  identifies application and
				 * display. */
{
    TkWindow *winPtr = (TkWindow *) tkwin;
    TkDisplay *dispPtr = winPtr->dispPtr;
    TkClipboardTarget *targetPtr, *nextTargetPtr;
    TkClipboardBuffer *cbPtr, *nextCbPtr;

    if (dispPtr->clipWindow == NULL) {
	int result;

	result = TkClipInit(interp, dispPtr);
	if (result != TCL_OK) {
	    return result;
	}
    }

    /*
     * Discard any existing clipboard data and delete the selection
     * handler(s) associated with that data.
     */

    for (targetPtr = dispPtr->clipTargetPtr; targetPtr != NULL;
	    targetPtr = nextTargetPtr) {
	for (cbPtr = targetPtr->firstBufferPtr; cbPtr != NULL;
		cbPtr = nextCbPtr) {
	    ckfree(cbPtr->buffer);
	    nextCbPtr = cbPtr->nextPtr;
	    ckfree((char *) cbPtr);
	}
	nextTargetPtr = targetPtr->nextPtr;
	Tk_DeleteSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom,
		targetPtr->type);
	ckfree((char *) targetPtr);
    }
    dispPtr->clipTargetPtr = NULL;

    /*
     * Reclaim the clipboard selection if we lost it.
     */

    if (!dispPtr->clipboardActive) {
	Tk_OwnSelection(dispPtr->clipWindow, dispPtr->clipboardAtom,
		ClipboardLostSel, (ClientData) dispPtr);
	dispPtr->clipboardActive = 1;
    }
    dispPtr->clipboardAppPtr = winPtr->mainPtr;
    return TCL_OK;
}

/*
 *----------------------------------------------------------------------
 *
 * Tk_ClipboardAppend --
 *
 * 	Append a buffer of data to the clipboard.  The first buffer of
 *	a given type determines the format for that type.  Any successive
 *	appends to that type must have the same format or an error will
 *	be returned.  Tk_ClipboardClear must be called before a sequence
 *	of Tk_ClipboardAppend calls can be issued.  In order to guarantee
 *	atomicity, no event handling should occur between Tk_ClipboardClear
 *	and the following Tk_ClipboardAppend calls.
 *
 * Results:
 *	A standard Tcl result.  If an error is returned, an error message
 *	is left in the interp's result.
 *
 * Side effects:
 * 	The specified buffer will be copied onto the end of the clipboard.
 *	The clipboard maintains a list of buffers which will be used to
 *	supply the data for a selection get request.  The first time a given
 *	type is appended, Tk_ClipboardAppend will register a selection
 * 	handler of the appropriate type.
 *
 *----------------------------------------------------------------------
 */

int
Tk_ClipboardAppend(interp, tkwin, type, format, buffer)
    Tcl_Interp *interp;		/* Used for error reporting. */
    Tk_Window tkwin;		/* Window that selects a display. */
    Atom type;			/* The desired conversion type for this
				 * clipboard item, e.g. STRING or LENGTH. */
    Atom format;		/* Format in which the selection
				 * information should be returned to
				 * the requestor. */
    char* buffer;		/* NULL terminated string containing the data
				 * to be added to the clipboard. */
{
    TkWindow *winPtr = (TkWindow *) tkwin;
    TkDisplay *dispPtr = winPtr->dispPtr;
    TkClipboardTarget *targetPtr;
    TkClipboardBuffer *cbPtr;

    /*
     * If this application doesn't already own the clipboard, clear
     * the clipboard.  If we don't own the clipboard selection, claim it.
     */

    if (dispPtr->clipboardAppPtr != winPtr->mainPtr) {
	Tk_ClipboardClear(interp, tkwin);
    } else if (!dispPtr->clipboardActive) {
	Tk_OwnSelection(dispPtr->clipWindow, dispPtr->clipboardAtom,
		ClipboardLostSel, (ClientData) dispPtr);
	dispPtr->clipboardActive = 1;
    }

    /*
     * Check to see if the specified target is already present on the
     * clipboard.  If it isn't, we need to create a new target; otherwise,
     * we just append the new buffer to the clipboard list.
     */

    for (targetPtr = dispPtr->clipTargetPtr; targetPtr != NULL;
	    targetPtr = targetPtr->nextPtr) {
	if (targetPtr->type == type)
	    break;
    }
    if (targetPtr == NULL) {
	targetPtr = (TkClipboardTarget*) ckalloc(sizeof(TkClipboardTarget));
	targetPtr->type = type;
	targetPtr->format = format;
	targetPtr->firstBufferPtr = targetPtr->lastBufferPtr = NULL;
	targetPtr->nextPtr = dispPtr->clipTargetPtr;
	dispPtr->clipTargetPtr = targetPtr;
	Tk_CreateSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom,
		type, ClipboardHandler, (ClientData) targetPtr, format);
    } else if (targetPtr->format != format) {
	Tcl_AppendResult(interp, "format \"", Tk_GetAtomName(tkwin, format),
		"\" does not match current format \"",
		Tk_GetAtomName(tkwin, targetPtr->format),"\" for ",
		Tk_GetAtomName(tkwin, type), (char *) NULL);
	return TCL_ERROR;
    }

    /*

pTk/mTk/generic/tkClipboard.c  view on Meta::CPAN

    TkSelUpdateClipboard((TkWindow*)(dispPtr->clipWindow), targetPtr);

    return TCL_OK;
}

/*
 *----------------------------------------------------------------------
 *
 * Tk_ClipboardObjCmd --
 *
 *	This procedure is invoked to process the "clipboard" Tcl
 *	command.  See the user documentation for details on what
 *	it does.
 *
 * Results:
 *	A standard Tcl result.
 *
 * Side effects:
 *	See the user documentation.
 *
 *----------------------------------------------------------------------

pTk/mTk/generic/tkClipboard.c  view on Meta::CPAN

    }
    return TCL_OK;
}

/*
 *----------------------------------------------------------------------
 *
 * TkClipCleanup --
 *
 *	This procedure is called to cleanup resources associated with
 *	claiming clipboard ownership and for receiving selection get
 *	results.  This function is called in tkWindow.c.  This has to be
 *	called by the display cleanup function because we still need the
 *	access display elements.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Resources are freed - the clipboard may no longer be used.
 *
 *----------------------------------------------------------------------
 */

void
TkClipCleanup(dispPtr)
    TkDisplay *dispPtr;	/* display associated with clipboard */
{
    if (dispPtr->clipWindow != NULL) {
	Tk_DeleteSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom,
		dispPtr->applicationAtom);
	Tk_DeleteSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom,
		dispPtr->windowAtom);

	Tk_DestroyWindow(dispPtr->clipWindow);
	Tcl_Release((ClientData) dispPtr->clipWindow);
	dispPtr->clipWindow = NULL;
    }
}

/*
 *----------------------------------------------------------------------
 *
 * TkClipInit --
 *
 *	This procedure is called to initialize the window for claiming
 *	clipboard ownership and for receiving selection get results.  This
 *	function is called from tkSelect.c as well as tkClipboard.c.
 *
 * Results:
 *	The result is a standard Tcl return value, which is normally TCL_OK.
 *	If an error occurs then an error message is left in the interp's
 *	result and TCL_ERROR is returned.
 *
 * Side effects:
 *	Sets up the clipWindow and related data structures.
 *

pTk/mTk/generic/tkClipboard.c  view on Meta::CPAN


int
TkClipInit(interp, dispPtr)
    Tcl_Interp *interp;		/* Interpreter to use for error
				 * reporting. */
    register TkDisplay *dispPtr;/* Display to initialize. */
{
    XSetWindowAttributes atts;

    dispPtr->clipTargetPtr = NULL;
    dispPtr->clipboardActive = 0;
    dispPtr->clipboardAppPtr = NULL;

    /*
     * Create the window used for clipboard ownership and selection retrieval,
     * and set up an event handler for it.
     */

    dispPtr->clipWindow = Tk_CreateWindow(interp, (Tk_Window) NULL,
	    "_clip", DisplayString(dispPtr->display));
    if (dispPtr->clipWindow == NULL) {
	return TCL_ERROR;
    }
    Tcl_Preserve((ClientData) dispPtr->clipWindow);
    atts.override_redirect = True;

pTk/mTk/generic/tkClipboard.c  view on Meta::CPAN


	TkSelInit(dispPtr->clipWindow);
    }

    /*
     * Create selection handlers for types TK_APPLICATION and TK_WINDOW
     * on this window.  Can't use the default handlers for these types
     * because this isn't a full-fledged window.
     */

    Tk_CreateSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom,
	    dispPtr->applicationAtom, ClipboardAppHandler,
	    (ClientData) dispPtr, XA_STRING);
    Tk_CreateSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom,
	    dispPtr->windowAtom, ClipboardWindowHandler,
	    (ClientData) dispPtr, XA_STRING);
    return TCL_OK;
}

/*
 *--------------------------------------------------------------
 *
 * ClipboardGetProc --
 *
 *	This procedure is invoked to process pieces of the selection
 *	as they arrive during "clipboard get" commands.
 *
 * Results:
 *	Always returns TCL_OK.
 *
 * Side effects:
 *	Bytes get appended to the dynamic string pointed to by the
 *	clientData argument.
 *
 *--------------------------------------------------------------
 */

pTk/mTk/generic/tkFocus.c  view on Meta::CPAN

void
TkFocusDeadWindow(winPtr)
    register TkWindow *winPtr;		/* Information about the window
					 * that is being deleted. */
{
    ToplevelFocusInfo *tlFocusPtr, *prevPtr;
    DisplayFocusInfo *displayFocusPtr;
    TkDisplay *dispPtr = winPtr->dispPtr;

    /*
     * Certain special windows like those used for send and clipboard
     * have no mainPtr.
     */

    if (winPtr->mainPtr == NULL)
        return;

    /*
     * Search for focus records that refer to this window either as
     * the top-level window or the current focus window.
     */

pTk/mTk/generic/tkInt.h  view on Meta::CPAN

				 * selection on this display. */
    Atom multipleAtom;		/* Atom for MULTIPLE.  None means
				 * selection stuff isn't initialized. */
    Atom incrAtom;		/* Atom for INCR. */
    Atom targetsAtom;		/* Atom for TARGETS. */
    Atom timestampAtom;		/* Atom for TIMESTAMP. */
    Atom textAtom;		/* Atom for TEXT. */
    Atom compoundTextAtom;	/* Atom for COMPOUND_TEXT. */
    Atom applicationAtom;	/* Atom for TK_APPLICATION. */
    Atom windowAtom;		/* Atom for TK_WINDOW. */
    Atom clipboardAtom;		/* Atom for CLIPBOARD. */
    Atom utf8Atom;		/* Atom for UTF8_STRING. */

    Tk_Window clipWindow;	/* Window used for clipboard ownership and to
				 * retrieve selections between processes. NULL
				 * means clipboard info hasn't been
				 * initialized. */
    int clipboardActive;	/* 1 means we currently own the clipboard
				 * selection, 0 means we don't. */
    struct TkMainInfo *clipboardAppPtr;
				/* Last application that owned clipboard. */
    struct TkClipboardTarget *clipTargetPtr;
				/* First in list of clipboard type information
				 * records.  Each entry contains information
				 * about the buffers for a given selection
				 * target. */

    /*
     * Information used by tkSend.c only:
     */

    Tk_Window commTkwin;	/* Window used for communication
				 * between interpreters during "send"

pTk/mTk/generic/tkSelect.c  view on Meta::CPAN

		    return TCL_ERROR;
		}
		winPtr = (TkWindow *)tkwin;
		for (infoPtr = winPtr->dispPtr->selectionInfoPtr;
		     infoPtr != NULL; infoPtr = infoPtr->nextPtr) {
		    if (infoPtr->selection == selection)
			break;
		}

		/*
		 * Ignore the internal clipboard window.
		 */

		if ((infoPtr != NULL)
			&& (infoPtr->owner != winPtr->dispPtr->clipWindow)) {
		    Tcl_SetResult(interp, Tk_PathName(infoPtr->owner),
			    TCL_STATIC);
		}
		return TCL_OK;
	    }
	    tkwin = Tk_NameToWindow(interp, Tcl_GetString(objs[0]), tkwin);

pTk/mTk/generic/tkSelect.c  view on Meta::CPAN

     */

    dispPtr->multipleAtom       = Tk_InternAtom(tkwin, "MULTIPLE");
    dispPtr->incrAtom           = Tk_InternAtom(tkwin, "INCR");
    dispPtr->targetsAtom        = Tk_InternAtom(tkwin, "TARGETS");
    dispPtr->timestampAtom      = Tk_InternAtom(tkwin, "TIMESTAMP");
    dispPtr->textAtom           = Tk_InternAtom(tkwin, "TEXT");
    dispPtr->compoundTextAtom   = Tk_InternAtom(tkwin, "COMPOUND_TEXT");
    dispPtr->applicationAtom    = Tk_InternAtom(tkwin, "TK_APPLICATION");
    dispPtr->windowAtom         = Tk_InternAtom(tkwin, "TK_WINDOW");
    dispPtr->clipboardAtom      = Tk_InternAtom(tkwin, "CLIPBOARD");

    /*
     * Using UTF8_STRING instead of the XA_UTF8_STRING macro allows us
     * to support older X servers that didn't have UTF8_STRING yet.
     * This is necessary on Unix systems.
     * For more information, see:
     *    http://www.cl.cam.ac.uk/~mgk25/unicode.html#x11
     */

#if !(defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK))

pTk/mTk/generic/tkSelect.h  view on Meta::CPAN

				 * of data that cross buffer boundaries. */
    int encFlags;		/* Encoding translation state flags. */
    Tcl_DString buf;		/* Buffer to hold translation data. */
    struct TkSelRetrievalInfo *nextPtr;
				/* Next in list of all pending
				 * selection retrievals.  NULL means
				 * end of list. */
} TkSelRetrievalInfo;

/*
 * The clipboard contains a list of buffers of various types and formats.
 * All of the buffers of a given type will be returned in sequence when the
 * CLIPBOARD selection is retrieved.  All buffers of a given type on the
 * same clipboard must have the same format.  The TkClipboardTarget structure
 * is used to record the information about a chain of buffers of the same
 * type.
 */

typedef struct TkClipboardBuffer {
    char *buffer;			/* Null terminated data buffer. */
    long length;			/* Length of string in buffer. */
    struct TkClipboardBuffer *nextPtr;	/* Next in list of buffers.  NULL
					 * means end of list . */
} TkClipboardBuffer;

typedef struct TkClipboardTarget {
    Atom type;				/* Type conversion supported. */
    Atom format;			/* Representation used for data. */
    TkClipboardBuffer *firstBufferPtr;	/* First in list of data buffers. */
    TkClipboardBuffer *lastBufferPtr;	/* Last in list of clipboard buffers.
					 * Used to speed up appends. */
    struct TkClipboardTarget *nextPtr;	/* Next in list of targets on
					 * clipboard.  NULL means end of
					 * list. */
} TkClipboardTarget;

/*
 * It is possible for a Tk_SelectionProc to delete the handler that it
 * represents.  If this happens, the code that is retrieving the selection
 * needs to know about it so it doesn't use the now-defunct handler
 * structure.  One structure of the following form is created for each
 * retrieval in progress, so that the retriever can find out if its
 * handler is deleted.  All of the pending retrievals (if there are more

pTk/mTk/generic/tkWindow.c  view on Meta::CPAN

#endif

static TkCmd commands[] = {
    /*
     * Commands that are part of the intrinsics:
     */

    {"bell",		NULL,			Tk_BellObjCmd,		0, 1},
    {"bind",		NULL,			Tk_BindObjCmd,		1, 1},
    {"bindtags",	NULL,			Tk_BindtagsObjCmd,	1, 1},
    {"clipboard",	NULL,			Tk_ClipboardObjCmd,	0, 1},
    {"destroy",		NULL,			Tk_DestroyObjCmd,	1, 1},
    {"event",		NULL,			Tk_EventObjCmd,		1, 1},
    {"focus",		NULL,			Tk_FocusObjCmd,		1, 1},
    {"font",		NULL,			Tk_FontObjCmd,		1, 1},
    {"grab",		NULL,			Tk_GrabObjCmd,		0, 1},
    {"grid",		NULL,			Tk_GridObjCmd,		1, 1},
    {"image",		NULL,			Tk_ImageObjCmd,		1, 1},
    {"lower",		NULL,			Tk_LowerObjCmd,		1, 1},
    {"option",		NULL,			Tk_OptionObjCmd,	1, 1},
    {"pack",		NULL,			Tk_PackObjCmd,		1, 1},

pTk/mTk/generic/tkWindow.c  view on Meta::CPAN

{
    /*
     * Initialize the interpreter with Tk, safely. This removes
     * all the Tk commands that are unsafe.
     *
     * Rationale:
     *
     * - Toplevel and menu are unsafe because they can be used to cover
     *   the entire screen and to steal input from the user.
     * - Continuous ringing of the bell is a nuisance.
     * - Cannot allow access to the clipboard because a malicious script
     *   can replace the contents with the string "rm -r *" and lead to
     *   surprises when the contents of the clipboard are pasted. Similarly,
     *   the selection command is blocked.
     * - Cannot allow send because it can be used to cause unsafe
     *   interpreters to execute commands. The tk command recreates the
     *   send command, so that too must be hidden.
     * - Focus can be used to grab the focus away from another window,
     *   in effect stealing user input. Cannot allow that.
     *   NOTE: We currently do *not* hide focus as it would make it
     *   impossible to provide keyboard input to Tk in a safe interpreter.
     * - Grab can be used to block the user from using any other apps
     *   on the screen.

pTk/mTk/unix/mkLinks  view on Meta::CPAN

    $ZIP chooseColor.n
    rm -f tk_chooseColor.n tk_chooseColor.n.*
    ln $S chooseColor.n$Z tk_chooseColor.n$Z
fi
if test -r chooseDirectory.n; then
    rm -f chooseDirectory.n.*
    $ZIP chooseDirectory.n
    rm -f tk_chooseDirectory.n tk_chooseDirectory.n.*
    ln $S chooseDirectory.n$Z tk_chooseDirectory.n$Z
fi
if test -r clipboard.n; then
    rm -f clipboard.n.*
    $ZIP clipboard.n
fi
if test -r colors.n; then
    rm -f colors.n.*
    $ZIP colors.n
fi
if test -r console.n; then
    rm -f console.n.*
    $ZIP console.n
fi
if test -r cursors.n; then

pTk/mTk/win/tkWinClipboard.c  view on Meta::CPAN

/* 
 * tkWinClipboard.c --
 *
 *	This file contains functions for managing the clipboard.
 *
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 * Copyright (c) 1998-2000 by Scriptics Corporation.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tkWinClipboard.c,v 1.7 2000/04/12 18:51:11 hobbs Exp $
 */

pTk/mTk/win/tkWinClipboard.c  view on Meta::CPAN

    return TCL_ERROR;
}

/*
 *----------------------------------------------------------------------
 *
 * TkSetSelectionOwner --
 *
 *	This function claims ownership of the specified selection.
 *	If the selection is CLIPBOARD, then we empty the system
 *	clipboard.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Empties the system clipboard, and claims ownership.
 *
 *----------------------------------------------------------------------
 */

Window
XGetSelectionOwner(Display *display, Atom selection)
{
 return None;
}

pTk/mTk/win/tkWinClipboard.c  view on Meta::CPAN

    /*
     * This is a gross hack because the Tk_InternAtom interface is broken.
     * It expects a Tk_Window, even though it only needs a Tk_Display.
     */

    tkwin = (Tk_Window) TkGetMainInfoList()->winPtr;

    if (selection == Tk_InternAtom(tkwin, "CLIPBOARD")) {

	/*
	 * Only claim and empty the clipboard if we aren't already the
	 * owner of the clipboard.
	 */

	if (GetClipboardOwner() != hwnd) {
	    UpdateClipboard(hwnd);
	}
    }
}

/*
 *----------------------------------------------------------------------
 *
 * TkWinClipboardRender --
 *
 *	This function supplies the contents of the clipboard in
 *	response to a WM_RENDERFORMAT message.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Sets the contents of the clipboard.
 *
 *----------------------------------------------------------------------
 */

void
TkWinClipboardRender(dispPtr, format)
    TkDisplay *dispPtr;
    UINT format;
{
    TkClipboardTarget *targetPtr;

pTk/mTk/win/tkWinClipboard.c  view on Meta::CPAN

		    *buffer++ = '\r';
		}
		*buffer++ = *p;
	    }
	}
    }
    *buffer = '\0';

    /*
     * Depending on the platform, turn the data into Unicode or the
     * system encoding before placing it on the clipboard.
     */

    if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) {
	Tcl_DStringInit(&ds);
	Tcl_UtfToUniCharDString(rawText, -1, &ds);
	ckfree(rawText);
	handle = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,
		Tcl_DStringLength(&ds)+2);
	if (!handle) {
	    Tcl_DStringFree(&ds);

pTk/mTk/win/tkWinClipboard.c  view on Meta::CPAN

    }

    return;
}

/*
 *----------------------------------------------------------------------
 *
 * TkSelUpdateClipboard --
 *
 *	This function is called to force the clipboard to be updated
 *	after new data is added.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Clears the current contents of the clipboard.
 *
 *----------------------------------------------------------------------
 */

void
TkSelUpdateClipboard(winPtr, targetPtr)
    TkWindow *winPtr;
    TkClipboardTarget *targetPtr;
{
    HWND hwnd = TkWinGetHWND(winPtr->window);
    UpdateClipboard(hwnd);
}

/*
 *----------------------------------------------------------------------
 *
 * UpdateClipboard --
 *
 *	Take ownership of the clipboard, clear it, and indicate to the
 *	system the supported formats.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

pTk/mTk/win/tkWinTest.c  view on Meta::CPAN


#include "tkWinInt.h"

HWND tkWinCurrentDialog;

/*
 * Forward declarations of procedures defined later in this file:
 */

int			TkplatformtestInit(Tcl_Interp *interp);
static int		TestclipboardObjCmd(ClientData clientData,
			    Tcl_Interp *interp, int objc,
			    Tcl_Obj *CONST objv[]);
static int		TestwineventCmd(ClientData clientData,
			    Tcl_Interp *interp, int argc, CONST char **argv);


/*
 *----------------------------------------------------------------------
 *
 * TkplatformtestInit --

pTk/mTk/win/tkWinTest.c  view on Meta::CPAN

 */

int
TkplatformtestInit(
    Tcl_Interp *interp)		/* Interpreter to add commands to. */
{
    /*
     * Add commands for platform specific tests on MacOS here.
     */

    Tcl_CreateObjCommand(interp, "testclipboard", TestclipboardObjCmd,
	    (ClientData) Tk_MainWindow(interp), (Tcl_CmdDeleteProc *) NULL);
    Tcl_CreateObjCommand(interp, "testwinevent", TestwineventCmd,
            (ClientData) Tk_MainWindow(interp), (Tcl_CmdDeleteProc *) NULL);

    return TCL_OK;
}

/*
 *----------------------------------------------------------------------
 *

pTk/mTk/win/tkWinTest.c  view on Meta::CPAN

    Tcl_AppendToObj(resultPtr, msg, length);

    if (length != 0) {
	Tcl_DStringFree(&ds);
    }
}

/*
 *----------------------------------------------------------------------
 *
 * TestclipboardObjCmd --
 *
 *	This procedure implements the testclipboard command. It provides
 *	a way to determine the actual contents of the Windows clipboard.
 *
 * Results:
 *	A standard Tcl result.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

static int
TestclipboardObjCmd(clientData, interp, objc, objv)
    ClientData clientData;		/* Main window for application. */
    Tcl_Interp *interp;			/* Current interpreter. */
    int objc;				/* Number of arguments. */
    Tcl_Obj *CONST objv[];		/* Argument values. */
{
    TkWindow *winPtr = (TkWindow *) clientData;
    HGLOBAL handle;
    char *data;
    int code = TCL_OK;

pTk/mTk/win/tkWinTest.c  view on Meta::CPAN

	 * would have to convert it from External.  Instead we'll just
	 * take this and do "bytestring" at the Tcl level for Unicode
	 * inclusive text
	 */
	handle = GetClipboardData(CF_TEXT);
	if (handle != NULL) {
	    data = GlobalLock(handle);
	    Tcl_AppendResult(interp, data, (char *) NULL);
	    GlobalUnlock(handle);
	} else {
	    Tcl_AppendResult(interp, "null clipboard handle", (char *) NULL);
	    code = TCL_ERROR;
	}
	CloseClipboard();
	return code;
    } else {
	Tcl_AppendResult(interp, "couldn't open clipboard: ", (char *) NULL);
	AppendSystemError(interp, GetLastError());
	return TCL_ERROR;
    }
    return TCL_OK;
}

/*
 *----------------------------------------------------------------------
 *
 * TestwineventCmd --

pTk/mTk/win/tkWinX.c  view on Meta::CPAN

static Tcl_Encoding unicodeEncoding = NULL; /* unicode encoding */

/*
 * Thread local storage.  Notice that now each thread must have its
 * own TkDisplay structure, since this structure contains most of
 * the thread-specific date for threads.
 */
typedef struct ThreadSpecificData {
    TkDisplay *winDisplay;       /* TkDisplay structure that *
				  *  represents Windows screen. */
    int updatingClipboard;      /* If 1, we are updating the clipboard */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;

/*
 * Forward declarations of procedures used in this file.
 */

#ifdef __CYGWIN__
static void             DisplayFileProc _ANSI_ARGS_((ClientData clientData,
			    int flags));

pTk/mTk/win/tkWinX.c  view on Meta::CPAN

    HWND hwnd;
    ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));

    if (dispPtr != tsdPtr->winDisplay) {
	panic("TkpCloseDisplay: tried to call TkpCloseDisplay on another display");
	return;
    }

    /*
     * Force the clipboard to be rendered if we are the clipboard owner.
     */

    if (dispPtr->clipWindow) {
	hwnd = Tk_GetHWND(Tk_WindowId(dispPtr->clipWindow));
	if (GetClipboardOwner() == hwnd) {
	    OpenClipboard(hwnd);
	    EmptyClipboard();
	    TkWinClipboardRender(dispPtr, CF_TEXT);
	    CloseClipboard();
	}

pod/Clipboard.pod  view on Meta::CPAN

#  Copyright (c) 1994 The Regents of the University of California.
#  Copyright (c) 1994-1996 Sun Microsystems, Inc.
#  See the file "license.terms" for information on usage and redistribution
#  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
#

=head1 NAME

Tk::clipboard - Manipulate Tk clipboard

=for category User Interaction

=head1 SYNOPSIS

I<$widget>-E<gt>B<clipboard>I<Option>?(I<args>)?

=head1 DESCRIPTION

This command provides an interface to the Tk clipboard,
which stores data for later retrieval using the selection mechanism.
In order to copy data into the clipboard, B<clipboardClear> must
be called, followed by a sequence of one or more calls to
B<clipboardAppend>.  To ensure that the clipboard is updated atomically, all
appends should be completed before returning to the event loop.

The following methods are currently supported:

=over 4

=item I<$widget>-E<gt>B<clipboardClear>

Claims ownership of the clipboard on I<$widget>'s display and removes
any previous contents.   Returns an empty string.

=item I<$widget>-E<gt>B<clipboardAppend>(?B<-format>=E<gt>I<format>?,?B<-type>=E<gt>I<type>?,?B<-->?,I<data>)

Appends I<data> to the clipboard on $widget's
display in the form given by I<type> with the representation given
by I<format> and claims ownership of the clipboard on $widget's
display.

=over 4

I<Type> specifies the form in which the selection is to be returned
(the desired ``target'' for conversion, in ICCCM terminology), and
should be an atom name such as STRING or FILE_NAME; see the
Inter-Client Communication Conventions Manual for complete details.
I<Type> defaults to STRING.

The I<format> argument specifies the representation that should be
used to transmit the selection to the requester (the second column of
Table 2 of the ICCCM), and defaults to STRING.  If I<format> is
STRING, the selection is transmitted as 8-bit ASCII characters.
See the L<Tk::Selection> documentation for explanation of what happens
if I<format> is not STRING.
Note that arguments passed to
B<clipboardAppend> are concatenated before conversion, so the
caller must take care to ensure appropriate spacing across string
boundaries.  All items appended to the clipboard with the same
I<type> must have the same I<format>.

A B<--> argument may be specified to mark the end of options:  the
next argument will always be used as I<data>.
This feature may be convenient if, for example, I<data> starts
with a B<->.

=back

=back

=over 4

=item I<$widget>-E<gt>B<clipboardGet>( ?-type? );

Retrieve data from the clipboard on  I<widget>'s  display.
I<-type> specifies the form in which the data is
to be returned and should be an atom  name  such  as  STRING  or
FILE_NAME.  Type defaults to STRING.  This command is equivalent 
to C<SelectionGet( -selection =E<gt> 'CLIPBOARD' )>.

=back

=head1 KEYWORDS

clear, format, clipboard, append, selection, type

=cut

pod/Entry.pod  view on Meta::CPAN


Control-/ selects all the text in the entry.

=item [14]

Control-\ clears any selection in the entry.

=item [15]

The F16 key (labelled Copy on many Sun workstations) or Meta-w
copies the selection in the widget to the clipboard, if there is a selection.

=item [16]

The F20 key (labelled Cut on many Sun workstations) or Control-w
copies the selection in the widget to the clipboard and deletes
the selection.
If there is no selection in the widget then these keys have no effect.

=item [17]

The F18 key (labelled Paste on many Sun workstations) or Control-y
inserts the contents of the clipboard at the position of the
insertion cursor.

=item [18]

The Delete key deletes the selection, if there is one in the entry.
If there is no selection, it deletes the character to the right of
the insertion cursor.

=item [19]

pod/Listbox.pod  view on Meta::CPAN

the active element and deselects everything else.

=item [18]

Control-backslash deselects everything in the widget, except in
B<browse> mode where it has no effect.

=item [19]

The F16 key (labelled Copy on many Sun workstations) or Meta-w
copies the selection in the widget to the clipboard, if there is
a selection.

The behavior of listboxes can be changed by defining new bindings for
individual widgets or by redefining the class bindings.

=back

=head1 TIED INTERFACE

The Tk::Listbox widget can also be tied to a scalar or array variable, with

pod/Spinbox.pod  view on Meta::CPAN


Control-/ selects all the text in the Spinbox.

=item [14]

Control-\ clears any selection in the Spinbox.

=item [15]

The F16 key (labelled Copy on many Sun workstations) or Meta-w
copies the selection in the widget to the clipboard, if there is a selection.

=item [16]

The F20 key (labelled Cut on many Sun workstations) or Control-w
copies the selection in the widget to the clipboard and deletes
the selection.
If there is no selection in the widget then these keys have no effect.

=item [17]

The F18 key (labelled Paste on many Sun workstations) or Control-y
inserts the contents of the clipboard at the position of the
insertion cursor.

=item [18]

The Delete key deletes the selection, if there is one in the Spinbox.
If there is no selection, it deletes the character to the right of
the insertion cursor.

=item [19]



( run in 5.222 seconds using v1.01-cache-2.11-cpan-84e82930d8c )