Lurker News
Hi HN

It also supports percentages, dates and variables.
I've been working on this alone for a few years now, so would love to get some feedback.

Comments (239) 97 threads

bww11 replies#
This looks pretty cool. I've long been looking for something similar to Soulver (https://soulver.app/) that I can use on Linux. This seems promising.

One small criticism: In my opinion, no web-based writing app is useful unless the tab key inserts a tab. The default behavior of most browsers to move focus to the next field is tremendously infuriating in this context. Unfortunately, that's what happens here, at least for Firefox.
(Related: key combinations that normally perform cursor movements but which are often used by browser for navigation.)

sigmaprimus1 reply#
Good Feedback! I would think a checkbox that enables tab function would be best, how would you feel about a FF Plugin that achieves this? My only concern would be that FF has reserved that particular key and it would require special permissions to map it to your needs.
addandsubtract#
I think it should just be a toggle on the page: "Hijack keyboard shortcuts? Y/N". Figma, Miro, Google and co do it without asking. It's something we've come to expect with web apps, so a toggle would be a fair middle ground.
tonyonodi2 replies#
Yeah, honestly this has been annoying me too, I just haven't got around to fixing it. It's using CodeMirror 6 as the editor, the author said he deliberately made this version not "break" the default tab behaviour, which I think is understandable as a library author, but that makes it my job to fix!
math-dev1 reply#
I thought CM had some example code on how to override the tab behaviour. Might be worth checking out as I agree it sucks to not have tab = indent 4 spaces
chrisweekly1 reply#
2 spaces!

(ducks) (but srsly)

Continue this thread — 1 reply

dugmartin1 reply#
To save you some time, here is what I did to add tabs to CM 6 (I think I found it somewhere or I may have cobbled it together to insert two spaces):

First import things you need:

    import { indentMore, indentLess } from "@codemirror/commands"
Then create a command:

    export const insertTab: StateCommand = ({state, dispatch}) => {
      if (state.selection.ranges.some(r => !r.empty)) return indentMore({state, dispatch})
      dispatch(state.update(state.replaceSelection("  "), {scrollIntoView: true, userEvent: "input"}))
      return true
    }
and then add it to the keymap in your extensions array:

    const extensions: Extension[] = [
      ...other extensions here...,
      keymap.of([
          ...closeBracketsKeymap,
          ...defaultKeymap,
          ...searchKeymap,
          ...historyKeymap,
          ...completionKeymap,
          {key: "Tab", run: insertTab, shift: indentLess}
        ]),
    ]
and then pass the extensions array into where you setup your editor view, eg:

    const view = new EditorView({
      state: EditorState.create({
        doc: textarea.value,
        extensions
      }),
      parent: editor
    })
tonyonodi#
Thank you so much! Changes are live now :)
usrme2 replies#
Might not be as comprehensive as Soulver, but here's something I've been using in a browser to fiddle with: https://cruncher.io/.
tonyonodi2 replies#
Gosh, everyone has made one of these haven't they?
makach#
I have as well :-) but I lose for not having released. This version is pretty cool though, will probably not gonna use it because same reason I didn’t evolve my version. Don’t need it, and when I need it I don’t need for it to be dynamic.
jen729w#
Not everyone! About five people from a population of six billion. And you’re one of them.

Yours looks great. Well done on the release.
Line 100 might have an error though? It isn’t recognising `30th Sept`, does it not like the final `t`?

Groxx#
> Cruncher can also automatically plot changes as you adjust a variable

Well that's pretty neat. I've seen it in fancier setups, but not something Soulver-like. It seems a lot more usable here, since practically any equation can show it.

cpow3104#
I came here to deposit this exact same comment with one addition. Great project but seems to be lacking base support. As an engineer I need hex at least.
mk12#
I've never used Soulver, but there is a free web app https://numbr.dev that seems very similar to it.
anthropodie1 reply#
Hey this is pretty cool. Instead of Electron app I would prefer it as a browser tab. Wish it could be self hosted.
sabellito2 replies#
Thanks!

You can use the web version, it's all offline and saved in localStorage. Works well in mobile too and can be "installed" as an app from there.
https://filipesabella.com/CalcPad

Continue this thread — 2 replies

madrox#
While I tend to agree, this can break accessibility. The official WAI-ARIA authoring practices recommend Control+M. https://www.w3.org/WAI/ARIA/apg/

There should likely be an explicit override of accessibility so the visitor knows what they're getting into.

justinlloyd#
SoulVer on macOS as you know. OpalCalc on Windows. Speedcrunch on all three platforms, though I will categorically state that whilst Speedcrunch is very good, it is no Soulver/OpalCalc.
sleightofmind#
Couldn't agree more with the last two paragraphs. Web standards purists will trot out a reference to some standard and point out the imagined (and terrifying) consequences of making the TAB or ENTER key behave just as they would in a non-web application, AKA a real data-entry program. This is just a version of the "lest thou cause thy brother to stumble" club used to nudge the religious into compliance with strictures that make no sense to them (and yeah, the quote is probably not verbatim, but hopefully the gist of it is clear).

