summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrés <andmarti@gmail.com>2022-02-03 14:33:36 -0300
committerAndrés <andmarti@gmail.com>2022-02-03 14:33:36 -0300
commit4494f010d191308b3dc4133e77afb4cab14ee6ca (patch)
tree4b9419707773df2d878ea1ed6d60292e6cc3c89b
parent77fe856adada4b29d9b8cc1135a64eefaf540a3a (diff)
Added ignore_hidden configuration variable. #653 #674
-rw-r--r--CHANGES9
-rw-r--r--src/actions/tags2
-rw-r--r--src/cmds/tags2
-rw-r--r--src/conf.c1
-rwxr-xr-xsrc/doc8
-rw-r--r--src/file.c10
-rw-r--r--src/formats/xlsx.c7
-rwxr-xr-xsrc/gram.y9
-rw-r--r--src/yank.c17
9 files changed, 59 insertions, 6 deletions
diff --git a/CHANGES b/CHANGES
index 6254f93..d058be7 100644
--- a/CHANGES
+++ b/CHANGES
@@ -22,6 +22,12 @@ Save triggers in files
** Added automated tests
C command in EDIT MODE
++ Added ignore_hidden configuration variable to address
+ #674 #653
+ With this hidden rows can be ignored when exporting spreasheets.
+ Useful when exporting the result of a filter.
+ This will also be honored when copy/pasting a range that have hidden rows in it.
+
Changes:
--------
+ Adapt string and number search for multisheet
@@ -72,6 +78,9 @@ fix when using C-r in INSERT_MODE
fix arguments reversed on sc.colrow2a
fix in delete_filters that caused SEGFAULT. Issue 637.
fix in unformat. call to copy_to_undostruct with wrong parameters.
+fix swapped arguments on lsetform
+added string functions to dep graph
+
Pending to make v0.8.3 release
diff --git a/src/actions/tags b/src/actions/tags
index 4fbc704..c524b0a 100644
--- a/src/actions/tags
+++ b/src/actions/tags
@@ -25,7 +25,7 @@ free_filters filter.c /^int free_filters() {$/;" f typeref:typename:int
handle_freeze freeze.c /^void handle_freeze(struct sheet * sh, struct ent * tl_ent, struct ent * br_ent, char value, char/;" f typeref:typename:void
hide_col hide_show.c /^void hide_col(int from_col, int arg) {$/;" f typeref:typename:void
hide_row hide_show.c /^void hide_row(int from_row, int arg) {$/;" f typeref:typename:void
-howmany filter.c /^static int howmany = 0; \/**< how many filters were definedi *\/$/;" v typeref:typename:int file:
+howmany filter.c /^static int howmany = 0; \/**< how many filters were defined *\/$/;" v typeref:typename:int file:
howmany sort.c /^int howmany;$/;" v typeref:typename:int
plot plot.c /^int plot(char * s, int r, int c, int rf, int cf) {$/;" f typeref:typename:int
plotedit plot.c /^int plotedit(wchar_t * s) {$/;" f typeref:typename:int
diff --git a/src/cmds/tags b/src/cmds/tags
index 0b91aee..84aff77 100644
--- a/src/cmds/tags
+++ b/src/cmds/tags
@@ -99,7 +99,7 @@ start_edit_mode cmds_edit.c /^int start_edit_mode(struct block * buf, char type)
start_visualmode cmds_visual.c /^void start_visualmode(int tlrow, int tlcol, int brrow, int brcol) {$/;" f typeref:typename:void
syncref cmds.c /^void syncref(struct sheet * sh, struct enode * e) {$/;" f typeref:typename:void
sync_refs cmds.c /^void sync_refs(struct sheet * sh) {$/;" f typeref:typename:void
-tick cmds.c /^struct ent * tick(char ch) {$/;" f typeref:struct:ent *
+tick cmds.c /^struct ent_ptr * tick(char ch) {$/;" f typeref:struct:ent_ptr *
valid_commands cmds_command.c /^static wchar_t * valid_commands[] = {$/;" v typeref:typename:wchar_t * [] file:
valueize_area cmds.c /^void valueize_area(struct sheet * sh, int sr, int sc, int er, int ec) {$/;" f typeref:typename:void
vert_bottom cmds.c /^struct ent * vert_bottom(struct sheet * sh) {$/;" f typeref:struct:ent *
diff --git a/src/conf.c b/src/conf.c
index 5fa321b..046ef8e 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -64,6 +64,7 @@ const char default_config[] =
"exec_lua=1\n"
"xlsx_readformulas=0\n"
"import_delimited_as_text=0\n"
+ "ignore_hidden=0\n"
"quit_afterload=0\n"
"quiet=0\n"
"numeric_zero=1\n"
diff --git a/src/doc b/src/doc
index 998cd92..d14aa93 100755
--- a/src/doc
+++ b/src/doc
@@ -436,6 +436,8 @@ Commands for handling cell content:
NOTE: If you do an export with the :e command, current file
name stays unchaged.
See :file command for more details.
+ See 'ignore_hidden' configuration variable below to avoid exporting
+ hidden rows.
:e tab {file}
Export the current spreadsheet to tab-separated file {file}.
@@ -1398,6 +1400,12 @@ Commands for handling cell content:
Make the screen cursor follow the active cell. Useful for people
using sc-im with a braille display.
+ 'ignore_hidden' [default off]
+ set this if you want the hidden rows of a spreadsheet to be ignored when exporting them
+ to another format.
+ this will also be used in case you also want to copy/paste a range that have hidden rows in
+ it (for instance, the result of an applied filter).
+
==============================================================================
&Built-in Range Functions&
diff --git a/src/file.c b/src/file.c
index 9ab7e77..f3d0eeb 100644
--- a/src/file.c
+++ b/src/file.c
@@ -1496,11 +1496,13 @@ void export_markdown(char * fname, int r0, int c0, int rn, int cn) {
int dash_num;
int rowfmt;
+ int ignore_hidden = get_conf_int("ignore_hidden");
+
for (row = r0; row <= rn; row++) {
for (rowfmt=0; rowfmt < roman->cur_sh->row_format[row]; rowfmt++) {
// ignore hidden rows
- //if (row_hidden[row]) continue;
+ if (ignore_hidden && roman->cur_sh->row_hidden[row]) continue;
for (pp = ATBL(roman->cur_sh, roman->cur_sh->tbl, row, col = c0); col <= cn; col++, pp++) {
// ignore hidden cols
@@ -1646,11 +1648,13 @@ void export_plain(char * fname, int r0, int c0, int rn, int cn) {
int align = 1;
int rowfmt;
+ int ignore_hidden = get_conf_int("ignore_hidden");
+
for (row = r0; row <= rn; row++) {
for (rowfmt = 0; rowfmt < roman->cur_sh->row_format[row]; rowfmt++) {
// ignore hidden rows
- //if (row_hidden[row]) continue;
+ if (ignore_hidden && roman->cur_sh->row_hidden[row]) continue;
for (pp = ATBL(roman->cur_sh, roman->cur_sh->tbl, row, col = c0); col <= cn; col++, pp++) {
// ignore hidden cols
@@ -1870,7 +1874,9 @@ void export_delim(char * fname, char coldelim, int r0, int c0, int rn, int cn, i
}
}
+ int ignore_hidden = get_conf_int("ignore_hidden");
for (row = r0; row <= rn; row++) {
+ if (ignore_hidden && sh->row_hidden[row]) continue;
for (pp = ATBL(sh, sh->tbl, row, col = c0); col <= cn; col++, pp++) {
int last_valid_col = right_limit(sh, row)->col; // for issue #374
if (col > last_valid_col) continue;
diff --git a/src/formats/xlsx.c b/src/formats/xlsx.c
index 0308d55..048633c 100644
--- a/src/formats/xlsx.c
+++ b/src/formats/xlsx.c
@@ -569,6 +569,7 @@ int export_xlsx(char * filename) {
struct roman * roman = session->cur_doc;
lxw_workbook * workbook = workbook_new(filename);
+ int ignore_hidden = get_conf_int("ignore_hidden");
struct sheet * sh = roman->first_sh;
while (sh != NULL) {
@@ -578,7 +579,10 @@ int export_xlsx(char * filename) {
insert_row(sh, 0); //add a row so that scim formulas apply to excel
for (row = 0; row <= sh->maxrow+1; row++)
- for (pp = ATBL(sh, sh->tbl, row, col = 0); col <= sh->maxcol; col++, pp++)
+ for (pp = ATBL(sh, sh->tbl, row, col = 0); col <= sh->maxcol; col++, pp++) {
+ // ignore hidden rows
+ if (ignore_hidden && sh->row_hidden[row]) continue;
+
if (*pp) {
// Check format here
lxw_format * format = workbook_add_format(workbook);
@@ -739,6 +743,7 @@ int export_xlsx(char * filename) {
}
/* TODO: handle hidden rows and columns? */
}
+ }
sh->currow = 0;
int_deleterow(sh, 0, 1); /* delete the added row */
sh->currow = bkp_currow;
diff --git a/src/gram.y b/src/gram.y
index 579f8aa..4d53654 100755
--- a/src/gram.y
+++ b/src/gram.y
@@ -271,6 +271,8 @@ token S_YANKCOL
%token K_OVERLAP
%token K_NOOVERLAP
%token K_INPUT_BAR_BOTTOM
+%token K_IGNORE_HIDDEN
+%token K_NOIGNORE_HIDDEN
%token K_UNDERLINE_GRID
%token K_TRUNCATE
%token K_NOTRUNCATE
@@ -1607,6 +1609,13 @@ setitem :
{ if ($3 == 0) parse_str(user_conf_d, "half_page_scroll=0", TRUE);
else parse_str(user_conf_d, "half_page_scroll=1", TRUE); }
| K_NOHALF_PAGE_SCROLL { parse_str(user_conf_d, "half_page_scroll=0", TRUE); }
+
+ | K_IGNORE_HIDDEN { parse_str(user_conf_d, "ignore_hidden=1", TRUE); }
+ | K_IGNORE_HIDDEN '=' NUMBER
+ { if ($3 == 0) parse_str(user_conf_d, "ignore_hidden=0", TRUE);
+ else parse_str(user_conf_d, "ignore_hidden=1", TRUE); }
+ | K_NOIGNORE_HIDDEN { parse_str(user_conf_d, "ignore_hidden=0", TRUE); }
+
| K_QUIET '=' NUMBER {
if ($3 == 0) parse_str(user_conf_d, "quiet=0", TRUE);
else parse_str(user_conf_d, "quiet=1", TRUE); }
diff --git a/src/yank.c b/src/yank.c
index 0ca40cb..bd53b97 100644
--- a/src/yank.c
+++ b/src/yank.c
@@ -164,15 +164,23 @@ void yank_area(struct sheet * sh, int tlrow, int tlcol, int brrow, int brcol, ch
type_of_yank = type;
yank_arg = arg;
free_yanklist();
+ int ignore_hidden = get_conf_int("ignore_hidden");
struct ent * e_ori;
// ask for memory to keep struct ent_ptr * and struct ent * for the whole range
struct ent_ptr * y_cells = (struct ent_ptr *) calloc((brrow-tlrow+1)*(brcol-tlcol+1), sizeof(struct ent_ptr));
struct ent * y_cells_vp = (struct ent *) calloc((brrow-tlrow+1)*(brcol-tlcol+1), sizeof(struct ent));
- for (r = tlrow; r <= brrow; r++)
+
+ // work on issue 674
+ // if ignore_hidden is set we need to keep the number of hidden rows in case
+ long hid = 0;
+
+ for (r = tlrow; r <= brrow; r++) {
+ if (sh->row_hidden[r]) { hid++; continue; }
for (c = tlcol; c <= brcol; c++) {
e_ori = *ATBL(sh, sh->tbl, r, c);
+
if (e_ori == NULL) continue;
// initialize the 'ent'
@@ -187,8 +195,15 @@ void yank_area(struct sheet * sh, int tlrow, int tlcol, int brrow, int brcol, ch
(y_cells)->vp->row = e_ori->row;
(y_cells)->vp->col = e_ori->col;
+ // work on issue 674
+ // if ignore_hidden is set we substract that number to the internal row so all the pasted rows are
+ // adjacent. this is a special case when we're pulling hidden rows and we want to ignore those hidden ranges
+ // (example if yanking a result of a filter)
+ if (ignore_hidden) (y_cells)->vp->row -= hid;
+
add_ent_to_yanklist(y_cells++);
}
+ }
// this takes care of a potential memory leak if no ent was added to yanklist
// for instance when deleting empty row
if (! yanked_cells) {