Commit Graph

58 Commits

Author SHA1 Message Date
00859ecbd2 feat: Add hashing color for cells (#93)
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Reviewed-on: #93
2023-07-26 03:21:43 +00:00
8db9c30825 chore: update copyright year 2023-05-01 22:26:19 -04:00
5176005bb3 feat: add if() conditional operator and update docs (#92)
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Reviewed-on: #92
2023-05-02 02:23:57 +00:00
7b794f90b9 fix: Always compute cells without clocked expressions using current values (#91)
Prior to this change, when a cell was clocked, it was always computed with prior values of referred-to cells. This had the effect, for example, of making cells defined only with a base expression as a total of a column, for example, to be out-of-date in that they would take on the value of the total of the prior values of the column, not the total of new current values of the column. This behavior was very counterintuitive.

With this change, updates of cells that have no clocked expression are delayed until after clocked expressions have been recomputed based on prior values and their cells' current values have been updated. Then the computations of those base-only cells use all of the new current values, leaving the spreadsheet in a (maximally) self-consistent state.

Resolves #90.

Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Reviewed-on: #91
2023-04-30 16:19:12 +00:00
da48b4c4f8 fix: typo in region_macro (#87)
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Reviewed-on: #87
2023-04-30 00:19:57 +00:00
7f005f171e feat: Allow expressions in region functions and add count() accumulator (#86)
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Reviewed-on: #86
2023-04-29 23:18:57 +00:00
eb5d576349 refactor: unify n() with other region functions (#85)
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Reviewed-on: #85
2023-04-29 19:53:17 +00:00
34e8b99585 fix: Allow n() function to count (empty) cells off edge of sheet (#84)
Resolves #83.

Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Reviewed-on: #84
2023-04-09 19:28:57 +00:00
d38cf2b913 feat: Add an orange color to the fteapot default palette (#81)
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Reviewed-on: #81
2023-04-09 14:06:39 +00:00
034ad0a201 fix: Initialize fteapot with z-depth 1, i.e., start 2D not 3D (#80)
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Reviewed-on: #80
2023-04-09 06:27:17 +00:00
0ca9d0176b row_heights (#77)
Implements row heights and a command-line option `-F nn` for fteapot to set the general font size.

Also improves documentation and uniformizes key bindings somewhat between teapot and fteapot.

Resolves #57.

Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Reviewed-on: #77
2023-04-09 05:41:50 +00:00
118374c46e fix: Prevent crash in fteapot when rendering very narrow columns (#76)
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Reviewed-on: #76
2023-04-08 01:34:37 +00:00
efdd63d351 chore: Add COPYING file that got left out of change to main 2023-04-07 19:34:16 -04:00
5cdb6271da Add dim and italic attributes to style
Closes #74
2019-09-18 08:49:53 -04:00
76b3cc29d8 Minor convenience changes to .gitignore 2019-09-15 22:52:51 -04:00
91a0087d2d Add READMEs for new examples, compress large one, update docs 2019-09-09 12:18:00 -04:00
b81b6a5fd4 Update NEWS as well and remove redundant COPYING file 2019-09-09 11:49:40 -04:00
f651421901 Update the README to reflect the current state of affairs. 2019-09-09 11:15:39 -04:00
d5fbc0ef07 Alleviate compile warnings on Linux and finalize programmable styles
This change gets teapot to compile without warnings on OpenSUSE Tumbleweed
  with the extended warnings flags that were recently added. It also represents
  a more thoroughly (but not exhaustively) tested and debugged version of the
  expression-controlled style settings from an earlier commit. The facility
  should be ready for use.

  It also adds a better pretty-printer for Token values in gdb and extensive
  edits to the documentation. It fixes a bug in max/min introduced by the
  addition of the Bool type and the switchover to comparisons returning Bool.
  It modifies the display of values too long to fit in their cells to show an
  initial segment of their contents with a continuation mark rather than
  obscuring the contents completely.

  Closes #54.
  Closes #55.
  Closes #44.
  Closes #22.
  Closes #13.
2019-09-09 10:33:41 -04:00
Glen Whitney
8074130224 First partial pass at getting teapot working on Mac OS X 2019-09-05 03:24:24 -04:00
Glen Whitney
c52219f827 Allow styles to be computed
Needs further testing and documentation, will provide a more detailed commit
   message when that is checked in.
2019-09-03 01:41:37 -07:00
Glen Whitney
253062e906 Add commands to edit color and add color rendering in terminal teapot
Now the foreground and background color can be set and displayed in
  either user interfaces, which finishes off #21.
  Closes #21.
2019-08-28 23:19:08 -07:00
Glen Whitney
06938ec494 Implement a find() macro
This macro looks at each cell along some stride through the sheet,
  returning the location of the first cell encountered at which a given
  expression evaluates to true, or boolean false otherwise.

  To make this more useful, this change also revamps the handling of
  boolean values, making them much more permissive and coercing to boolean type
  in fewer circumstances. It adds the bool() type conversion for explicitly
  coercing to boolean type, and fixes a small issue with reading hex-formatted
  floating-point values ('p' can be used as an exponent indicator).

  Closes #64.
2019-08-28 12:40:50 -07:00
Glen Whitney
6534aec2fd Add type predicate
The main new finction is is(), which tests the type of a value. There
  are also constants for each of the possible token types, and one new
  conversion: number(), which converts a value into the most appropriate number
  type. This change also reuses the functions in scanner.h for exracting ints,
  floats, and identifiers from strings, rather than either rewriting the
  functionality elsewhere, or using the general-purpose scan when only one
  token type was of interest.
2019-08-27 23:30:02 -07:00
Glen Whitney
892fdcdb75 Add BOOL token_type, macros, and boolean operators
For clarity, it is valuable for the results of comparisons to show as "true"
  and "false" rather than "1" and "0". This change implements a BOOL type
  to facilitate that. Since we want logical operators to short-circuit, this
  change also obliges the introduction of macros, which are just like functions
  except their arguments are not evaluated before control is passed to the
  routine implementing the macro.
2019-08-26 23:56:19 -07:00
Glen Whitney
7e0ba7370d Add functions for unit displacements in the siz cardinal directions
This change is the "easy" part of #64, but to reduce the amount of duplicated
   code, this change also modifies the internals of implementing a function.
   The function identifier is now passed to the implementation as well, allowing
   many implementations of similar functions to be collapsed more easily.
2019-08-25 23:19:34 -07:00
Glen Whitney
9670e8b4a1 Print parse trees with infix notation
Fixes #62.
2019-08-24 15:17:35 -07:00
Glen Whitney
96079b210e 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 09:58:46 -07:00
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