/*******************************************************************************
* Copyright (c) 2013-2017, Andrés Martinelli <andmarti@gmail.com *
* All rights reserved. *
* *
* This file is a part of SC-IM *
* *
* SC-IM is a spreadsheet program that is based on SC. The original authors *
* of SC are James Gosling and Mark Weiser, and mods were later added by *
* Chuck Martin. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions are met: *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. All advertising materials mentioning features or use of this software *
* must display the following acknowledgement: *
* This product includes software developed by Andrés Martinelli *
* <andmarti@gmail.com>. *
* 4. Neither the name of the Andrés Martinelli nor the *
* names of other contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY ANDRES MARTINELLI ''AS IS'' AND ANY *
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL ANDRES MARTINELLI BE LIABLE FOR ANY *
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;*
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*******************************************************************************/
/**
* \file tui.c
* \author Andrés Martinelli <andmarti@gmail.com>
* \date 2017-07-18
* \brief TODO Write a brief file description.
*
* \details This is the ncurses implementation of sc-im user interface,
* or called tui. It mainly consists on the following two windows:
* main_win: window that shows the grid
* input_win: status bar window (or called header) and stdin input
*
* these are the functions called outside tui.c:
* ui_query // function to read text from stdin
* ui_query_opt // function that shows a message and waits for confirmation between a couple of defined options
* yyerror // error routine for yacc parser
* ui_bail // function to print errors of lua scripts
* ui_winchg // function that handles SIGWINCH
* ui_show_celldetails // function that shows cell details in header bar
* ui_start_colors // exclusive ui startup routine for colors
* ui_pause
* ui_resume
*
* these are local functions that might not be needed to reimplement if writing another ui:
* ui_set_ucolor // function called internally for setting a color
* ui_show_content
* ui_show_sc_col_headings
* ui_add_cell_detail // Add details of an ent to a char * received as a parameter. used for input_win
*
* ANYONE WHO WANTS TO PORT THIS TO ANOTHER UI, WOULD JUST NEED TO REIMPLEMENT THIS FILE
* AND HELP() IN HELP.C
*
*
* if not working with ncurses, you should also have to define LINES and COLS macros in Xui.h as well.
* see ui example inside /files folder
*/
#include <string.h>
#include <ncurses.h>
#include <stdio.h>
#include <time.h>
#include <locale.h>
#include <stdlib.h>
#include <stdarg.h>
#include "main.h"
#include "conf.h"
#include "input.h"
#include "tui.h"
#include "range.h"
#include "sc.h"
#include "cmds.h"
#include "cmds_visual.h"
#include "conf.h"
#include "version.h"
#include "file.h"
#include "format.h"
#include "utils/string.h"
#include "digraphs.h"
extern struct dictionary * d_colors_param;
extern int cmd_pending;
extern int cmd_multiplier