Commit Graph

54 Commits

Author SHA1 Message Date
Simon Michael
ffc535ad64 lib: add Show to Table render functions for debugging 2023-10-17 11:46:00 +01:00
Simon Michael
c790aa6145 ;dev: lib: also build with GHC 9.6.1; add base-compat 2023-03-14 10:42:48 -10:00
Simon Michael
33dba1945d dev: lib: Text.Megaparsec.Custom notes 2022-10-07 06:34:34 -10:00
Simon Michael
c80c72d7cd dev: lib, cli, bin: enable/fix name shadowing warnings
And a few other cleanups.
2022-08-23 12:16:15 +01:00
Simon Michael
1c67d0860e imp: errors: more error prettification 2022-07-13 03:59:44 +01:00
Simon Michael
5ab7b9f643 ref: HledgerParseErrors type alias 2022-04-25 02:56:59 -10:00
Simon Michael
2f28e1b0a7 ref: rename CustomErr -> HledgerParseErrorData
Verbose, but use every chance to clarify the complicated parse error
situation.
2022-04-25 02:56:59 -10:00
Simon Michael
a2f6b30fbd cln: silence some warnings/lints 2022-03-26 08:34:21 -10:00
Stephen Morgan
8d161ebe32 cln: Silence build warning due to redundant import. 2021-11-11 19:42:06 -10:00
Stephen Morgan
ff0132df28 dev: Use realLength from doclayout instead of strWidth and textWidth. (#895)
This gives us more accurate string length calculations. In particular,
it handles emoji and other scripts properly.
2021-11-11 18:29:50 -10:00
Stephen Morgan
1bc04685b7 pkg: Drop base-compat-batteries dependency.
Our supported stackage versions are now new enough that we don't need
any of the compatibility features anymore.
2021-10-31 07:56:07 -10:00
Stephen Morgan
d248aec313 cln: hlint: Remove eta reduce warnings. 2021-08-27 06:13:56 -10:00
Stephen Morgan
8bf7c95697 cln: hlint: Clean up Functor related hlint warnings, and NOINLINE warning. 2021-08-27 06:13:56 -10:00
Stephen Morgan
22db5c4a3f cln: hlint: Remove warnings to use library list functions. 2021-08-27 06:13:56 -10:00
Stephen Morgan
435fbf001e cln: hlint: Remove <|> and bimap warnings. 2021-08-26 21:00:35 -10:00
Lawrence
710823e5d7 imp: bal: handle commodity-column flag in compound balance reports (#1654) 2021-08-19 17:37:30 -10:00
Lawrence
234caae557 doc: test: update for commodity-column
Add documentation and sample output for `--commodity-column` behavior
and functional tests e.g single-period balance, yearly balance, and
yearly budget
2021-08-08 09:19:25 -10:00
Lawrence Wu
f3c07144a8 bal: option to view one commodity per row
This adds the `--commodity-column` option that displays each commodity
on a separate line and the commodities themselves as a separate column.
The initial design considerations are at
simonmichael.hledger.issues.1559

The single-period balance report with `--commodity-column` does not
interoperate with custom formats.
2021-08-08 09:19:25 -10:00
Stephen Morgan
55308e1ca8 lib,cli,ui,web: Remove unnecessary CPP when dropping support for GHC 8.2. 2021-06-07 17:33:54 -10:00
Stephen Morgan
0e59fee251 lib,cli: Export Text.Tabular from Text.Tabular.AsciiWide, clean up import lists. 2021-06-03 23:23:54 -10:00
Simon Michael
0f4e462ae7 add a Show instance for AmountDisplayOpts, WideBuilder
For debug logging.
2021-04-13 17:19:22 -10:00
Stephen Morgan
f3c9bce02c lib: Minor refactor, using foldMap instead of asum . map . toList. 2021-03-23 11:26:30 -07:00
Stephen Morgan
217bfc5e74 lib: Rename alignCell to textCell, minor cleanups. 2021-01-15 12:56:48 -08:00
Stephen Morgan
2c2bd8b27e lib: Refactor unlinesB to be cleaner and more efficient. 2021-01-15 12:56:48 -08:00
Stephen Morgan
e63138ef7d lib,cli: Assorted fixes for older GHC. 2021-01-02 15:08:09 +11:00
Stephen Morgan
13c111da73 lib,cli,ui: Use WideBuilder for Tabular.AsciiWide.
Move WideBuilder to Text.WideString.
2021-01-02 15:08:09 +11:00
Stephen Morgan
462a13cad7 lib,cli: Use Text Builder for Balance commands. 2021-01-02 15:08:09 +11:00
Stephen Morgan
a620ab9666 lib: Expand Tabular.AsciiWide to allow multiline cells, either top or bottom aligned. 2020-11-04 14:25:21 +11:00
Stephen Morgan
7e47c11fda lib: Remove some uses of pad(Left|Right)Wide to ensure we're using the
width provided by showMixed.

Also refactor renderTable to be a bit clearer, and to avoid duplicate
calculations.
2020-11-04 14:25:20 +11:00
Stephen Morgan
162a936360 lib: BudgetReport uses new renderTable inteface, now has more compact output.
This changes showMixedAmountElided so that the width to elide to is
given as an argument, rather than fixed at 22 characters. This
actually uses the new renderTable interface. Mostly this is just an
internal change, but since we have more information about the widths
of things, we can actually get rid of some superfluous spaces in the
budget report output, previously there to make sure it stayed aligned
with the largest reasonable contents.
2020-11-04 14:25:20 +11:00
Stephen Morgan
33369dfa6c lib: renderTable can now receive alignment and width specifications on all cells, and has an option to display the outer border.
This gives renderTable a little more customisation. Before any of the
commits of this PR, render would just receive a string to display in
each cell. After the second commit of this PR it would also receive a
width of the string (in place of stripping ANSI sequences and then
calculating the width). After this commit, it now also takes an
alignment, so you can make cells left or right aligned. The function
render calls renderTable with appropriate options to give the same
behaviour as before. Also, previously render would always put a border
around the table. We would take this output, and would sometimes strip
the border by dropping the first and last rows, and first and last
characters of every row. I've just added an option to control whether
to put the border in, so we can just not add it in the first place,
rather than stripping it later. Note that this is again just defining
helper functions; this extra power is not yet used anywhere.
2020-11-04 14:25:20 +11:00
Stephen Morgan
e50a8c0f34 lib: Refactor Text.Tabular.AsciiWide to allow custom width specification in rendering. 2020-11-04 14:25:20 +11:00
Eric Mertens
e33aa56d43 cli:Fixed NoLine column rendering after previous commit 2020-02-29 12:56:35 -08:00
Eric Mertens
011a864deb cli:Render pretty line-art tables with smooth borders 2020-02-29 11:44:13 -08:00
Eric Mertens
43b118c9b8 cli:Improve pretty table rendering
This fixes table edges always using single-width intersections and
adds support for double horizontal lines with single vertical lines
2020-02-27 14:54:47 -08:00
Simon Michael
445e8aa3cc add support for megaparsec 8 (#1175) 2020-01-14 09:54:06 -08:00
Caleb Maclennan
11d9e5eb6a code: Strip extraneous trailing whitespace from Haskell sources 2019-07-15 16:40:49 +01:00
Alex Chen
880e6e0a32 lib: add a custom parse error for "re-parsing"
- for pretty-printing parse errors thrown from the parsing of excerpts
  of the source text as if they were thrown from the parsing of the
  source text itself
2018-11-22 14:09:32 -08:00
Peter Simons
027d084878 Drop undecidable Ord instance for ParseError.
That code fails to compile with ghc-8.6.1 because the instance is undecidable.
I suppose we could enable the appropriate compiler extension to support it, but
I've found that simply removing the instance causes no problems whatsoever: the
entire repository still compiles fine and it passes all test suites, too.
2018-10-24 10:35:11 -07:00
Alex Chen
a8d642d5b5 lib: revise comments for "final" parse errors
- also simplify their implementation a bit
2018-10-09 11:05:46 -06:00
Alex Chen
3d2584d869 lib: switch to megaparsec 7 2018-09-30 20:15:12 -06:00
Alex Chen
26369c28a3 lib: remove old code for include file parse errors 2018-09-29 22:55:10 -06:00
Alex Chen
855a8f1985 lib: Re-implement the 'ExceptT' layer of the parser
We previously had another parser type, 'type ErroringJournalParser =
ExceptT String ...' for throwing parse errors without the possibility of
backtracking. This parser type was removed under the assumption that it
would be possible to write our parser without this capability. However,
after a hairy backtracking bug, we would now prefer to have the option
to prevent backtracking.

- Define a 'FinalParseError' type specifically for the 'ExceptT' layer
- Any parse error can be raised as a "final" parse error
- Tracks the stack of include files for parser errors, anticipating the
  removal of the tracking of stacks of include files in megaparsec 7
  - Although a stack of include files is also tracked in the 'StateT
    Journal' layer of the parser, it seems easier to guarantee correct
    error messages in the 'ExceptT FinalParserError' layer
  - This does not make the 'StateT Journal' stack redundant because the
    'ExceptT FinalParseError' stack cannot be used to detect cycles of
    include files
2018-09-29 22:33:34 -06:00
Alex Chen
2b3c97e1af lib: tweak custom parse errors
- Don't immediately throw custom parse errors into 'ParsecT'; rather,
  just construct and return them
- This anticipates the re-implementation of an 'ExceptT' layer of the
  parser, which should be able throw custom parse errors
2018-09-29 22:32:34 -06:00
Alex Chen
0382bb5cd4 lib: move custom parse errors to Text.Megaparsec.Custom 2018-06-11 13:58:56 -06:00
Alex Chen
b245ec7b3d lib: remove the megaparsec compatability module 2018-05-22 12:16:46 -07:00
Simon Michael
581d02162c resolve all current build warnings with the supported GHC versions
If I'm lucky.
2018-05-17 20:43:55 -07:00
Simon Michael
43287a3e26 budget: use a new first-class BudgetReport for --budget 2018-04-23 18:52:28 -07:00
Simon Michael
20442196fb lib: refactor 2017-07-31 07:09:06 -07:00
Simon Michael
f1c5cce575 lib: another doctests fix, replace wrong haddock char 2017-07-31 07:09:06 -07:00