void setcolwidth(int col) /* Sets the new column width for a selected column */ { int width, row; writeprompt(MSGCOLWIDTH); if (!getint(&width, MINCOLWIDTH, MAXCOLWIDTH)) return; colwidth[col] = width; setrightcol(); if (rightcol < col) { rightcol = col; setleftcol(); setrightcol(); } for (row = 0; row <= lastrow; row++) { if ((cell[col][row] != NULL) && (cell[col][row]->attrib == TEXT)) clearoflags(col + 1, row, NOUPDATE); else clearoflags(col, row, NOUPDATE); updateoflags(col, row, NOUPDATE); } displayscreen(NOUPDATE); changed = TRUE; } /* setcolwidth */
void deletecell(int col, int row, int display) /* Deletes a cell */ { CELLPTR cellptr = cell[col][row]; if (cellptr == NULL) return; switch (cellptr->attrib) { case TEXT : memleft += textcellsize(cellptr->v.text); clearoflags(col + 1, row, display); break; case VALUE : memleft += valuecellsize; break; case FORMULA : memleft += formulacellsize(cellptr->v.f.formula); break; } /* switch */ format[col][row] &= ~OVERWRITE; free(cell[col][row]); cell[col][row] = NULL; if (col == lastcol) setlastcol(); if (row == lastrow) setlastrow(); updateoflags(col, row, display); changed = TRUE; } /* deletecell */
void insertcol(int col) /* Inserts a column */ { int counter, row; if (lastcol == MAXCOLS - 1) { for (counter = 0; counter <= lastrow; counter++) deletecell(lastcol, counter, NOUPDATE); printfreemem(); } if (col != MAXCOLS - 1) { movmem(&cell[col][0], &cell[col + 1][0], MAXROWS * sizeof(CELLPTR) * (MAXCOLS - col - 1)); movmem(&format[col][0], &format[col + 1][0], MAXROWS * (MAXCOLS - col - 1)); movmem(&colwidth[col], &colwidth[col + 1], MAXCOLS - col - 1); } setmem(&cell[col][0], MAXROWS * sizeof(CELLPTR), 0); setmem(&format[col][0], MAXROWS, DEFAULTFORMAT); colwidth[col] = DEFAULTWIDTH; lastcol = MAXCOLS - 1; setlastcol(); setrightcol(); if (curcol > rightcol) { rightcol++; setleftcol(); } for (counter = 0; counter <= lastcol; counter++) { for (row = 0; row <= lastrow; row++) { if ((cell[counter][row] != NULL) && (cell[counter][row]->attrib == FORMULA)) fixformula(counter, row, COLADD, col); updateoflags(col, row, NOUPDATE); } } while (col <= rightcol) displaycol(col++, NOUPDATE); changed = TRUE; recalc(); } /* insertcol */