Demeter

Description Perl tools for X-ray Absorption Spectroscopy
Demeter > Perl Modules > Demeter::UI::Screen::Pause
Source

NAME

Demeter::UI::Screen::Pause - A generic pause method for the screen UI

VERSION

This documentation refers to Demeter version 0.9.26.

SYNOPSIS

   $fitobject->pause(-1);

DESCRIPTION

This role for a Demeter object provides a generic and easy-to-use pause when using the terminal. This role is imported when the UI mode is set to "screen". See "PRAGMATA" in Demeter.

Trying to use the pause method without being in screen mode will do nothing. That is because there is a pause method in the base class that does nothing. That no-op gets overridden when in screen mode with this more useful method. Note, however, that the attributes documented below do not exist in the base class and will return the "Can't locate object method" error when you attempt to access them outside of screen mode.

ATTRIBUTES

prompt

The text of the carriage return prompt which is displayed when not pausing for specified amount of time. The default is

  Hit return to continue>

If ANSI colors are available, the prompt will be displayed in reverse colors (usually black on white). The ANSI colors control sequences are part of the default value of this attribute and so can be overriden by resetting its value.

highlight

This sets the form of highlighting of the prompt. The possible values are underline and reverse, which will cause the prompt text to be either underlined or reverse video in the sense of Term::ANSIColor. Any other value for this attribute will result in no highlighting of the prompt string.

METHODS

pause

This pauses either for the amount of time indicated in seconds or, if the argument is zero or negative, until the enter key is pressed.

   $object->pause(-1);

This method returns whatever string is entered before return is hit. So this method could be used, for example, to prompt for the answer with a question.

   $object->prompt("What is 2+2? ");
   my $answer = $object->pause;
   chomp $answer;
   if ($answer eq '4') {
      print "You're a math genius!\n";
   } else {
      print "Sigh. I don't know why I even bother....\n";
   };

DEPENDENCIES

Demeter's dependencies are in the Build.PL file. This module uses Term::ANSIColor if it is available.

BUGS AND LIMITATIONS

Please report problems to the Ifeffit Mailing List (http://cars9.uchicago.edu/mailman/listinfo/ifeffit/)

Patches are welcome.

AUTHOR

Bruce Ravel (http://bruceravel.github.io/home)

http://bruceravel.github.io/demeter/

LICENCE AND COPYRIGHT

Copyright (c) 2006-2018 Bruce Ravel (http://bruceravel.github.io/home). All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlgpl.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.