summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandmarti1424 <andmarti@gmail.com>2017-02-21 23:53:57 -0300
committerandmarti1424 <andmarti@gmail.com>2017-02-21 23:53:57 -0300
commit035ce82dddbb36afad6d2bfd1bf6485fde9c3c82 (patch)
tree7f1256eb7d8c11598d288f0489a5856c4ae59b6a
parentc31fdb37353029a46148eefb72605a6fe7a64ad6 (diff)
changes in update of freeze row
-rw-r--r--src/cmds.c250
-rw-r--r--src/cmds_normal.c19
-rw-r--r--src/color.c2
-rw-r--r--src/screen.c101
4 files changed, 202 insertions, 170 deletions
diff --git a/src/cmds.c b/src/cmds.c
index 63f88cf..dd5bb54 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -1084,6 +1084,117 @@ void clearent(struct ent * v) {
return;
}
+// moves curcol back one displayed column
+struct ent * back_col(int arg) {
+ extern int center_hidden_cols;
+ int freeze = freeze_ranges && (freeze_ranges->type == 'c' || freeze_ranges->type == 'a') ? 2 : 0;
+ int c = curcol;
+
+ while (--arg >= 0) {
+ if (c)
+ c--;
+ else {
+ sc_info ("At column A");
+ break;
+ }
+ while ((col_hidden[c] || (freeze && c >= freeze_ranges->br->col
+ && c < freeze_ranges->br->col + center_hidden_cols)) && c)
+ c--;
+ }
+
+ return lookat(currow, c);
+}
+
+/* moves curcol forward one displayed column */
+struct ent * forw_col(int arg) {
+ int c = curcol;
+ extern int center_hidden_cols;
+ int freeze = freeze_ranges && (freeze_ranges->type == 'c' || freeze_ranges->type == 'a') ? 1 : 0;
+
+ while (--arg >= 0) {
+ if (c < maxcols - 1)
+ c++;
+ else
+ if (! growtbl(GROWCOL, 0, arg)) { /* get as much as needed */
+ sc_debug("cannot grow");
+ return lookat(currow, curcol);
+ } else
+ c++;
+ while ((col_hidden[c] || (freeze && c >= freeze_ranges->br->col
+ && c < freeze_ranges->br->col + center_hidden_cols)) && (c < maxcols - 1))
+ c++;
+
+ }
+ return lookat(currow, c);
+}
+
+/* moves currow forward one displayed row */
+struct ent * forw_row(int arg) {
+ int r = currow;
+ extern int center_hidden_rows;
+ int freeze = freeze_ranges && (freeze_ranges->type == 'r' || freeze_ranges->type == 'a') ? 1 : 0;
+
+ while (arg--) {
+ if (r < maxrows - 1)
+ r++;
+ else {
+ if (! growtbl(GROWROW, arg, 0)) {
+ sc_debug("cannot grow");
+ return lookat(currow, curcol);
+ } else
+ r++;
+ }
+ while ((row_hidden[r] && (freeze && r >= freeze_ranges->br->row && r < freeze_ranges->br->row + center_hidden_rows)) && (r < maxrows - 1)) {
+ r++;
+ }
+ }
+ return lookat(r, curcol);
+}
+
+/* moves currow backward one displayed row */
+struct ent * back_row(int arg) {
+ int r = currow;
+ extern int center_hidden_rows;
+ int freeze = freeze_ranges && (freeze_ranges->type == 'r' || freeze_ranges->type == 'a') ? 1 : 0;
+
+ while (arg--) {
+ if (r) r--;
+ else {
+ sc_info("At row zero");
+ break;
+ }
+ while ((row_hidden[r] || (freeze && r >= freeze_ranges->br->row
+ && r < freeze_ranges->br->row + center_hidden_rows)) && r)
+ r--;
+ }
+ return lookat(r, curcol);
+}
+
+struct ent * go_home() {
+ return lookat(0, 0);
+}
+
+// if ticks a cell, returns struct ent *
+// if ticks a range, return struct ent * to top left cell
+struct ent * tick(char c) {
+ //tick cell
+ int r = get_mark(c)->row;
+ if (r != -1)
+ return lookat(r, get_mark(c)->col);
+
+ // tick range
+ if (curmode != VISUAL_MODE) {
+ get_mark(c)->rng->selected = 1;
+ return lookat(get_mark(c)->rng->tlrow, get_mark(c)->rng->tlcol);
+ }
+ return NULL;
+}
+
+
+
+
+
+// FIXME to handle freeze rows/cols
void scroll_left(int n) {
while (n--) {
if (! offscr_sc_cols ) {
@@ -1105,6 +1216,7 @@ void scroll_left(int n) {
return;
}
+// FIXME to handle freeze rows/cols
void scroll_right(int n) {
while (n--) {
// This while statement allow the cursor to shift to the right when the
@@ -1117,6 +1229,7 @@ void scroll_right(int n) {
return;
}
+// FIXME to handle freeze rows/cols
void scroll_down(int n) {
while (n--) {
if (currow == offscr_sc_rows) {
@@ -1128,6 +1241,7 @@ void scroll_down(int n) {
return;
}
+// FIXME to handle freeze rows/cols
void scroll_up(int n) {
while (n--) {
if (offscr_sc_rows)
@@ -1142,12 +1256,14 @@ void scroll_up(int n) {
return;
}
+// FIXME to handle freeze rows/cols
struct ent * left_limit() {
int c = 0;
while ( col_hidden[c] && c < curcol ) c++;
return lookat(currow, c);
}
+// FIXME to handle freeze rows/cols
struct ent * right_limit() {
register struct ent *p;
int c = maxcols - 1;
@@ -1155,12 +1271,14 @@ struct ent * right_limit() {
return lookat(currow, c);
}
+// FIXME to handle freeze rows/cols
struct ent * goto_top() {
int r = 0;
- while ( row_hidden[r] && r < currow ) r++;
+ while ( row_hidden[r] && r < currow ) r++;
return lookat(r, curcol);
}
+// FIXME to handle freeze rows/cols
struct ent * goto_bottom() {
register struct ent *p;
int r = maxrows - 1;
@@ -1168,92 +1286,7 @@ struct ent * goto_bottom() {
return lookat(r, curcol);
}
-// moves curcol back one displayed column
-struct ent * back_col(int arg) {
- extern int center_hidden_cols;
- int freeze = freeze_ranges && (freeze_ranges->type == 'c' || freeze_ranges->type == 'a') ? 2 : 0;
- int c = curcol;
-
- while (--arg >= 0) {
- if (c)
- c--;
- else {
- sc_info ("At column A");
- break;
- }
- while ((col_hidden[c] || (freeze && c >= freeze_ranges->br->col
- && c < freeze_ranges->br->col + center_hidden_cols)) && c)
- c--;
- }
-
- return lookat(currow, c);
-}
-
-/* moves curcol forward one displayed column */
-struct ent * forw_col(int arg) {
- int c = curcol;
- extern int center_hidden_cols;
- int freeze = freeze_ranges && (freeze_ranges->type == 'c' || freeze_ranges->type == 'a') ? 1 : 0;
-
- while (--arg >= 0) {
- if (c < maxcols - 1)
- c++;
- else
- if (! growtbl(GROWCOL, 0, arg)) { /* get as much as needed */
- sc_error("cannot grow");
- return lookat(currow, curcol);
- } else
- c++;
- while ((col_hidden[c] || (freeze && c >= freeze_ranges->br->col
- && c < freeze_ranges->br->col + center_hidden_cols)) && (c < maxcols - 1))
- c++;
-
- }
- return lookat(currow, c);
-}
-
-/* moves currow forward one displayed row */
-struct ent * forw_row(int arg) {
- int r = currow;
- extern int center_hidden_rows;
- int freeze = freeze_ranges && (freeze_ranges->type == 'r' || freeze_ranges->type == 'a') ? 1 : 0;
-
- while (arg--) {
- if (r < maxrows - 1)
- r++;
- else {
- if (! growtbl(GROWROW, arg, 0)) {
- sc_error("cannot grow");
- return lookat(currow, curcol);
- } else
- r++;
- }
- while ((row_hidden[r] || (freeze && r >= freeze_ranges->br->row
- && r < freeze_ranges->br->row + center_hidden_rows)) && (r < maxrows - 1))
- r++;
- }
- return lookat(r, curcol);
-}
-
-/* moves currow backward one displayed row */
-struct ent * back_row(int arg) {
- int r = currow;
- extern int center_hidden_rows;
- int freeze = freeze_ranges && (freeze_ranges->type == 'r' || freeze_ranges->type == 'a') ? 1 : 0;
-
- while (arg--) {
- if (r) r--;
- else {
- sc_info("At row zero");
- break;
- }
- while ((row_hidden[r] || (freeze && r >= freeze_ranges->br->row
- && r < freeze_ranges->br->row + center_hidden_rows)) && r)
- r--;
- }
- return lookat(r, curcol);
-}
-
+// FIXME to handle freeze rows/cols
struct ent * go_end() {
int r = currow, c = curcol;
int raux = r, caux = c;
@@ -1274,26 +1307,7 @@ struct ent * go_end() {
return NULL;
}
-struct ent * go_home() {
- return lookat(0, 0);
-}
-
-// if ticks a cell, returns struct ent *
-// if ticks a range, return struct ent * to top left cell
-struct ent * tick(char c) {
- //tick cell
- int r = get_mark(c)->row;
- if (r != -1)
- return lookat(r, get_mark(c)->col);
-
- // tick range
- if (curmode != VISUAL_MODE) {
- get_mark(c)->rng->selected = 1;
- return lookat(get_mark(c)->rng->tlrow, get_mark(c)->rng->tlcol);
- }
- return NULL;
-}
-
+// FIXME to handle freeze rows/cols
struct ent * go_forward() {
int r = currow, c = curcol;
int r_ori = r, c_ori = c;
@@ -1314,6 +1328,7 @@ struct ent * go_forward() {
return lookat(r_ori, c_ori);
}
+// FIXME to handle freeze rows/cols
struct ent * go_backward() {
int r = currow, c = curcol;
int r_ori = r, c_ori = c;
@@ -1334,30 +1349,36 @@ struct ent * go_backward() {
return lookat(r_ori, c_ori);
}
+// FIXME to handle freeze rows/cols
struct ent * vert_top() {
return currow < LINES - RESROW - 1 ? lookat(0, curcol) : lookat(offscr_sc_rows, curcol);
}
+// FIXME to handle freeze rows/cols
struct ent * vert_middle() {
int bottom = offscr_sc_rows + LINES - RESROW - 2;
if (bottom > maxrow) bottom = maxrow;
return lookat( ((currow < LINES - RESROW - 1 ? 0 : offscr_sc_rows) + bottom) / 2, curcol);
}
+// FIXME to handle freeze rows/cols
struct ent * vert_bottom() {
int c = offscr_sc_rows + LINES - RESROW - 2;
if (c > maxrow) c = maxrow;
return lookat(c, curcol);
}
+// FIXME to handle freeze rows/cols
struct ent * go_bol() {
return lookat(currow, offscr_sc_cols);
}
+// FIXME to handle freeze rows/cols
struct ent * go_eol() {
return lookat(currow, offscr_sc_cols + calc_offscr_sc_cols() - 1);
}
+// FIXME to handle freeze rows/cols
struct ent * horiz_middle() {
int i;
int ancho = rescol;
@@ -1371,6 +1392,21 @@ struct ent * horiz_middle() {
return NULL;
}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
void auto_justify(int ci, int cf, int min) {
// column width is not set below the min value
int r, c, sum = 0;
diff --git a/src/cmds_normal.c b/src/cmds_normal.c
index bb425c2..42f0d23 100644
--- a/src/cmds_normal.c
+++ b/src/cmds_normal.c
@@ -35,15 +35,16 @@ void do_normalmode(struct block * buf) {
switch (buf->value) {
case L'A':
- //add_frange(lookat(0, 0), lookat(0, 3));
- //add_frange(lookat(0, 1), lookat(0, 3));
- //add_frange(lookat(0, 4), lookat(0, 6));
- //add_frange(lookat(0, 27), lookat(0, 28));
- //add_frange(lookat(0, 0), lookat(4, 0));
- //add_frange(lookat(14, 0), lookat(18, 0));
- //add_frange(lookat(24, 0), lookat(24, 0));
- //add_frange(lookat(24, 0), lookat(26, 0));
- //update(FALSE);
+ //add_frange(lookat(0, 0), lookat(0, 3), 'c');
+ //add_frange(lookat(0, 1), lookat(0, 3), 'c');
+ //add_frange(lookat(0, 4), lookat(0, 6), 'c');
+ //add_frange(lookat(0, 27), lookat(0, 28), 'c');
+ //add_frange(lookat(0, 0), lookat(4, 0), 'r');
+ add_frange(lookat(4, 0), lookat(8, 0), 'r');
+ //add_frange(lookat(14, 0), lookat(18, 0), 'r');
+ //add_frange(lookat(24, 0), lookat(24, 0), 'r');
+ //add_frange(lookat(24, 0), lookat(26, 0), 'r');
+ update(FALSE);
break;
/* TEST
diff --git a/src/color.c b/src/color.c
index 1549eff..f8ead1a 100644
--- a/src/color.c
+++ b/src/color.c
@@ -41,7 +41,7 @@ void start_default_ucolors() {
ucolors[ DEFAULT ].bg = BLACK;
ucolors[ HEADINGS ].fg = BLACK;
ucolors[ HEADINGS ].bg = CYAN;
- ucolors[ WELCOME ].fg = CYAN;
+ ucolors[ WELCOME ].fg = MAGENTA;
ucolors[ WELCOME ].bg = BLACK;
ucolors[ CELL_SELECTION ].fg = BLUE; // cell selection in headings
ucolors[ CELL_SELECTION ].bg = WHITE;
diff --git a/src/screen.c b/src/screen.c
index e438d3a..09ba2a4 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -141,12 +141,14 @@ void update(int header) {
}
// Calculate hidden rows and columns
- // mxcol-1: las 'sc_col' in the screen
- // mxrow-1: las 'sc_row' in the screen
+ // mxcol-1: 'sc_col' in the screen
+ // mxrow-1: 'sc_row' in the screen
int off_cols = calc_offscr_sc_cols();
int off_rows = calc_offscr_sc_rows();
int mxcol = offscr_sc_cols + off_cols - 1;
int mxrow = offscr_sc_rows + off_rows - 1;
+ sc_debug("off_rows:%d, mxrow:%d, offscr_sc_rows:%d", off_rows, mxrow, offscr_sc_rows);
+ sc_info("");
/* You can't hide the last row or col */
while (row_hidden[currow])
@@ -346,22 +348,18 @@ void show_sc_row_headings(WINDOW * win, int mxrow) {
int i;
int freeze = freeze_ranges && (freeze_ranges->type == 'r' || freeze_ranges->type == 'a') ? 1 : 0;
- for (i = 0; i <= mxrow; i++) {
+ //FIXME
+ //for (i = 0; i < mxrow && i < maxrows; i++) {
+ for (i = 0; i < mxrow; i++) {
// print rows in case freezen rows are before offscr_sc_rows
- if (i < offscr_sc_rows
- && !(freeze
- && i >= freeze_ranges->tl->row
- && i <= freeze_ranges->br->row)) continue;
+ if (i < offscr_sc_rows && !(freeze && i >= freeze_ranges->tl->row && i <= freeze_ranges->br->row)) continue;
if (row_hidden[i]) continue;
// skip center_hidden_rows
- if (freeze &&
- (
- (currow >= freeze_ranges->br->row && i > freeze_ranges->br->row && i <= freeze_ranges->br->row + center_hidden_rows)
- ||
- (currow <= freeze_ranges->tl->row && i < freeze_ranges->tl->row && i >= freeze_ranges->tl->row - center_hidden_rows)
- )
+ if (freeze && (
+ (currow >= freeze_ranges->br->row && i > freeze_ranges->br->row && i <= freeze_ranges->br->row + center_hidden_rows) ||
+ (currow <= freeze_ranges->tl->row && i < freeze_ranges->tl->row && i >= freeze_ranges->tl->row - center_hidden_rows))
) continue;
srange * s = get_selected_range();
@@ -398,20 +396,14 @@ void show_sc_col_headings(WINDOW * win, int mxcol) {
for (i = 0; i <= mxcol; i++) {
// print cols in case freezen columns are before offscr_sc_cols
- if (i < offscr_sc_cols
- && !(freeze
- && i >= freeze_ranges->tl->col
- && i <= freeze_ranges->br->col)) continue;
+ if (i < offscr_sc_cols && !(freeze && i >= freeze_ranges->tl->col && i <= freeze_ranges->br->col)) continue;
if (col_hidden[i]) continue;
// skip center_hidden_cols
- if (freeze &&
- (
- (curcol >= freeze_ranges->br->col && i > freeze_ranges->br->col && i <= freeze_ranges->br->col + center_hidden_cols)
- ||
- (curcol <= freeze_ranges->tl->col && i < freeze_ranges->tl->col && i >= freeze_ranges->tl->col - center_hidden_cols)
- )
+ if (freeze && (
+ (curcol >= freeze_ranges->br->col && i > freeze_ranges->br->col && i <= freeze_ranges->br->col + center_hidden_cols) ||
+ (curcol <= freeze_ranges->tl->col && i < freeze_ranges->tl->col && i >= freeze_ranges->tl->col - center_hidden_cols))
) continue;
int k = fwidth[i] / 2;
@@ -438,15 +430,22 @@ void show_sc_col_headings(WINDOW * win, int mxcol) {
// Show the content of the cells
void show_content(WINDOW * win, int mxrow, int mxcol) {
-
register struct ent ** p;
int row, col;
int q_row_hidden = 0;
int freezer = freeze_ranges && (freeze_ranges->type == 'r' || freeze_ranges->type == 'a') ? 1 : 0;
int freezec = freeze_ranges && (freeze_ranges->type == 'c' || freeze_ranges->type == 'a') ? 1 : 0;
+ //FIXME
+ //for (row = 0; row < mxrow && row < maxrows; row++) {
for (row = 0; row < mxrow; row++) {
if (row < offscr_sc_rows
+ && (freezer
+ && row >= freeze_ranges->tl->row
+ && row <= freeze_ranges->br->row)) {
+ q_row_hidden--;
+ continue;
+ } else if (row < offscr_sc_rows
&& !(freezer
&& row >= freeze_ranges->tl->row
&& row <= freeze_ranges->br->row)) {
@@ -459,13 +458,9 @@ void show_content(WINDOW * win, int mxrow, int mxcol) {
}
// skip center_hidden_cols
- if (freezer &&
- (
- (row >= freeze_ranges->br->row && row > freeze_ranges->br->row && row <= freeze_ranges->br->row + center_hidden_rows)
- ||
- (row <= freeze_ranges->tl->row && row < freeze_ranges->tl->row && row >= freeze_ranges->tl->row - center_hidden_rows)
- )
- ) {
+ if (freezer && (
+ (row >= freeze_ranges->br->row && row > freeze_ranges->br->row && row <= freeze_ranges->br->row + center_hidden_rows) ||
+ (row <= freeze_ranges->tl->row && row < freeze_ranges->tl->row && row >= freeze_ranges->tl->row - center_hidden_rows))) {
q_row_hidden++;
continue;
}
@@ -475,7 +470,7 @@ void show_content(WINDOW * win, int mxrow, int mxcol) {
int fieldlen;
col = 0;
- for (p = ATBL(tbl, row, 0); col <= mxcol;
+ for (p = ATBL(tbl, row, 0); col < mxcol;
p += nextcol - col, col = nextcol, c += fieldlen) {
nextcol = col + 1;
@@ -497,12 +492,8 @@ void show_content(WINDOW * win, int mxrow, int mxcol) {
// skip center_hidden_cols
if (freezec &&
- (
- (col >= freeze_ranges->br->col && col > freeze_ranges->br->col && col <= freeze_ranges->br->col + center_hidden_cols)
- ||
- (col <= freeze_ranges->tl->col && col < freeze_ranges->tl->col && col >= freeze_ranges->tl->col - center_hidden_cols)
- )
- ) {
+ ((col >= freeze_ranges->br->col && col > freeze_ranges->br->col && col <= freeze_ranges->br->col + center_hidden_cols) ||
+ (col <= freeze_ranges->tl->col && col < freeze_ranges->tl->col && col >= freeze_ranges->tl->col - center_hidden_cols))) {
c -= fieldlen;
continue;
}
@@ -563,7 +554,6 @@ void show_content(WINDOW * win, int mxrow, int mxcol) {
#endif
}
-
char num [FBUFLEN] = "";
char text[FBUFLEN] = "";
wchar_t out [FBUFLEN] = L"";
@@ -826,12 +816,14 @@ int calc_offscr_sc_cols() {
} else {
// Try to put the cursor in the center of the screen
col = (COLS - rescol - fwidth[curcol]) / 2 + rescol;
- if (freeze) center_hidden_cols = curcol;
- else offscr_sc_cols = curcol;
+ //if (freeze) center_hidden_cols = curcol;
+ //else
+ offscr_sc_cols = curcol;
for (i=curcol-1; i >= 0 && col-fwidth[i] - 1 > rescol; i--) {
- if (freeze) center_hidden_cols--;
- else offscr_sc_cols--;
+ //if (freeze) center_hidden_cols--;
+ //else
+ offscr_sc_cols--;
// if its shown, we count it, else continue.
if (! col_hidden[i] && !freeze)
@@ -995,6 +987,7 @@ int calc_offscr_sc_rows() {
// pick up row counts
if (offscr_sc_rows - 1 <= currow)
+ // FIXME
for (i = 0, rows = 0, row=RESROW; i < maxrows && row < LINES; i++) {
if (i < offscr_sc_rows
&& ! (freeze && i >= freeze_ranges->tl->row && i <= freeze_ranges->br->row)) continue;
@@ -1003,7 +996,7 @@ int calc_offscr_sc_rows() {
else if (freeze && i < freeze_ranges->tl->row && i > freeze_ranges->tl->row - center_hidden_rows) continue;
rows++;
- if (i == maxrows - 1) return rows+1;
+ // if (i == maxrows - 1) return rows+1;
if (! row_hidden[i]) row++;
}
// get off screen rows
@@ -1011,8 +1004,7 @@ int calc_offscr_sc_rows() {
|| (freeze && currow < freeze_ranges->tl->row &&
currow >= freeze_ranges->tl->row - center_hidden_rows)
) {
- //if (freeze) sc_debug("off:%d, center:%d, rows:%d, currow:%d, tl:%d, br:%d", offscr_sc_rows, center_hidden_rows, rows, currow,
- // freeze_ranges->tl->row, freeze_ranges->br->row);
+
// move up
if (offscr_sc_rows - 1 == currow) {
if (freeze && offscr_sc_rows + rows + center_hidden_rows >= freeze_ranges->br->row
@@ -1042,12 +1034,15 @@ int calc_offscr_sc_rows() {
// Try to put the cursor in the center of the screen
row = (LINES - RESROW) / 2 + RESROW;
- if (freeze) center_hidden_rows = currow;
- else offscr_sc_rows = currow;
+ //if (freeze) center_hidden_rows = currow;
+ //else
+ offscr_sc_rows = currow;
for (i=currow-1; i >= 0 && row - 1 > RESROW && i < maxrows; i--) {
- if (freeze) center_hidden_rows--;
- else offscr_sc_rows--;
+ //if (freeze)
+ //center_hidden_rows--;
+ //else
+ offscr_sc_rows--;
// if its shown, we count it, else continue.
if (!row_hidden[i] && !freeze) row--;
@@ -1067,7 +1062,7 @@ int calc_offscr_sc_rows() {
else if (freeze && i < freeze_ranges->tl->row && i > freeze_ranges->tl->row - center_hidden_rows) continue;
rows++;
- if (i == maxrows - 1) return rows+1;
+ // if (i == maxrows - 1) return rows+1;
if (! row_hidden[i]) row++;
}
}
@@ -1076,6 +1071,6 @@ int calc_offscr_sc_rows() {
currow <= freeze_ranges->br->row + center_hidden_rows) {
center_hidden_rows--;
}
-
- return rows + center_hidden_rows;
+ //if (freeze) rows -= freeze_ranges->br->row - freeze_ranges->tl->row;
+ return rows; //+ center_hidden_rows;
}