// $Id: screen.c,v 1.1 2008/05/31 00:35:09 lpoulsen Exp $
//
// Copyright (c) 2008 by Afar Communications Inc, Santa Barbara, CA 93117 USA
//
// "screen" command for ECON for Windows
//
// $Log: screen.c,v $
// Revision 1.1  2008/05/31 00:35:09  lpoulsen
// Econ 4.x preview - now with command shell
//
//
#include <windows.h>
#include <stdio.h>
#include "afartype.h"
#include "parser.h"

Select screen_back_sel[] = {
  { "white",      0 },
  { "black",      0 },
  { NULL,         0 }
};

Arg screen_args[] = {
  { "background", SELECT(screen_back_sel), 0 },
  { "lines",      INT(24, 500),            0 },
  { NULL,         UNDEF_ARG,               0 }
};

cmd_ret_t
econ_screen(Argument_List *a, ucio_session *s)
{
    char *tmp;

    tmp = parser_get_value(a, "background");
    if (tmp) {
        switch(parse_select_match(tmp, screen_back_sel))
        {
        case 0:    // white
            setReverseTextBackground();
            break;
        case 1:    // black
            setNormalTextBackground();
            break;
        }
    }
    tmp = parser_get_value(a, "lines");
    if (tmp) {
        COORD sbufsize;
        HANDLE console;

        console = GetStdHandle(STD_OUTPUT_HANDLE);
        sbufsize.X = 80;
        sbufsize.Y = atoi(tmp);
        SetConsoleScreenBufferSize(console, sbufsize);
    }
    return CMD_SUCCESS;
}
