#! /local/bin/perl

# curses.pl -- Copyright (c) 1990, Henk P. Penning.
# You may distribute under the terms of the GNU General Public License
# as specified in the README file that comes with the Jinx 2.0 kit.

sub addlog { &ctermlog($_[0]) if $logLevel >= 0 ; }

sub getchintR { return &ch2str(&getchR) ; }

sub addstrC
  { local($str,$c) = shift ;
    while ($str =~ qq/\n$/)
      { chop $str ;
	$c++ ;
      }
    &addstr($str) ;
    &clrtoeol() if ($c) ;
  }

sub initEdit
  { local($_) ;
    &editreset ;
    for ( @_ ) { &editq($_) ; }
  }

sub initCurses
  { &initscr ;
    &nonl ;
    &cbreak ;
    &noecho ;
    &keypad(0,1) ;
    &leaveok(0,0) ;
    $flushOn = 1 ;
  }

sub testCurses
  { local($_,@keys,@errors) ;
    @keys = ('KEY_UP','KEY_DOWN','KEY_LEFT','KEY_RIGHT','KEY_RET','KEY_TAB') ;
    for ( @testCurses )
      { push(@errors,"jinx: required cterm function '$_' is absent")
	  if ! defined $curfun{$_} ;
      }
    for ( @keys )
      { push(@errors,"jinx: required cterm constant '$_' is absent")
	  if ! defined $curcon{$_} ;
      }
    return $#errors == -1, @errors ;
  }

@testCurses = ('addstr','beep'
,'cbreak','clrreg','clrtoeol','ctermlog','edit'
,'editq','editreset','endwin','getchR','initscr'
,'keypad','leaveok','move','mvaddstr','noecho'
,'nonl','show') ;

1;
