summaryrefslogtreecommitdiffstats
path: root/src/shift.c
diff options
context:
space:
mode:
authorandmarti1424 <scim.spreadsheet@gmail.com>2016-05-16 20:21:12 -0300
committerandmarti1424 <scim.spreadsheet@gmail.com>2016-05-16 20:21:12 -0300
commitd44df1b0f0882d5433464e6984aec1f90983ceee (patch)
tree1650af10245431ac37ea2c1ac7188c6da9189948 /src/shift.c
parent3ac62bdee4de7549f330e8374005034edba8947d (diff)
Cleaned code
Diffstat (limited to 'src/shift.c')
-rw-r--r--src/shift.c72
1 files changed, 11 insertions, 61 deletions
diff --git a/src/shift.c b/src/shift.c
index 1b07d51..e8c1efe 100644
--- a/src/shift.c
+++ b/src/shift.c
@@ -6,7 +6,6 @@
#include "cmds.h"
// shift a range of 'ENTS'
-
void shift_range(int delta_rows, int delta_cols, int tlrow, int tlcol, int brrow, int brcol) {
currow = tlrow;
curcol = tlcol;
@@ -21,49 +20,17 @@ void shift_range(int delta_rows, int delta_cols, int tlrow, int tlcol, int brrow
}
// shift cells down
-// TODO rewrite without using copyent
+// REVISED
void shift_cells_down(int deltarows, int deltacols) {
int r, c;
- struct ent **pp;
- //int lim = maxrow - currow + 1;
+ struct ent ** pp;
int lim = maxrow - currow + deltarows;
if (currow > maxrow) maxrow = currow;
maxrow += deltarows;
- //lim = maxrow - lim;
lim = maxrow - lim + deltarows - 1;
if ((maxrow >= maxrows) && !growtbl(GROWROW, maxrow, 0))
return;
- /*
- int r, c;
- struct ent **pp;
- register struct ent * p;
- register struct ent *n;
- int lim = maxrow - currow + 1;
- if (currow > maxrow) maxrow = currow;
- maxrow += deltarows;
-
- lim = maxrow - lim;
- if ((maxrow >= maxrows) && !growtbl(GROWROW, maxrow, 0))
- return;
-
- for (r = maxrow; r > lim; r--) {
- for (c = curcol; c < curcol + deltacols; c++) {
- p = *ATBL(tbl, r - deltarows, c);
- if (p) {
- n = lookat(r, c);
- copyent(n, p, 1, 0, 0, 0, r - deltarows, c, 0);
- n->row += deltarows;
- p = (struct ent *)0;
-
- pp = ATBL(tbl, r - deltarows, c);
- clearent(*pp);
- }
- }
- }
- return;
-*/
-
for (r = maxrow; r > currow; r--) {
for (c = curcol; c < curcol + deltacols; c++) {
pp = ATBL(tbl, r, c);
@@ -82,27 +49,10 @@ void shift_cells_down(int deltarows, int deltacols) {
// shift cells right
-// revised
+// REVISED
void shift_cells_right(int deltarows, int deltacols) {
int r, c;
- struct ent **pp;
-
- /*
- int r, j, c;
- register struct ent *p;
- register struct ent *n;
- for (j = 0; j < deltacols; j++)
- for (r = currow; r < currow + deltarows; r++)
- for (c = maxcol; c >= curcol; c--) {
- if ((p = *ATBL(tbl, r, c))) {
- n = lookat(r, c + 1);
- (void) copyent(n, p, 0, 1, r, 0, maxrow, maxcol, 0);
- n->col++;
- pp = ATBL(tbl, r, c);
- clearent(*pp);
- }
- }
- */
+ struct ent ** pp;
if (curcol + deltacols > maxcol)
maxcol = curcol + deltacols;
@@ -121,10 +71,13 @@ void shift_cells_right(int deltarows, int deltacols) {
for (c = curcol; c < curcol + deltacols; c++, pp++)
*pp = (struct ent *) 0;
}
-
return;
}
+
+
+
+
// shift cells up
// TODO rewrite without using copyent
void shift_cells_up(int deltarows, int deltacols) {
@@ -132,9 +85,7 @@ void shift_cells_up(int deltarows, int deltacols) {
register struct ent * n;
register struct ent * p;
int r, c, i;
-
//if (currow + deltarows - 1 > maxrow) return;
-
// Delete cell content
for (i = 0; i < deltarows; i++)
for (r = currow; r < maxrow; r++)
@@ -163,9 +114,9 @@ void shift_cells_up(int deltarows, int deltacols) {
// TODO rewrite without using copyent
void shift_cells_left(int deltarows, int deltacols) {
int r, j, c;
- register struct ent *p;
- register struct ent *n;
- struct ent **pp;
+ register struct ent * p;
+ register struct ent * n;
+ struct ent ** pp;
for (j = 0; j < deltacols; j++)
for (r = currow; r < currow + deltarows; r++)
for (c = curcol; c < maxcol; c++) {
@@ -187,4 +138,3 @@ void shift_cells_left(int deltarows, int deltacols) {
}
return;
}
-