Sindbad~EG File Manager
// displaycontrol.c
// MathXpert Calculus Assistant
//
// Created by Michael Beeson on 11.5.23.
// last modified 11.24.24
#include <assert.h>
#include <string.h>
#include <stddef.h>
#include "terms.h"
#include "displaycontrol.h"
#include "display1.h"
#include "dispfunc.h"
/* VARIABLES TO CONTROL DISPLAY______________________________ */
static int anddisplay = 2; /* matrix with bars;
0 means display AND as an interval_as_and,
1 as a matrix without bars */
static int ordisplay = 2; /* 0 as "or"; 1 as matrix, no bars; 2 as matrix, with bars */
static int falsedisplay = 1; /* No solution */
/* maxfract is the maximum width of vertically-displayed fraction */
static coord maxfract = 78 << 4; /* 78 characters, 16 coord units per character */
static int precision = 6;
/* argument to my_gcvt telling number of significant digits
for use in printing doubles
defined in terms.c */
static int separator = 2; /* argument to print_bignum telling about commas and spaces*/
/* 2 = blocks of 3 digits with commas */
/* 0 = blocks of 6 digits with space */
/* 1 = no separator */
/* > 2 specifies ascii code to use for separator,e.g. '.' or ' ' */
/* defined in terms.c */
/* one-line upper limit is displaced to the right and up
from the right of the integral sign by these amounts: */
static coord upperlimx = 2;
static coord upperlimy = 4;
/* bottom of one-line lower limit is displaced to the right and down
from the right bottom of the integral sign by these amounts: */
static coord lowerlimx = 1;
static coord lowerlimy = 2;
/*_______________________________________________________________________*/
int bigparens = 1; /* nonzero means we can draw big round parentheses */
/* In the DOS version we could not */
/* 'font' will be either EIGHTPOINT or TENPOINT. The lowest level output
functions wwrite and wputch should look at this global variable
on machines where variable size fonts are being used. It is used
to decrease the size of exponents, subscripts, and so on. */
// int font = TENPOINT;
int textstyle = ROMAN;
/* typedef unsigned short coord; already in screen.h */
/* variables to control spacing in graphics mode */
/* in units of 1/16 of a character */
/* following give the TENPOINT and EIGHTPOINT values of certain spacings */
static coord parenspace[2] = {2,1}; /* space after open paren and before close paren */
static coord parenwidth[2] = {6,3}; /* space occupied by one parenthesis */
static coord charspace = 16; /* height of one TENPOINT glyph box with internal leading */
/* This should not be changed, as the
whole system of allocating bits in a
'block' depends on this value */
static coord eightpointheight=7 ; /* height of EIGHTPOINT type in coord units */
/* if this changes, change CreateFonts too (hasn't been changed yet) */
static coord sumspace[2] = {6,1}; /* space between summands and '+' as in a-b+c */
static coord plussignoffset[2] = {8,2};
static coord minussignoffset[3] = {9,2};
static coord minusspace[2] = {4,2}; /* space following minus sign before the arg in a sum*/
/* if changed, change in select.c also */
static coord unaryminusspace[2] = {2,1}; /* space following unary minus sign */
static coord productspace[2] = {4,1}; /* space between factors */
static coord prefixspace = 4; /* space between sin and x in 'sin x' */
static coord dotspace = 8; /* space for multiplication dot before a number */
static coord abovefractionspace = 2; /* above a fraction bar */
static coord belowfractionspace = 2; /* below a fraction bar */
static coord belowrootbar = 2; /* below a sqrt or root bar */
static coord undersqrtshift = 4; /* shift arg of SQRT right this much from the x-coordinate of
the top of the slanting part of the sqrt sign */
static coord rootspace = -7; /* leave this much space after the index of an n-th root */
/* it's negative, so it means to let the root sign stick under the index */
static coord sqrtspace = 10; /* width needed for drawing a sqrt sign, and the bar extends that far to the right also. */
static coord indexspace = 6; /* raise index of roots this much over the floor of the term */
static coord powerspace = 1; /* horizontal space between base and exponent */
static coord subscriptspace = 4; /* subscripts stick out this much below the variable letter */
static coord matrixspace = 4; /* space between rows of a matrix; also half this
much is left above and below a matrix with
bars for the bars to stick out. */
static coord integralsignwidth = 8; /* width of the actual sign itself; then productspace is blank before the integrand. */
static coord floorwidth = 8; /* width of the floor corner characters */
static coord underfloor = 4; /* below the bounding box of what's inside floor */
static coord infixspace = 4; /* space left and right of <= or < */
static coord ineqspace = 8; /* width of inequality sign */
#define RGB(r,g,b) r | (g << 8) | (b << 16)
static int textcolor = RGB(0,0,0);
static int backgroundcolor;
static int highlightcolor = RGB(255,0,0);
static int selectioncolor = RGB(128,128,0);
static int reasoncolor = RGB(0,127,255);
/*______________________________________________________________________*/
coord get_floorwidth(void)
{ return floorwidth;
}
coord get_underfloor(void)
{ return underfloor;
}
coord get_parenwidth(int size)
{ assert(size <= 2);
return parenwidth[size];
}
coord get_charspace(void)
{ return charspace;
}
coord get_parenspace(int size)
{ assert(size <= 2);
return parenspace[size];
}
coord get_sqrtspace(void)
{ return sqrtspace;
}
coord get_productspace(int size)
{ assert(size<=2);
return productspace[size];
}
coord get_matrixspace(void)
{ return matrixspace;
}
coord get_sumspace(int size)
{ assert(size <=2);
return sumspace[size];
}
coord get_minuswidth(int size)
/* width of minus sign */
{ if (size == TENPOINT)
return 4;
else
return 3;
}
coord get_pluswidth(int size)
/* width of plus sign */
{ if (size == TENPOINT)
return 8;
else
return 6;
}
coord get_minusspace(int size)
{ assert(size<=2);
return minusspace[size];
}
coord get_unaryminusspace(int size)
{ assert(size<=2);
return unaryminusspace[size];
}
coord get_powerspace(void)
{ return powerspace;
}
coord get_prefixspace(void)
{ return prefixspace;
}
coord get_abovefractionspace(void)
{ return abovefractionspace;
}
coord get_belowfractionspace(void)
{ return belowfractionspace;
}
coord get_belowrootbar(void)
{ return belowrootbar;
}
coord get_undersqrtshift(void)
{ return undersqrtshift;
}
coord get_indexspace(void)
{ return indexspace;
}
coord get_rootspace(void)
{ return rootspace;
}
coord get_anddisplay(void)
{ return anddisplay;
}
coord get_ordisplay(void)
{ return ordisplay;
}
void set_ordisplay(coord t)
{ ordisplay = t;
}
void set_anddisplay(int t)
{ anddisplay = t;
}
coord get_upperlimx(void)
{ return upperlimx;
}
coord get_lowerlimx(void)
{ return lowerlimx;
}
coord get_upperlimy(void)
{ return upperlimy;
}
coord get_lowerlimy(void)
{ return lowerlimy;
}
coord get_dotspace(void)
{ return dotspace;
}
coord get_eightpointheight(void)
{ return eightpointheight;
}
coord get_maxfract(void)
{ return maxfract;
}
coord get_falsedisplay(void)
{ return falsedisplay;
}
int get_precision(void)
{ return precision;
}
int get_separator(void)
{ return separator;
}
coord get_subscriptspace(void)
{ return subscriptspace;
}
coord get_integralsignwidth(void)
{ return integralsignwidth;
}
coord get_infixspace(void)
{ return infixspace;
}
coord get_ineqspace(void)
// inequalities never appear in EIGHTPOINT in MathXpert
// so no size parameter in this function
{ return ineqspace;
}
coord get_signoffset(int size, char sign)
/* vertical space between sign and water level of the sum */
/* But for + it needs two less than for minus.. */
{ assert(size <= 2);
if(sign == '+')
return plussignoffset[size];
if(sign == '-')
return minussignoffset[size];
return 8; // assert(0), only used for + and -
}
/*_________________________________________________________*/
/* following functions get and set the static
globals controlling colors */
int get_highlightcolor(void)
{ return highlightcolor;
}
int get_textcolor(void)
{ return textcolor;
}
void set_textcolor(int c)
{ textcolor=c;
}
int get_selectioncolor(void)
{ return selectioncolor;
}
void set_selectioncolor(int c)
{ selectioncolor=c;
}
int get_reasoncolor(void)
{ return reasoncolor;
}
void set_reasoncolor(int c)
{ reasoncolor=c;
}
void set_highlightcolor(int c)
{ highlightcolor=c;
}
/*_________________________________________________________*/
/* The following are used to keep track of the display strings
of multi-character functors and atoms. These strings are
stored here by the parser, and used by atom_string and
functor_string only. The parser
accesses these data structures by means of the exported functions
newatom and newfunctor. The rest of the program accesses them
only by means of atom_string and functor_string. The data
structures 'symbols' and 'functors' cannot be accessed outside
display.dll.
*/
/* __________________________________________________________*/
void get_display_control( display_control *p)
/* Used to fetch values of the display_control variables */
{ p->precision = precision;
p->maxfract = maxfract;
p->separator = separator;
/* p->breakcol = breakcol; */
p->anddisplay = anddisplay;
p->ordisplay = ordisplay;
p->falsedisplay = falsedisplay;
p->textcolor = textcolor;
p->backgroundcolor= backgroundcolor;
p->highlightcolor = highlightcolor;
}
void set_display_control( display_control *p)
{ precision = p->precision;
separator = p->separator;
/* breakcol = p->breakcol; */
maxfract = p->maxfract;
anddisplay = p->anddisplay;
ordisplay = p->ordisplay;
falsedisplay= p->falsedisplay;
textcolor = p->textcolor;
highlightcolor = p->highlightcolor;
backgroundcolor = p->backgroundcolor;
}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists