xoofx / kalk Goto Github PK
View Code? Open in Web Editor NEWkalk is a powerful command line calculator app for developers.
Home Page: https://kalk.dev
License: BSD 2-Clause "Simplified" License
kalk is a powerful command line calculator app for developers.
Home Page: https://kalk.dev
License: BSD 2-Clause "Simplified" License
First of all, thank you very much for the excellent tool you created! I used basics of it only, but already found it amazing.
One thing which immediately hit me, is that in case of error the cursor is put at the beginning of the error expression, not the end. For example if you type
bin something
the cursor is put at the beginning of something
:
That feels "unexpected" to me. It's a bit unusual to use "delete" button to correct the error, not the "backspace" one. It's very difficult for me though to explain why exactly I feel the current behavior non-natural. Like I would naturally have an intent to look for an error left to the cursor, not right. And also I have intuition to fix error to the left, not to the right.
Could be because in IDE you would usually have the whole error selected with the cursor at the end - so that's where I got used to that.
I do not have strong arguments in favor of suggested behavior change and I did not test how it would feel if that would be different. But decided to drop an issue in case I'm not the only one or you yourself thought about it as well ๐
In case AST underneath allows to precisely track position, one of the ideas could be to have something like this:
https://twitter.com/firstdrafthell/status/1427936354214764548
Then repeat the prompt again with the cursor at the end. This way it's clear what the boundaries of the error are even in case when broken expression has multiple words.
readline command line editing is the closest thing to a universal standard that exists. would be great if kalk supported these as well, for command line editing, history, and search. https://github.com/mono/LineEditor might be helpful?
Unix-derived operating systems like Linux and macOS use Ctrl-D (^D, EOT, end-of-transmission) as input terminator, with the typical behavior of closing a terminal shell when typed after a prompt. Also the Python CLI, that shares the prompt (>>>
) with kalk, closes on Linux and macOS when Ctrl-D is typed right after the prompt (after writing ^D
where the cursor was). Kalk could use ^D on Linux and Mac just like it uses ^Z on Windows.
It would be useful if kalk could support half precision floating point.
The string containing the binary representation output by bin
, which can also be its input, is divided into bytes written least-significant to most-significant left to right, i.e., supposing memory locations increase left to right, in "little-endian" (LE) order. This order is the most widespread order nowadays, but to better understand the constituents of the representation the "big-endian" (BE) order is definitely more intuitive โ especially for floating-point numbers. BTW, it can also be interpreted as the LE order with memory addresses increasing right to left.
I don't know what the BE equivalent of the bin
function could be called, or if other mechanisms to select the BE representation could be devised, but let me call it for now the bebin
function. Example calls:
>>> bebin 259
# bebin(259)
out = "00000000 00000000 00000001 00000011"
>>> bebin "00000000 00000000 00000001 00000011"
# bebin("00000000 00000000 00000001 00000011")
out = 259
>>> bebin 1.25
# bebin(1.25)
out = "00111111 11110100 00000000 00000000 00000000 00000000 00000000 00000000"
kalk is a command line app but doesn't have options to use it outside of its interactive mode
--file=input.kalk
to process an input file--version
--eval="x = 1; x + 2"
--help
to print all these optionsWe need to define what we can allow to do here.
This is what I'm seeing on debian sid under WSL:
>>> cos 45
Cannot dynamically create an instance of type 'Kalk.Core.KalkDoubleValue'. Reason: No parameterless constructor defined.
I've verified this with the trig functions, log, sqrt, exp, round, etc. abs produces a similar message referencing 'Kalk.Core.KalkCompositeValue'.
I'm not sure why this is happening, and my .NET Core 7 installation seems fine otherwise. Any particular information I should send you for this one? Not sure what would be helpful.
kalk
:[1] 33491 killed kalk
If I run kalk.exe straight from explorer it pops up a command window but the color codes seem to be broken and display as strings:
When I run this from e.g. conemu it works fine. Not sure if this is something about detecting console capabilities to turn off the color output or what might be the difference?
I'm not sure what information you might need from me - this is 0.1.1 downloaded straight from https://kalk.dev . I can build from source and debug or provide anything else you might need since I imagine this is system-specific and not a general problem.
btw I'm not sure if this is a separate unrelated issue but my gut feeling tells me it's too coincidental and it's probably related to the same thing. Even in conemu if I type in an unrecognised command it seems to break the prompt from then on:
And then if I type I typed this just once
I get:
If that needs to be split into a separate issue please let me know, I didn't want to file two bugs since it felt like probably the same root cause.
kalk is relying on standard ANSI escape code colors to select the colors for syntax highlighting.
We don't want necessarily to use other colors (e.g user defined with full RGB escape sequences) but would like to only rely on these standard escape code.
The supported colors are the following, and kalk is using only a subset of them:
:
The code involved is here:
kalk/src/Kalk.Core/KalkEngine.Highlight.cs
Lines 651 to 698 in 18a486e
We should add some guidance to the documentation on how to configure these colors (e.g in new Windows terminal)
Accessorily, do we need to improve the syntax highlighting?
KB (+KiB), MB (+MiB), etc
https://www.wikiwand.com/en/Byte#/Multiple-byte_units
Would presumably be added here: https://github.com/xoofx/kalk/blob/master/src/Kalk.Core/units.kalk#L48
Well, sorry, but it's time for the first issue ๐
I tried to install kalk as a .NET tool, and here's the console output:
C:\Users\lucas>dotnet tool install --global kalk --version 0.1.0
You can invoke the tool using the following command: kalk
Tool 'kalk' (version '0.1.0') was successfully installed.
C:\Users\lucas>kalk
Error:
An assembly specified in the application dependencies manifest (kalk.deps.json) was not found:
package: 'Packaging.Targets', version: '0.1.189'
path: 'runtimes/win7-x64/native/lzma.dll'
I have the .NET SDK installed through a VS 2019 build tools installation on this machine.
Thanks for this tool BTW! ๐
If I write something like this
vmlal_s16(int4(0,0,0,0), int4(2,2,2,2), int4(1,2,3,4))
The result will be
out(2, 0, 4, 0);
Which is unexpected given https://developer.arm.com/architectures/instruction-sets/intrinsics/vmlal_s16 that the result should be a + b * c
where the result gets expanded to int32x4
in this case.
It would be great to have the option to keep my history (content, commands) across sessions.
When pressing SHIFT+END
with the following program:
using System;
namespace TestConsole
{
class Program
{
static void Main(string[] args)
{
// Console.TreatControlCAsInput = true;
while (true)
{
var key = Console.ReadKey(true);
Console.WriteLine($"Key: {key.Key} Modifiers: {key.Modifiers} Char: {(key.KeyChar < ' ' || (int)key.KeyChar >= 126 ? "0x" + ((int)key.KeyChar).ToString("x2") : key.KeyChar.ToString())}");
if (key.Key == ConsoleKey.C && (key.Modifiers & ConsoleModifiers.Control) != 0)
{
break;
}
}
}
}
}
It generates the following sequence on Linux:
Key: Escape Modifiers: 0 Char: 0x1b
Key: D1 Modifiers: 0 Char: 1
Key: 0 Modifiers: 0 Char: ;
Key: D2 Modifiers: 0 Char: 2
Key: F Modifiers: Shift Char: F
instead of generating the following on Windows:
Key: End Modifiers: Shift Char: 0x00
In kalk
, it's breaking the start selection + move cursor to end, while SHIFT+HOME
is working just fine.
So it's either a bug in .NET or in WSL. I haven't checked this in a VM/real Linux so see how it behaves...
It would be nice to have instructions on how to build, along with essential dependencies, laid out in the readme.
kalk should be able to run on an ARM device/OS, so we should be able to export all the ARM intrinsics in a similar way Intel HW Intrinsics have been exposed.
Started with the new key binding introduced in 0.2.0
There are currently no tests for testing that these intrinsics are working (and we have 730+ of them)
We should at least generate automated input values to check that they are all running fine at least.
We could then manually validate some of them regarding expected results.
Just need to derive from the existing scriban vscode syntax highlighting using generated code.
Which is to say, if the Windows path has been duplicated into WSL, and while that's the default, it's not a guarantee.
(I prefer to turn off path copying because my Linux path is long enough without cramming all of my Windows path, relevant or not, into it. It also generates WSL errors when path translation can't cope with network paths.)
Maybe it would be possible to invoke these with their full paths, based on %SystemRoot% or the location of the "/Windows" directory under /mnt/c or other drive letter?
All the CTRL+left
, CTRL+right
are not working.
We should maybe replace CTRL
by ALT
on macOS (because the %command+left
is used for switching between windows).
Hi Alexandre Mutel(@xoofx),
I've tried to install your latest *.deb
package, at version 0.4.0
, on my Ubuntu 21.04 64b and it doesn't want to, due to the fact that the package is relying on <= libicu66
and my Ubuntu is on libicu67
.
Could I ask that you confirm that it can be installed under libicu67
?
Many thanks in advance!!
Cheers,
Gus
Run import Currencies
and it fails with the following error:
>>> import Currencies
# 2 functions successfully imported from module `Currencies`.
# Downloading rates from https://api.exchangeratesapi.io/latest
Unable to download rates. Reason: Unable to find `rates` from returned JSON.
# Using rates defined as of 2020-05-08.
I've checked the endpoint itself and it seems to be alive.
Specially with the implicit function/multiplication model where e.g 1 + cos 2x
will translate to 1 + cos(2 * x)
, the precedence is not necessarily obvious.
Is a good idea, but you have has a lack.
If I want to create variables, data structures then you will have to find a way to send them in text format to a file and not to copy/paste.
Using a set in settings
Example:
>>> a = bool2x2
# a = bool2x2
a = bool2x2(false, false, false, false)
# col 0 1 / row
bool2(false , false ) # 0
bool2(false , false ) # 1
Use a command to set patterns in settings to have a good output.
Maybe you can try to do it with :
# Modules (e.g
import Files) - All, Csv, Currencies, Files, HardwareIntrinsics, StandardUnits, Strings, Web
It solves it, then you need to fulfill with simple tutorials ...
Thank's for share.
So that, say, bin(long(5))
would output 00000000 00000101
instead of int-like 00000101
as it currently does. Same could be applied to hex(v)
function.
kalk is missing quaternions and all matrices helpers (rotate/scale/translate), so it's a bit cumbersome today to perform quick calculations with 3D stuffs
Not sure if this is compatible with the goals of this project, but I've always wanted a command line calculator that ignored currency symbols (e.g. $
) and thousand separators (,
in the US, .
in many other countries).
So for example:
>>> $1,000.00 / 4
$250
Hi
Fantastic app! I wanted to suggest adding ability to type the decimal value without a leading zero. For example, .3
instead of 0.3
.
Would this be possible?
Thank you!
Dax
kalk is distributed via:
Should we provide a Chocolatey package? For part of the packaging above, kalk is relying on Packaging.Targets
When I get the syntax wrong, I get some helpful red text but the cursor remains on the original line. Unfortunately, my shell muscle memory makes me hit Ctrl-C which exits the app and I loose everything from my current session.
Kalk opens a dedicated window. AFAIK it's not an interactive shell (like Python or some other compilers / environments) that can be run via terminal where you might need to "abort".
I don't think Ctrl-C should quit the application without a warning. Preferably it would not do anything (except if something is selected, then of course it should copy as it currently does).
I could not find any information in the docs about one's complement. The other basic bitwise operations work as expected (&, I, ^), but neither "not", nor "~", nor "!" work for me.
I think it would intuitive to have alternative operators as well in the form of "and", "or", "xor" and "not"
Similar to this https://en.cppreference.com/w/cpp/language/operator_alternative
Binary shifts are not really mentioned in the documentation. kalk's >> is an arithmetic shift as far as I can see. Might be worth clarifying.
Hi Alexandre Mutel(@xoofx),
Is it possible to compile kalk
under MonoDevelop?
If so, could you please provide some instructions on the README.md
file?
Many thanks in advance!!
Cheers,
Gus
kalk is supporting complex conversions with multiple units, but only if they are multiplied or divided or powered.
But today, kalk is not able to express simple conversions like:
[ยฐC] = [K] โ 273.15
The code involved is in KalkExpressionSimplifier.cs is relatively basic to simplify units operations (e.g C * km / h can be reduced to C * m / s
) but I'm not sure on how to handle the +/- delta easily.
For example a unit ยฐC/m
, how would be expressed the right side? (K-273)/m
?
(Sorry, I'd have submitted this as a pull request, but I couldn't find the apt packaging files.)
A very minor issue, but APT packaging standards make a point of insisting that packages touch nothing inside the /usr/local/* hierarchy, as that's supposed to be reserved for things the admin installed locally, meaning compiled from source. Having the link in /usr/local/* can confuse some management tools.
(And, after all, as a packaged app, kalk has earned its place in /usr/bin ๐ .)
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.