obonaventure has asked for the wisdom of the Perl Monks concerning the following question:

I was wondering if it is possible to have a static line or two at the top and/or the bottom of the screen (Like a header or footer). This text would remain as the screen scrolls or as it is cleared. I attempted to do some searches here and in Google but I have been unsuccessful in finding anything. that may mean it is not possible or i'm searching for it the wrong way. Thank you all!

  • Comment on Header (and/or Footer) on perl output screen

Replies are listed 'Best First'.
Re: Header (and/or Footer) on perl output screen
by zentara (Cardinal) on Mar 14, 2012 at 17:21 UTC
    Are you willing to use a GUI toolkit like Gtk2 or Tk? If so, you can probably use one of the widgets, like the Text or Canvas to simulate what you want to do. You could put a text string in the system tray, or you could embed an xterm into a canvas, and make whatever headers and footers you desire above and below a xterm window. An example:
    #!/usr/bin/perl -w use strict; use Tk; # Idea ripped from a script by Christophe Mertz of the # Tk::Zinc module, to work with a plain canvas. # The Zinc module has much more flexibility in how # you can hide windows. I had to mask the xterm with a # toplevel to hide it in the plain old canvas. # my $mw = MainWindow->new(); my $canv = $mw->Canvas(-bg => 'lightsteelblue', -relief => 'sunken', -width => 550, -height => 350)->pack(-expand => 1, -fill => 'both'); my $xtermWidth = 400; my $xtermHeight = 300; ## this Frame is needed for including the xterm in Tk::Canvas my $xtermContainer = $canv->Frame(-container => 1); my $xtid = $xtermContainer->id(); # converting the id from HEX to decimal as xterm requires a decimal Id my ($xtId) = sprintf hex $xtid; my $dcontitem = $canv->createWindow(275,175, -window => $xtermContainer, -width => $xtermWidth+100, -height => $xtermHeight, -state => 'normal'); my $label = $canv->createText( 275,10, -text => "Hide xterm", ); $canv->Tk::bind("<Button-1>", \&hideShow); my $width = $xtermWidth; my $height = $xtermHeight; $mw->Button(-text => "Exit", -command => [sub{Tk::exit}] )->pack( ); my $tl; #used to mask xterm system("xterm -into $xtId &"); MainLoop(); sub hideShow { if ($canv->itemcget($label, -text) =~ /Hide/) { $canv->itemconfigure($label, -fill => 'white', -text => "Show xterm"); $tl = $mw->Toplevel(-use=>$xtId ); } else { $canv->itemconfigure($label, -fill => 'black', -text => "Hide xterm"); $tl->withdraw; } }

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      Thank you. I'll take a look
Re: Header (and/or Footer) on perl output screen
by Anonymous Monk on Mar 14, 2012 at 15:23 UTC