1 /******************************************************************************* 2 * Copyright (c) 2013-2021, Andrés Martinelli <andmarti@gmail.com> * 3 * All rights reserved. * 4 * * 5 * This file is a part of SC-IM * 6 * * 7 * SC-IM is a spreadsheet program that is based on SC. The original authors * 8 * of SC are James Gosling and Mark Weiser, and mods were later added by * 9 * Chuck Martin. * 10 * * 11 * Redistribution and use in source and binary forms, with or without * 12 * modification, are permitted provided that the following conditions are met: * 13 * 1. Redistributions of source code must retain the above copyright * 14 * notice, this list of conditions and the following disclaimer. * 15 * 2. Redistributions in binary form must reproduce the above copyright * 16 * notice, this list of conditions and the following disclaimer in the * 17 * documentation and/or other materials provided with the distribution. * 18 * 3. All advertising materials mentioning features or use of this software * 19 * must display the following acknowledgement: * 20 * This product includes software developed by Andrés Martinelli * 21 * <andmarti@gmail.com>. * 22 * 4. Neither the name of the Andrés Martinelli nor the * 23 * names of other contributors may be used to endorse or promote products * 24 * derived from this software without specific prior written permission. * 25 * * 26 * THIS SOFTWARE IS PROVIDED BY ANDRES MARTINELLI ''AS IS'' AND ANY * 27 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * 28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * 29 * DISCLAIMED. IN NO EVENT SHALL ANDRES MARTINELLI BE LIABLE FOR ANY * 30 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * 31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;* 32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * 33 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * 35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 36 *******************************************************************************/ 37 38 /** 39 * \file tui.h 40 * \author Andrés Martinelli <andmarti@gmail.com> 41 * \date 2017-07-18 42 * \brief Header file for tui.c 43 */ 44 45 #include <ncurses.h> 46 #include <wchar.h> 47 #ifdef XLUA 48 #include <lua.h> 49 #endif 50 #include "color.h" 51 52 #define NONE_COLOR -2 53 #define DEFAULT_COLOR -1 54 #define BLACK COLOR_BLACK 55 #define RED COLOR_RED 56 #define GREEN COLOR_GREEN 57 #define YELLOW COLOR_YELLOW 58 #define BLUE COLOR_BLUE 59 #define MAGENTA COLOR_MAGENTA 60 #define CYAN COLOR_CYAN 61 #define WHITE COLOR_WHITE 62 63 extern int offscr_sc_rows, offscr_sc_cols; 64 extern int nb_frozen_rows, nb_frozen_cols; 65 66 extern unsigned int curmode; 67 extern struct srange * ranges; 68 extern struct ent ** p; 69 70 void ui_start_screen(); 71 void ui_stop_screen(); 72 int ui_getch(wint_t * wd); 73 int ui_getch_b(wint_t * wd); 74 void ui_clr_header(int row); 75 void ui_refresh_pad(int scroll); 76 void ui_print_mult_pend(); 77 void ui_show_header(); 78 void ui_show_celldetails(); 79 void ui_print_mode(); 80 void ui_do_welcome(); 81 void ui_update(int header); 82 int ui_get_formated_value(struct ent ** p, int col, char * value); 83 void ui_handle_cursor(); 84 void yyerror(char *err); // error routine for yacc (gram.y) 85 void ui_show_text(char * val); 86 #ifdef XLUA 87 void ui_bail(lua_State *L, char * msg); 88 #endif 89 char * ui_query(char * initial_msg); 90 void ui_start_colors(); 91 void ui_sc_msg(char * s, int type, ...); 92 93 void ui_set_ucolor(WINDOW * w, struct ucolor * uc, int bg_override); 94 void ui_show_content(WINDOW * win, int mxrow, int mxcol); 95 void ui_show_sc_row_headings(WINDOW * win, int mxrow); 96 void ui_show_sc_col_headings(WINDOW * win, int mxcol); 97 void ui_add_cell_detail(char * d, struct ent * p1); 98 void ui_write_j(WINDOW * win, const char * word, const unsigned int row, const unsigned int justif); 99 void ui_show_cursor(WINDOW * win); 100 void ui_pause(); 101 void ui_resume(); 102 wchar_t ui_query_opt(wchar_t * initial_msg, wchar_t * valid); 103 void ui_mv_bottom_bar(); 104 #ifdef MOUSE 105 void ui_handle_mouse(MEVENT event); 106 #endif 107