Commit Graph

30 Commits

Author SHA1 Message Date
Glen Whitney
364ef2c0ea Streamline internals of teapot
The primary change is to add a “funcall” token, so that an entire expression
  can be encapsulated as a single token. This change is used to allow a cell to
  include simply a selection of appropriate semantic tokens. I.e., the content
  and iterative content are now each a single token like the value and the
  result value. Token vectors are used only as intermediate results in scanning
  and parsing.

  Not this means the cells are now in effect storing parse trees, so
  computation should be slightly faster and future extensions (like #56) should
  be facilitated.

  This commit also takes the opportunity while internals are being altered to
  add another token to a cell for future use for computed attributes, cf #22,
  and to change the internal numerical values from double and ints to long
  doubles and long longs. However, the change attempts to encapsulate that
  choice so it would be easy to change back or change to another representation.

  Note that these changes break savexdr(), as the internal binary format of
  a cell is now different. Rather than reimplement it, it is deprecated as
  the world does not need another binary spreadsheet format. Hence, the
  ascii format for teapot spreadsheets becomes the primary file format.
  Loading of old xdr files is still supported for backward compatibility.

  Closes #59.

  Also along the way, various other slight fixes and enhancements crept in,
  a partial but probably not exhaustive list of which follows:

  Fixes #31.

  Further revisions and improvements to documentation.

  Make the approximate comparison of floating point values scale more
  accurately with the size of the doubles being compared.

  Further extensions of absolute and relative cell addressing.

  Addition of (circle constant) tau function/constant.

  Modified string conversion to simply use internal printing routines, and
  to take "scientific" and "decimal" keywords.

  Allowed n() function to take a list of values, or just a single location
  defaulting to the current location.

  Added floor, ceil, trunc, and round functions, and allowed them to be
  keywords controlling the int() integer conversion function as well.

  Allowed substr() to drop its last argument to go to the end of the string.

  Provided an enum of built-in functions to preserve legacy function
  identifiers, allowing the large table inside func.c to be reorganized
  in a clearer fashion.

  Added additional annotation of properties of the built-in functions,
  including precedence.

  All operators are now also accessible as built-in functions.

  Made precedence of unary - lower than ^ to match python.

  Avoided inadvertently using FLTK @symbol abbreviations for formulas with
  "@" in them.
2019-08-23 12:12:06 -07:00
Glen Whitney
a56efa0c91 Prepare for parsing expressions into parse trees
Prior to this change, every evaluation re-parses the expression. The
  intermediate form as a parse tree is never stored anywhere. This change
  adds a new token type, FUNCALL, which acts as a node in a parse tree, and
  adds an (untested) evaluation method which returns the unevaluated parse tree
  as opposed to evaluating as it goes.

  This is preparation for a following step in which rather than storing a token
  sequence for each variety of content, teapot will store a single token
  representing the parse tree, allowing for quicker evaluation when the time
  comes; no actual parsing will have to occur on evaluation.
2019-08-05 16:45:04 -04:00
Glen Whitney
b0e989d848 Copy and free funcall tokens
Again, even though there is not as of yet any way to create them
2019-08-04 10:39:20 -04:00
Glen Whitney
d6b4adfc8c Add ability to print new funcall tokens
Even though they can't be created yet.
2019-08-04 00:23:21 -04:00
Glen Whitney
26ea0e05b3 Extend sum() to cover the case of just adding up all of its arguments.
Also a small amount of preparation of storing parse trees instead of
  linear sequences of tokens got mixed in here, namely a new type of
  token called a "FUNCALL".
2019-08-03 16:29:00 -04:00
Glen Whitney
07bf78c7bb More color prep: define color aspects of a cell
This change does away with separate attributes foreground and background,
  opting for an array of color "aspects", where the aspect can vary
  over an enum which can either be FOREGROUND or BACKGROUND. This will allow
  writing a single set of color-editing code which can work either on the
  foreground or background color of a cell.
2019-08-03 12:42:32 -04:00
Glen Whitney
91b5ae7e1f Further prepare for color rendering; highlight row and column
Now palettes are allocated and deallocated in fteapot as well as teapot;
  both executables have some color rendering, with fteapot using the cell
  foreground and background (there's just no way to set them at the moment).
  teapot is so far only using color in the header.
  Implements #39.
2019-08-02 23:21:58 -04:00
Glen Whitney
2e0a3a480c Improve dialogs
Now in fteapot you can select any one of the buttons in a modal dialog
  with the cursor keys and hit enter and it will be selected.
  Fixes #17.
  In addition, I clarified that the block attribute options will either set
  every cell to bold (say), or unset every cell, or you can cancel to not
  actually go through with the block operation.

  These changes required adding a custom FLTK dialog, tpt_choose.{h,cxx}.
  Along the way, I reflowed fteapot.fl to make it more readable for further
  coding.
  Finally, there is a small amount of additional prep for color support
  that (unfortunately) got mixed in with these changes.
2019-08-02 20:31:48 -04:00
Glen Whitney
341b12ba04 Implement a relative reference robust to source and reference moving
The new function is X(SRC,REF), which briefly for a cell in the neighborhood
   of REF returns the corresponding cell in the neighborhood in SRC. For
   further details, see the updated documention.

   In developing and documenting this function, I refined some of the
   existing error messages (e.g. showing the coordinates when there is an
   attempt to obtain a cell with a negative coordinate) and improved the
   error propagation to increase the chance that the innermost error will
   percolate to the top level.
2019-07-30 15:07:54 -04:00
Glen Whitney
ab1a2fbb5a Fix relative addressing 2019-07-29 14:33:47 -04:00
Glen Whitney
b3ea9f7ad9 Add relative address and at functions 2019-07-29 14:14:36 -04:00
Glen Whitney
a5bf64b061 Add bitwise logical functions 2019-07-29 13:22:15 -04:00
Glen Whitney
1114df2e13 Extend max/min to cover an explicit list of values. 2019-07-29 12:42:51 -04:00
Glen Whitney
9caf9bf1a5 Document the Fill With operation 2019-07-29 12:03:36 -04:00
Glen Whitney
d7f7bf3ce7 One more file prepping for color 2019-07-29 12:02:45 -04:00
Glen Whitney
25bb787f08 Prepare for per-cell configurable colors
So far, this jst consists of initializing color in curses mode, and making
  the display start and end part of intializing and freeing a sheet (so that
  it can control allocating the palette, for example, where the data structure
  used depends on what kind of display it is.

  Next up will be to allocate and destroy the color palette, and set up the
  default colors for cells to use (0 for foreground,
  TEAPOT_WHITE for background.) The outline beyond that is to allow setting of
  the cell colors, then actually display those colors, and finally edit the
  palette.
2019-07-29 11:35:10 -04:00
Glen Whitney
2a4071f8dc Prevent some near-startup coredumps.
Fixes #38.
2019-07-27 23:54:16 -04:00
Glen Whitney
39c12c08e0 Implement a fill-with menu item
This new option fills the entire marked region with copies of the current cell.
  Implements #35.
2019-07-27 04:08:42 -04:00
Glen Whitney
8b95dec96d Factor Cell into its own file
THis will make adding other Cell operations easier.
2019-07-27 03:00:03 -04:00
Glen Whitney
ea230efc23 Move source code into subdirectory
Also removed a stray copy of the automatically generated config.h which
  had somehow gotten into the distribution. Closes #36.
2019-07-27 01:35:44 -04:00
Glen Whitney
255bd86bf5 A first stab at refactoring
In general, the goal of these changes is to be more type-specific wherever
  possible, reduce duplicated code, and avoid magic numbers. The biggest
  individual change is to use Location triples of integers wherever possible
  rather than three separate int variables. Another very helpful change for
  understanding what is going on in the code is introducing the MarkState enum
  for tracking the process of marking and unmarking blocks of cell.

  The MarkState change was motivated by the issues with Ctrl-C,
  and this commit, in fact,
  resolves #28.

  Because of the lack of a test harness, it is possible that a change of
  this scope has created some bugs as well, but teapot was running OK for
  me at the time of the commit. However, I don't know how good my coverage of
  the changed code was -- I certainly did not save or load a Lotus 1-2-3 file!
2019-07-27 00:14:26 -04:00
Glen Whitney
2837cc2253 Document operations on locations. 2019-07-25 09:56:15 -04:00
Glen Whitney
d24b8c5ead Add arithmetic for locations
Nearly all of the basic operations in eval.c have been implemented for values
  of type LOCATION. The behavior is generally modeled after typical vector
  arithmetic. For "<", as a particular case, every component must be less
  than or equal the corresponding component, and at least one must be strictly
  less (<= drops the latter condition, of course). Note "<" returns the number
  of strictly less coordinates, but 0 (false) if any coordinate is greater.

  Also implements a mechanism (string array Type_Names) for printing type
  information and slightly enhanced the error message for type mismatch in +

  Closes #16.
2019-07-25 06:10:05 -07:00
Glen Whitney
08b42bf424 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 10:47:39 -07:00
Glen Whitney
c072cb9af4 Add more clock/reset keys and update docs
Provides additional keys to clock and reset the spreadsheet in GUI mode.
  Updated LyX manual to include GUI mode keys, including the new ones, to
  include some of the more recent features like bold and highlight, and
  also improved some phrasing throughout.
  Fixes #4.
2019-07-23 12:42:19 -07:00
Glen Whitney
eefc54818c Restore build of fteapot (on OpenSUSE Tumbleweed)
Changes to CMakeLists.txt to allow the system fltk to be found. These may
  have interfered with static linking, as now the command lines for static
  and dynamic linking look identical.

  A small change to fteapot.fl so that the resulting code will compile.

  Some additions to the INSTALL file to help point to prerequisites.

  Fixes #1.
2019-07-22 17:13:24 -07:00
Glen Whitney
06fab6dba1 Restore compilation of curses teapot on OpenSUSE Tumbleweed
The XDR library is no longer in the Gnu standard library, but it can be
  supplied in Tumbleweed via the tirpc library, so look for that as an
  option.
  Also renamed README to README.md in the packaging, to reflect prior change.
2019-07-22 15:02:18 -07:00
Glen Whitney
4451032ab9 Merge readme files 2019-07-22 13:44:57 -07:00
Glen Whitney
f8a60447d6 Import exactly the files of the teapot-2.3.0 distribution 2019-07-22 13:32:33 -07:00
Glen Whitney
360b88936b Initial commit 2019-07-22 20:26:15 +00:00