
(********************************************************************)
(*                                                                  *)
(*  screen.s7i    General text screen with random access            *)
(*  Copyright (C) 1992, 1993, 1994, 2005  Thomas Mertes             *)
(*                                                                  *)
(*  This file is part of the Seed7 Runtime Library.                 *)
(*                                                                  *)
(*  The Seed7 Runtime Library is free software; you can             *)
(*  redistribute it and/or modify it under the terms of the GNU     *)
(*  Lesser General Public License as published by the Free Software *)
(*  Foundation; either version 2.1 of the License, or (at your      *)
(*  option) any later version.                                      *)
(*                                                                  *)
(*  The Seed7 Runtime Library 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.  See the GNU Lesser General Public License for more    *)
(*  details.                                                        *)
(*                                                                  *)
(*  You should have received a copy of the GNU Lesser General       *)
(*  Public License along with this program; if not, write to the    *)
(*  Free Software Foundation, Inc., 51 Franklin Street,             *)
(*  Fifth Floor, Boston, MA  02110-1301, USA.                       *)
(*                                                                  *)
(********************************************************************)


const type: screen_file is sub null_file struct
  end struct;

type_implements_interface(screen_file, text);

const screen_file: STD_SCREEN is screen_file.value;

const proc: SCR_OPEN is                               action "SCR_OPEN";


const func screen_file: open (SCREEN) is func
  result
    var screen_file: result is STD_SCREEN;
  begin
    SCR_OPEN;
    result := STD_SCREEN;
  end func;


const proc: flush (ref screen_file param) is                        action "SCR_FLUSH";
const func integer: height (ref screen_file param) is               action "SCR_HEIGHT";
const func integer: width (ref screen_file param) is                action "SCR_WIDTH";
const proc: cursor (ref screen_file param, ref boolean param) is    action "SCR_CURSOR";
const proc: clear (in screen_file param, in integer param,
    in integer param, in integer param, in integer param) is        action "SCR_CLEAR";
const proc: v_scroll (inout screen_file param,
    in integer param, in integer param, in integer param,
    in integer param, in integer param) is                          action "SCR_V_SCL";
const proc: h_scroll (ref screen_file param,
    in integer param, in integer param, in integer param,
    in integer param, in integer param) is                          action "SCR_H_SCL";
const proc: setPos (ref screen_file param,
    ref integer param, ref integer param) is                        action "SCR_SETPOS";
const proc: color (ref screen_file param, ref color param) is noop;
const proc: color (ref screen_file param, ref color param, ref color param) is noop;


const proc: write (ref screen_file param, in string param) is       action "SCR_WRITE";

const proc: write (ref screen_file: screen_fil, in char: ch) is func
  begin
    write(screen_fil, str(ch));
  end func;

const proc: clear (in screen_file: screen_fil) is func
  begin
    clear(screen_fil, 1, 1, height(screen_fil), width(screen_fil));
  end func;

(*
const proc: writeln (ref screen_file: screen_fil) is func
  begin
    if LINE(screen_fil) = height(screen_fil) then
      SCROLL_UP(screen_fil, 1, 1, height(screen_fil), width(screen_fil), 1);
      setPos(screen_fil, LINE(screen_fil), 1);
    else
      setPos(screen_fil, succ(LINE(screen_fil)), 1);
    end if;
  end func;


const proc: backSpace (ref screen_file: screen_fil) is func
  begin
    if COLUMN(screen_fil) > 1 then
      setPos(screen_fil, LINE(screen_fil); pred(COLUMN(screen_fil)));
      if COLUMN(screen_fil) <= width(screen_fil) then
        write(screen_fil.OUT_FILE, " ");
        setPos(screen_fil, LINE(screen_fil); pred(COLUMN(screen_fil)));
      end if;
    end if;
  end func;
*)


const proc: cursor_on (ref screen_file: screen_fil) is func
  begin
    write(screen_fil, "_");
  end func;


const proc: cursor_off (ref screen_file: screen_fil) is func
  begin
    write(screen_fil, " ");
  end func;
