#ifndef ETERMVIEWER_H
#define ETERMVIEWER_H

#include "estr.h"
#include "earray.h"
#include "esystem.h"
#include "efile.h"

#ifndef _WIN32
 #include <unistd.h>
#endif

#include <ncurses.h>

class etermviewer
{
 public:
  estr line;
  int cpos;
  int hcpos;
  int inputfd;
  int outputfd;
  int errorfd;
  efile termfd;
  efile outputf;
  efile errorf;

  static int lines;
  static int cols;
  static etermviewer *cviewer;
  int lastcolor;

  int tpos;
  earray<estr> *text;

  estr status;

  bool listMode;
  int listCursor;

  efunc onEnter;
//  static efunc onExit;
  efunc onKeyPress;

  etermviewer();
  ~etermviewer();

  void init();

  void doDraw();
  void add(const estr& line);
  void add(const earray<estr>& lines);
  void textPageUp();
  void textPageDown();

  void update();
  void setText(earray<estr> *text);

  void listChoice(int choice);
  void doKeyPress();

  static void doExit();
  static void doWindowResize(int);
};

#endif

