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 range.h 40 * \author Andrés Martinelli <andmarti@gmail.com> 41 * \date 2017-07-18 42 * \brief Header file for range.c 43 */ 44 45 #include "sc.h" 46 47 struct srange { 48 int tlrow; // top left row 49 int tlcol; // top left col 50 int brrow; // bottom right row 51 int brcol; // bottom right col 52 int orig_row; // original row before starting selection 53 int orig_col; // original col before starting selection 54 int startup_row; // row position before entering visual mode 55 int startup_col; // col position before entering visual mode 56 char marks[2]; // marks used for creating the range 57 int selected; 58 struct srange * pnext; 59 }; 60 typedef struct srange srange; 61 62 extern srange * ranges; 63 64 srange * create_range(char c, char d, struct ent * tl, struct ent * br); 65 int find_range(char * name, int len, struct ent * lmatch, struct ent * rmatch, struct range ** rng); 66 67 void unselect_ranges(); 68 void free_ranges (); 69 void del_ranges_by_mark (char c); 70 srange * get_range_by_pos(int pos); 71 srange * get_range_by_marks (char c, char d); 72 int is_range_selected(); 73 srange * get_selected_range(); 74 75 srange * create_custom_range(int tlrow, int tlcol, int brrow, int brcol); 76 void free_custom_range(srange * sr); 77 void clean_range(); 78 79 void add_range(char * name, struct ent_ptr left, struct ent_ptr right, int is_range); 80 void del_range(struct ent * left, struct ent * right); 81