Example: I (who am not a programmer) once wrote a tangled mess of HTML and JavaScript to accept, and tabulate data entry for rebar (reinforcing steel) estimates. I was inordinately proud of it, bird's nest of bad programming practice that it was. I could TAB or ENTER-key my way through all fields, the up and down arrows performed the same tasks as the TAB-key, just like on a desktop program.
So why was it important to do things this way, and break the conventions so dear to the heart of the standard's purist? Because this is how I (and many others) estimated rebar in the 1990's:
You sat at a wide desk or table with a set of plans 30" to 48"-wide spread out to your left (if you were lucky) and another 30"-48" of table was needed to catch the plan pages turned to reveal the one you were working on. You right hand rested on the keyboard's ten-key pad some 3-5 feet away. You didn't look at your right hand -- you looked at your left hand index finger which was glued to (and rarely left) the large page at precisely the item you wanted to enter into your tabulation program, as you entered the SAC code, the qty per unit, the number of units, the bar size number, the bend category, the grade of steel, and the total length. Your eyes never left the drawing as you did this, and immediately upon completing that line item, your left hand picked up a yellow highlighter and highlighted that item -- one of many hundreds or thousands that would be necessary in a materials take-off of any appreciable size. To force the use of the TAB-key, or the mouse to move through data-entry fields would simply guarantee that no one would use your program. Ever.
But the purist says, "Someone may stumble." Aunt Loreen said, "Sometimes the 'You shoulds' are the sh-ts."

gnramires#
Note: I had this response typed up but didn't submit...

One related app that I absolutely love is Qalculate![1] (yes, it has a built-in exclamation for default enthusiasm :) )
It can do cool stuff like converting N (newtons) to kg.m/s^2 when you specify units as ?kg. It also converts units like 1kW x 1year = 31.55... GJ
It's fantastic for engineering and specially back-of-envelope calculations. This notepad aspect does seem useful though. One alternative is to use Jupyter notebooks, sometimes I work problems with Sage[2]+Jupyter. Sage is extremely powerful (you can do calculus, linear algebra, and more) but doesn't support units (that I know of), it's more geared toward advanced maths.
[1] https://qalculate.github.io/
[2] https://www.sagemath.org/ It's a bit on the heavy side although it's definitely worth it if you're doing a lot of math. I think the flatpak is preferred due to its significant size.

defrost3 replies#
Nice - I'll give it props for:

> 1 metre + 8 chain = 161.9344 m
> 1 tonne + 1 short ton = 1.90718474 t
> 1 tonne + 1 long ton = 2.0160469 t
and give it a pass for not supporting pre 1963 UK | US historic weights and measures .. that's getting into a pretty specific use case where Standards nerds like to have a clear display of what conversion factors are in play and what provenance those factors have.
Time Zone support (on your About ToDo) will be interesting, historic computations with daytime savings support will be a quagmnire :-)
The SHARE DOC URLs seem a bit long - something like "base64 full text of doc as an URL" I guess.
Will this hit a URL length limit if widespread use becomes a thing?
jq play : https://jqplay.org/s/f1r-BZ5xYd2
regex101 : https://regex101.com/r/OqojJl/1
do server side storage and doc hash .. which has issues of its own.

tonyonodi1 reply#
Well, I love this comment. And yes, time zone support terrifies me an order of magnitude more than anything else on the list.
defrost#
On the gnarly scale dealing with with pre-WGS84 paper maps from about the globe is arguably worse ..

there are so many reference ellipsoids and datums used in different parts of the world at different times .. and then there are the many variations on curved surface to flat map projections to deal with.
But yes - Time and date is an iceberg domain :-)

tonyonodi2 replies#
You're right, I'm using lz-string to compress the text before shoving it in the URL. This is definitely a necessary evil for the time being so I don't need a back end component to the app. But eventually I do want prettier URLs and collaborative editing if I can make that work without it bankrupting me or driving me insane.
simonz05#
Be aware URL field in browsers have a maximum number of characters they accept.
dunham#
For what it's worth, the typescript playground takes the exact same approach as you, placing a compressed (lz-string) copy of the text after the #code/ in a sharing url.
tonyonodi#
I am truly sorry
hcrisp1 reply#
I was disappointed it couldn't convert "1 furlong / 1 fortnight in mph", but this was successful:

> 14 furlongs / 2 weeks in mph [0.0052083333 mph]

tonyonodi#
That's a very enjoyable calculation!
xerxesaa2 replies#
Super cool. I wish this was open source so I could see how you did some things, but I understand you've decided to keep it closed. Just to satisfy my curiosity, would you mind sharing how you did parsing at a high level? Did you use some publicly available parser/lexer or did you just implement pattern matching yourself with something like regex or other token splitting measures?
ralphb1 reply#
I've found that a super simple way to parse basic expressions is a recursive descent parser. It is very simple to implement. No need to to break into tokenizer/parser, no need to generate an AST, just evaluate the expression while parsing.
lsferreira421 reply#
Do you have an example of a simple parser like that?
tonyonodi1 reply#
I'm very glad you asked. I wrote my own parser combinator library in TypeScript partly based on eulalie[0], so it doesn't have a separate lexer and parser and doesn't rely heavily on regexes (though it does use them to do things like match a single alphanumeric character). I plan on open sourcing this library one day once I can tidy up the API because I think it would be useful to other people.

But to give you an idea of what that all looks like this is the code for the parser that parses the "as a % of" operator:

  append(
    string("as"),
    oneOrMore(space),
    optional(append(string("a"), oneOrMore(space))),
    percentSymbol,
    oneOrMore(space),
    string("of")
  )
[0] https://github.com/bodil/eulalie
joe8756438#
Thanks for sharing, I had the same question!

I wasn't familiar with Eulalie, that's a really interesting approach. I built functionality [0] similar to numpad into a larger record-keeping system, Tap [1]. Precedence rules kindof scramble my brain so I ended up implementing s-expression syntax for Tap formulas.
I ended up writing the parser myself, called sowhat, but used a library for tokenization, moo.js [2]. You can see a demo of just the sowhat editor here [3].
0. https://www.tatatap.com/formulas 1. https://www.tatatap.com 2. https://github.com/no-context/moo 3. https://tatatap-com.github.io/sowhat-editor/

Continue this thread — 3 replies

Load more comments