/* Turbo C - (C) Copyright 1987, 1988 by Borland International */
#include <string.h>
#include <mem.h>
#include <stdio.h>
#include <math.h>
#include <io.h>
#include <fcntl.h>
#include <conio.h>
#include "mcalc.h"
char *name = MSGNAME;
void moverowup(void)
/* Moves up 1 row */
{
displaycell(curcol, currow, NOHIGHLIGHT, NOUPDATE);
if (currow > toprow)
currow--;
else if (toprow != 0)
{
scroll(DOWN, 1, LEFTMARGIN + 1, 3, 80, SCREENROWS + 2, WHITE);
displayrow(--toprow, NOUPDATE);
currow--;
setbottomrow();
}
} /* moverowup */
void moverowdown(void)
/* Moves down one row */
{
displaycell(curcol, currow, NOHIGHLIGHT, NOUPDATE);
if (currow < bottomrow)
currow++;
else if (bottomrow < (MAXROWS - 1))
{
scroll(UP, 1, LEFTMARGIN + 1, 3, 80, SCREENROWS + 2, WHITE);
toprow++;
currow++;
setbottomrow();
displayrow(bottomrow, NOUPDATE);
}
} /* moverowdown */
void movecolleft(void)
/* Moves left one column */
{
int col, oldleftcol;
unsigned char oldcolstart[SCREENCOLS];
oldleftcol = leftcol;
movmem(colstart, oldcolstart, sizeof(colstart));
displaycell(curcol, currow, NOHIGHLIGHT, NOUPDATE);
if (curcol > leftcol)
curcol--;
else if (leftcol != 0)
{
curcol--;
leftcol--;
setrightcol();
setleftcol();
if (oldleftcol <= rightcol)
scroll(RIGHT, colstart[oldleftcol - leftcol] - LEFTMARGIN, LEFTMARGIN + 1,
3, 80, SCREENROWS + 2, WHITE);
clearlastcol();
for (col = leftcol; col <= oldleftcol - 1; col++)
displaycol(col, NOUPDATE);
}
} /* movecolleft */
void movecolright(void)
/* Moves right one column */
{
int col, oldleftcol, oldrightcol;
unsigned char oldcolstart[SCREENCOLS];
movmem(colstart, oldcolstart, sizeof(colstart));
oldleftcol = leftcol;
oldrightcol = rightcol;
displaycell(curcol, currow, NOHIGHLIGHT, NOUPDATE);
if (curcol < rightcol)
curcol++;
else if (rightcol < (MAXCOLS - 1))
{
curcol++;
rightcol++;
setleftcol();
setrightcol();
if (oldrightcol >= leftcol)
scroll(LEFT, oldcolstart[leftcol - oldleftcol] - LEFTMARGIN,
LEFTMARGIN + 1, 3, 80, SCREENROWS + 2, WHITE);
clearlastcol();
for (col = oldrightcol + 1; col <= rightcol; col++)
displaycol(col, NOUPDATE);
}
} /* movecolright */
void recalc(void)
/* Recalculates all of the numbers in the speadsheet */
{
int col, row, dummy;
for (col = 0; col <= lastcol; col++)
{
for (row = 0; row <= lastrow; row++)
{
if ((cell[col][row] != NULL) && (cell[col][row]->attrib == FORMULA))
cell[col][row]->v.f.fvalue = parse(cell[col][row]->v.f.formula, &dummy);
}
}
displayscreen(UPDATE);
} /* recalc */
void changeautocalc(int newmode)
/* Changes and prints the current AutoCalc value on the screen */
{
char s[15];
if (!autocalc && newmode)
recalc();
autocalc = newmode;
if (autocalc)
strcpy(s, MSGAUTOCALC);
else
s[0] = 0;
writef(73, 1, MSGAUTOCALCCOLOR, strlen(MSGAUTOCALC), s);
} /* autocalc */
void changeformdisplay(int newmode)
/* Changes and prints the current formula display value on the screen */
#include <string.h>
#include <mem.h>
#include <stdio.h>
#include <math.h>
#include <io.h>
#include <fcntl.h>
#include <conio.h>
#include "mcalc.h"
char *name = MSGNAME;
void moverowup(void)
/* Moves up 1 row */
{
displaycell(curcol, currow, NOHIGHLIGHT, NOUPDATE);
if (currow > toprow)
currow--;
else if (toprow != 0)
{
scroll(DOWN, 1, LEFTMARGIN + 1, 3, 80, SCREENROWS + 2, WHITE);
displayrow(--toprow, NOUPDATE);
currow--;
setbottomrow();
}
} /* moverowup */
void moverowdown(void)
/* Moves down one row */
{
displaycell(curcol, currow, NOHIGHLIGHT, NOUPDATE);
if (currow < bottomrow)
currow++;
else if (bottomrow < (MAXROWS - 1))
{
scroll(UP, 1, LEFTMARGIN + 1, 3, 80, SCREENROWS + 2, WHITE);
toprow++;
currow++;
setbottomrow();
displayrow(bottomrow, NOUPDATE);
}
} /* moverowdown */
void movecolleft(void)
/* Moves left one column */
{
int col, oldleftcol;
unsigned char oldcolstart[SCREENCOLS];
oldleftcol = leftcol;
movmem(colstart, oldcolstart, sizeof(colstart));
displaycell(curcol, currow, NOHIGHLIGHT, NOUPDATE);
if (curcol > leftcol)
curcol--;
else if (leftcol != 0)
{
curcol--;
leftcol--;
setrightcol();
setleftcol();
if (oldleftcol <= rightcol)
scroll(RIGHT, colstart[oldleftcol - leftcol] - LEFTMARGIN, LEFTMARGIN + 1,
3, 80, SCREENROWS + 2, WHITE);
clearlastcol();
for (col = leftcol; col <= oldleftcol - 1; col++)
displaycol(col, NOUPDATE);
}
} /* movecolleft */
void movecolright(void)
/* Moves right one column */
{
int col, oldleftcol, oldrightcol;
unsigned char oldcolstart[SCREENCOLS];
movmem(colstart, oldcolstart, sizeof(colstart));
oldleftcol = leftcol;
oldrightcol = rightcol;
displaycell(curcol, currow, NOHIGHLIGHT, NOUPDATE);
if (curcol < rightcol)
curcol++;
else if (rightcol < (MAXCOLS - 1))
{
curcol++;
rightcol++;
setleftcol();
setrightcol();
if (oldrightcol >= leftcol)
scroll(LEFT, oldcolstart[leftcol - oldleftcol] - LEFTMARGIN,
LEFTMARGIN + 1, 3, 80, SCREENROWS + 2, WHITE);
clearlastcol();
for (col = oldrightcol + 1; col <= rightcol; col++)
displaycol(col, NOUPDATE);
}
} /* movecolright */
void recalc(void)
/* Recalculates all of the numbers in the speadsheet */
{
int col, row, dummy;
for (col = 0; col <= lastcol; col++)
{
for (row = 0; row <= lastrow; row++)
{
if ((cell[col][row] != NULL) && (cell[col][row]->attrib == FORMULA))
cell[col][row]->v.f.fvalue = parse(cell[col][row]->v.f.formula, &dummy);
}
}
displayscreen(UPDATE);
} /* recalc */
void changeautocalc(int newmode)
/* Changes and prints the current AutoCalc value on the screen */
{
char s[15];
if (!autocalc && newmode)
recalc();
autocalc = newmode;
if (autocalc)
strcpy(s, MSGAUTOCALC);
else
s[0] = 0;
writef(73, 1, MSGAUTOCALCCOLOR, strlen(MSGAUTOCALC), s);
} /* autocalc */
void changeformdisplay(int newmode)
/* Changes and prints the current formula display value on the screen */

