Bundle-PBib

 view release on metacpan or  search on metacpan

lib/PBibTk/Main.pm  view on Meta::CPAN

  $cmd = sub { $self->clipboardSelectedPaperReferenceId(); };
  $mb->command(-label => '~Copy CiteKey to Clipboard', -command => $cmd,
  				-accelerator => 'Ctrl-X' );
  $win->bind('<Control-Key-x>' => $cmd);

  $cmd = sub { $self->searchSelectedPaperReferenceId(); };
  $mb->command(-label => '~Search CiteKey in Paper', -command => $cmd,
  				-accelerator => 'Ctrl-G' );
  $win->bind('<Control-Key-g>' => $cmd);

  $cmd = sub { $self->foundList()->focus(); };
  $mb->command(-label => 'Keyboardfocus to ~Paper', -command => $cmd,
  				-accelerator => 'Ctrl-P' );
  $win->bind('<Control-p>' => $cmd);

  $mb->separator();

  $cmd = sub { openFile($filename); };
  $mb->command(-label => '~Edit Paper', -command => $cmd,
  				-accelerator => 'Ctrl-E' );
  $win->bind('<Control-Key-e>' => $cmd);

  $mb->separator();

  $mb->command(-label => "Read & ~Analyze Paper", -command => [ $self, 'readPaperFile' ]);

  $cmd = [ $self, 'processPaperFile' ];
  $mb->command(-label => "Pr~ocess Paper", 
				  -command => $cmd,
				  -accelerator => 'Ctrl-S' );
  $win->bind('<Control-Key-s>' => $cmd);

  $mb->command(-label => "~Write newrefs file", -command => [$self => 'writeNewRefs']);
}

sub refList {
  my $self = shift;
  # access window first, to ensure it's created.
  $self->window();
  return $self->{'refList'};
}
sub foundList {
  my $self = shift;
  # access window first, to ensure it's created.
  $self->window();
  return $self->{'foundList'};
}
sub queryAuthorList { return shift->{'queryAuthorList'}; }
sub queryKeywordList { return shift->{'queryKeywordList'}; }
sub chosenLabel { my $self = shift; return $self->{'chosenLabel'}; }
sub refListLabel { my $self = shift; return $self->{'refListLabel'}; }
sub foundListLabel { my $self = shift; return $self->{'foundListLabel'}; }
sub refListSelection { my $self = shift; return $self->refList()->curselection(); }
sub foundListSelection { my $self = shift; return $self->foundList()->curselection(); }

sub litRefs { my $self = shift; return $self->{'litRefs'}; }



sub initDropSite {
# I guess this doesn't qork jet under Win32 ...
  my ($self, $win) = @_;
  $win->DropSite(
	-entercommand => sub{print "enter @_\n";},
	-leavecommand  => sub{print "leave @_\n";},
	-motioncommand  => sub{print "motion @_\n";},
	-dropcommand  => sub{print "drop @_\n";},
	);
}


#
# button / menu methods
#

sub keyPressed {
  my ($self, $key, $mod, $list, $refsName) = @_;
  return if $mod && $mod ne '';
  my $refs = $self->{$refsName};
  my $idx = $self->indexOfRefStartingWith($refs, $key);
print "keyPressed $key ($mod) --> $idx\n";
  $list->focus();
  $list->activate($idx);
  $list->selectionClear(0, 'end');
  $list->selectionAnchor($idx);
  $list->selectionSet($idx);
  $list->see($idx);
  $self->selectionMove($list, undef);
}
sub indexOfRefStartingWith {
  my ($self, $refs, $char) = @_;
  return undef unless defined($char);
  my $idx = 0;
  for( ; $idx < scalar(@$refs); $idx++ ) {
###  print ord(lc($char)), ' ', ord(lc(substr($refs->[$idx], 0, 1))), " $idx - $refs->[$idx]\n";
    last if( ord(lc($char)) <= ord(lc(substr($refs->[$idx], 0, 1))) );
  }
  return $idx;
}

sub entryFocusAndSelectAll {
	my ($self, $list) = @_;
	$list->focus();
	$list->selectionRange(0, "end");
}

sub selectionMove {
	# called on UP and Down key presses to be able to adjust the printed ref.
	my ($self, $list, $inc) = @_;
	if( $list == $self->refList() ) {
		$self->updateExpandedSelectedBiblioReference();
	} else {
		$self->updateExpandedSelectedPaperReference();
	}
}


# updateing

sub updateBiblioRefs {
# re-load all refs and re-analyze paper!



( run in 2.532 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )