2019-07-22 20:32:33 +00:00
|
|
|
#ifndef MAIN_H
|
|
|
|
#define MAIN_H
|
|
|
|
|
2019-09-05 07:24:24 +00:00
|
|
|
#include <limits.h>
|
|
|
|
|
2019-07-22 20:32:33 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#define _(x) (x)
|
|
|
|
|
|
|
|
#include "sheet.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-07-29 15:35:10 +00:00
|
|
|
extern bool batch;
|
2019-09-03 08:41:37 +00:00
|
|
|
extern PrecisionLevel def_precision;
|
Make tpa the default file format for Teapot
There turned out to be one blocking technical issue for full adpotion of
tpa format, and that was the fact that the printed representation of
floating values inside the tpa file might not reproduce the same double
when read. This change therefore introduces the "hexact" floating point
format, based on the the %La format string, which produces a hex
representation with exact round trips. While working on this, it was
convenient to add a new representation "compact" which is basically the
shorter of decimal and scientific representations, without trailing zeros.
This is now the default float format, but of course one can select decimal
or scientific formats to restore prior appearance. However, full-precision
compact format is now the (only) format for editing cell contents, as it
is accurate and efficient. Of course you can enter floating point values
in any format you like when typing in a formula.
The addition of several new floating point options overloaded the menus
in terminal teapot, so this change also revamps those menus slightly,
including eliminating the unused MenuChoice struct, and just specifying menus
with an array of strings.
Closes #63.
2019-08-24 16:58:46 +00:00
|
|
|
extern StringFormat quote;
|
2019-07-29 15:35:10 +00:00
|
|
|
extern bool header;
|
2023-04-09 05:41:50 +00:00
|
|
|
extern int fontsize;
|
Prevent phantom values when clocking, resetting, and clocking again
In the end it turned out that the cause of the phantom values was
short-cutting in getvalue() when the contents of a cell were empty,
preventing the update of the internal cache of the value of the cell.
However, tracking this down (and getting the associated memory management
correct) necessitated implementing a debugging mode in which I could
dump the internal states of cells and print various other stuff to standard
output. It also involved understanding the meaning of various pointers in
the code, in the process of which I renamed some commonly used macros,
particularly the former SHEET(s,x,y,z) which was not returning a Sheet at
all but rather a pointer to a Cell. So this macro is now called CELL_AT. I
also replaced several very repeatedly used patterns of checking the validity
of locations and pointers with macros, now defined in sheet.h.
Therefore, unfortunately the (relatively small in the end) bugfix for this
major issue is entangled with numerous textual changes to the code made
in tracking it down.
Fixes #18.
Closes #19.
2019-07-24 17:47:39 +00:00
|
|
|
extern int debug_level;
|
2019-07-29 15:35:10 +00:00
|
|
|
extern bool always_redraw;
|
2019-07-22 20:32:33 +00:00
|
|
|
extern unsigned int batchln;
|
|
|
|
|
|
|
|
/* A variable of type Key is either a special symbol from this enum, representing
|
|
|
|
actions the user has triggered (by whatever means available), or a Unicode
|
|
|
|
character that was entered
|
|
|
|
*/
|
2019-09-05 07:24:24 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
K_MAX = INT_MAX,
|
2019-07-22 20:32:33 +00:00
|
|
|
K_NONE = 0,
|
|
|
|
K_INVALID = -1,
|
|
|
|
K_BACKSPACE = -2,
|
|
|
|
K_BPAGE = -3,
|
|
|
|
K_CLOCK = -4,
|
|
|
|
K_COPY = -5,
|
|
|
|
K_DC = -6,
|
|
|
|
K_DOWN = -7,
|
|
|
|
K_END = -8,
|
|
|
|
K_ENTER = -9,
|
|
|
|
K_FIRSTL = -10,
|
|
|
|
K_FPAGE = -11,
|
|
|
|
K_FSHEET = -12,
|
|
|
|
K_HOME = -13,
|
|
|
|
K_LASTL = -14,
|
|
|
|
K_LEFT = -15,
|
|
|
|
K_LOAD = -16,
|
|
|
|
K_LOADMENU = -17,
|
|
|
|
K_LSHEET = -18,
|
|
|
|
K_MARK = -19,
|
|
|
|
K_MENTER = -20,
|
|
|
|
K_NPAGE = -21,
|
|
|
|
K_NSHEET = -22,
|
|
|
|
K_PPAGE = -23,
|
|
|
|
K_PSHEET = -24,
|
|
|
|
K_QUIT = -25,
|
|
|
|
K_RECALC = -26,
|
|
|
|
K_RIGHT = -27,
|
|
|
|
K_SAVE = -28,
|
|
|
|
K_SAVEMENU = -29,
|
|
|
|
K_SAVEQUIT = -30,
|
|
|
|
K_UP = -31,
|
|
|
|
K_GOTO = -32,
|
|
|
|
K_NAME = -33,
|
|
|
|
ADJUST_LEFT = -34,
|
|
|
|
ADJUST_RIGHT = -35,
|
|
|
|
ADJUST_CENTER = -36,
|
|
|
|
ADJUST_SCIENTIFIC = -37,
|
|
|
|
ADJUST_BOLD = -38,
|
|
|
|
ADJUST_PRECISION = -39,
|
|
|
|
ADJUST_SHADOW = -40,
|
|
|
|
ADJUST_TRANSPARENT = -41,
|
|
|
|
ADJUST_LABEL = -42,
|
|
|
|
ADJUST_LOCK = -43,
|
|
|
|
ADJUST_IGNORE = -44,
|
|
|
|
K_COLWIDTH = -45,
|
|
|
|
BLOCK_CLEAR = -46,
|
|
|
|
BLOCK_INSERT = -47,
|
|
|
|
BLOCK_DELETE = -48,
|
|
|
|
BLOCK_MOVE = -49,
|
|
|
|
BLOCK_COPY = -50,
|
|
|
|
BLOCK_FILL = -51,
|
|
|
|
BLOCK_SORT = -52,
|
|
|
|
BLOCK_MIRROR = -53,
|
|
|
|
K_ABOUT = -54,
|
|
|
|
K_HELP = -55,
|
Prevent phantom values when clocking, resetting, and clocking again
In the end it turned out that the cause of the phantom values was
short-cutting in getvalue() when the contents of a cell were empty,
preventing the update of the internal cache of the value of the cell.
However, tracking this down (and getting the associated memory management
correct) necessitated implementing a debugging mode in which I could
dump the internal states of cells and print various other stuff to standard
output. It also involved understanding the meaning of various pointers in
the code, in the process of which I renamed some commonly used macros,
particularly the former SHEET(s,x,y,z) which was not returning a Sheet at
all but rather a pointer to a Cell. So this macro is now called CELL_AT. I
also replaced several very repeatedly used patterns of checking the validity
of locations and pointers with macros, now defined in sheet.h.
Therefore, unfortunately the (relatively small in the end) bugfix for this
major issue is entangled with numerous textual changes to the code made
in tracking it down.
Fixes #18.
Closes #19.
2019-07-24 17:47:39 +00:00
|
|
|
K_DUMPCELL = -56,
|
2019-07-27 08:08:42 +00:00
|
|
|
ADJUST_UNDERLINE = -57,
|
Make tpa the default file format for Teapot
There turned out to be one blocking technical issue for full adpotion of
tpa format, and that was the fact that the printed representation of
floating values inside the tpa file might not reproduce the same double
when read. This change therefore introduces the "hexact" floating point
format, based on the the %La format string, which produces a hex
representation with exact round trips. While working on this, it was
convenient to add a new representation "compact" which is basically the
shorter of decimal and scientific representations, without trailing zeros.
This is now the default float format, but of course one can select decimal
or scientific formats to restore prior appearance. However, full-precision
compact format is now the (only) format for editing cell contents, as it
is accurate and efficient. Of course you can enter floating point values
in any format you like when typing in a formula.
The addition of several new floating point options overloaded the menus
in terminal teapot, so this change also revamps those menus slightly,
including eliminating the unused MenuChoice struct, and just specifying menus
with an array of strings.
Closes #63.
2019-08-24 16:58:46 +00:00
|
|
|
FILL_BLOCK = -58,
|
|
|
|
ADJUST_DECIMAL = -59,
|
|
|
|
ADJUST_COMPACT = -60,
|
2019-08-29 06:19:08 +00:00
|
|
|
ADJUST_HEXACT = -61,
|
|
|
|
ADJUST_FOREGROUND = -62,
|
2019-09-03 08:41:37 +00:00
|
|
|
ADJUST_BACKGROUND = -63,
|
2019-09-18 12:49:53 +00:00
|
|
|
K_EDIT_STYLE_EXPR = -64,
|
|
|
|
ADJUST_DIM = -65,
|
2023-04-09 05:41:50 +00:00
|
|
|
ADJUST_ITALIC = -66,
|
|
|
|
K_ROWHEIGHT = -67
|
2019-07-22 20:32:33 +00:00
|
|
|
} Key;
|
|
|
|
|
2019-09-05 07:24:24 +00:00
|
|
|
extern int do_sheetcmd(Sheet *cursheet, Key c, bool moveonly);
|
2019-09-03 08:41:37 +00:00
|
|
|
extern bool doanyway(Sheet *sheet, const char *msg);
|
2019-09-05 07:24:24 +00:00
|
|
|
extern void moveto(Sheet *sheet, CoordT x, CoordT y, CoordT z);
|
2019-07-27 04:14:26 +00:00
|
|
|
extern void movetoloc(Sheet *sheet, const Location dest);
|
2019-09-05 07:24:24 +00:00
|
|
|
extern void relmoveto(Sheet *sheet, CoordT x, CoordT y, CoordT z);
|
2019-07-27 04:14:26 +00:00
|
|
|
extern void do_mark(Sheet *cursheet, MarkState ms);
|
2019-07-27 08:08:42 +00:00
|
|
|
void fillwith(Sheet *she);
|
|
|
|
|
2019-07-22 20:32:33 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|