40 Commits

Author SHA1 Message Date
27ea64e172 Merge branch 'dev' 2023-10-14 09:37:06 -07:00
b7a6378589 Fixed default.nix 2023-10-14 09:36:25 -07:00
d6f1ce0442 Merge minor chagnes from 'dev' 2023-10-14 09:21:01 -07:00
5e34017225 Added nix package 2023-10-14 09:13:54 -07:00
d9730fd699 Added contrib guide 2023-09-29 10:18:10 -07:00
5788ffa085 Updated TODO 2023-09-29 10:17:54 -07:00
a75f6197cd Merge pull request #11 from rm-dr/dev
Version bump to v1.1.5
2023-09-28 13:38:21 -07:00
2f2c005c86 Version bump 2023-09-28 13:32:34 -07:00
ffebcf2e15 Merge branch 'master' into dev 2023-09-28 13:30:08 -07:00
4e1df2399b Merge pull request #10 from bojohnson5/testing
fix electron mass
2023-09-28 13:29:23 -07:00
5a921cfc7b fix electron mass 2023-09-28 14:35:16 -04:00
2531524ffd Updated makefile 2023-09-22 11:22:36 -07:00
e5525adcca Updated todo 2023-09-22 11:05:58 -07:00
a61cbf29e5 Makefile edits 2023-09-22 11:05:30 -07:00
39ab47530e Merge pull request #9 from rm-dr/dev
Merge v1.1.4
2023-09-22 11:01:55 -07:00
be28669416 Sync with master 2023-09-22 11:00:28 -07:00
7658ff76ef Version bump 2023-09-22 10:59:35 -07:00
e9d392b80b Fixed linelocation inside user functions 2023-09-22 10:58:51 -07:00
63d4a01095 Merge pull request #8 from rm-dr/dev
Merge v1.1.3
2023-09-22 10:48:59 -07:00
6a025cbf1a Version bump 2023-09-22 10:47:38 -07:00
8a6c623ef2 Updated TODO 2023-09-22 10:47:25 -07:00
a1db2b6bb0 Fixed space key 2023-09-22 10:46:01 -07:00
c2d3e613d4 Added mobile warning 2023-09-22 10:41:01 -07:00
96a34dc05d Added makefile 2023-09-22 10:26:46 -07:00
42fdcd5853 Minor cleanup 2023-09-22 10:26:37 -07:00
cffb3726cc Character checks, minor cleanup 2023-09-22 10:08:28 -07:00
ef74b67f90 Moved server files to /server 2023-09-22 10:08:10 -07:00
32463ad6aa Updated shell.nix 2023-09-21 20:52:35 -07:00
413c34c440 Merge branch 'dev' of github.com:rm-dr/daisy into dev 2023-09-21 20:47:39 -07:00
a1d190b06e Updated TODO 2023-09-21 19:54:37 -07:00
178708a4ac Updated TODO 2023-09-21 19:52:48 -07:00
5bb8e2c4ce Merge 1.0.2 (#7)
* Fixed page scrolling

* Updated TODO

* Fixed a link

* Minor edits

* Version bump
2023-09-21 19:50:52 -07:00
49b88af2bb Version bump 2023-09-21 19:49:31 -07:00
a0fe0a9385 Minor edits 2023-09-21 19:49:12 -07:00
7215afcc7e Fixed a link 2023-09-21 19:43:40 -07:00
3ab559b240 Updated TODO 2023-09-21 19:43:00 -07:00
810e2a1267 Fixed page scrolling 2023-09-21 19:42:53 -07:00
798c9ceae9 Merge pull request #6 from rm-dr/dev
Merge v1.1.1
2023-09-21 19:37:34 -07:00
bab305e11d Merge pull request #4 from rm-dr/dev
Merge 1.1.0
2023-09-20 11:19:34 -07:00
a6c3ffa68d Merge v1.0.1 2023-08-17 10:30:26 -07:00
28 changed files with 154 additions and 55 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
/target /target
/src/target /src/target
/pkg /pkg
/result

31
CONTRIBUTING.MD Normal file
View File

@ -0,0 +1,31 @@
# Contribution guidelines for Daisy
## Pull requests
All PRs should merge to `dev`. See "branching" below.
## Versioning
Daisy uses [semantic versioning](https://semver.org/), which looks like `maj.min.patch`. In short:
- `maj`: Incremented on large, incompatible changes
- `min`: Incremented on new features
- `patch`: Incremented on bugfixes
Whenever one of the above fields is incremented, all sub-fields are reset to zero. When `min` is incremented, `patch` is set to zero.
## Branching
Daisy uses a branch model much like the one described [here](https://nvie.com/posts/a-successful-git-branching-model).
- `master`: 1 commit = 1 release. This is always a merge comit from `dev`, and is always tagged with a version.
- `dev`: main development branch. Never deleted. Most work happens here.
- `features`: temporary branches pulled from `dev` and merged to `dev` for larger features.
- Always merge with git's `--no-ff` option for a more detailed history.
## Releases
What to do
- Merge into `master` (`git merge --no-ff dev`)
- Tag merge commit on `master` (`git tag -a v1.0.0 -m "Version 1.0.0"`)
- `cargo publish`
- Update web demo & pull server (`make docker`)
- Update aur package

2
Cargo.lock generated
View File

@ -28,7 +28,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "daisycalc" name = "daisycalc"
version = "1.1.1" version = "1.1.5"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"num", "num",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "daisycalc" name = "daisycalc"
version = "1.1.1" version = "1.1.5"
edition = "2021" edition = "2021"
build = "buildscript/main.rs" build = "buildscript/main.rs"
license = "GPL-3.0-only" license = "GPL-3.0-only"

19
Makefile Normal file
View File

@ -0,0 +1,19 @@
release:
cargo build --release
test:
cargo test
run:
cargo run
wasm:
wasm-pack build --release --target web --out-dir server/pkg
publish:
cargo test
cargo publish
docker: wasm
docker build ./server -t git.betalupi.com/mark/daisy --no-cache
docker push git.betalupi.com/mark/daisy

View File

@ -1,10 +1,10 @@
![](./site/misc/readme-banner.png) ![](./server/site/resources/readme-banner.png)
A high-precision scientific calculator with support for units, derivatives, and more. A high-precision scientific calculator with support for units, derivatives, and more.
Many features are missing, this is still under development. Many features are missing, this is still under development.
**Web demo: [here](daisy.betalupi.com)** **Web demo: [here](https://daisy.betalupi.com) (won't work on mobile)**
# 📦 Installation # 📦 Installation
- **Cargo:** `cargo install daisycalc` - **Cargo:** `cargo install daisycalc`

34
TODO.md
View File

@ -1,55 +1,31 @@
## Version Bump checklist
- TODO: build and publish script
- update Cargo.toml
- run cargo test
- commit
- push
- merge
- git tag -a v1.0.0 -m "Version 1.0.0" on merge commit
- cargo publish
- Update packages
- Build wasm & push changes
## Pre-release
- Tuple operations
- we don't need vectors as arguments to operators
- Fix linelocation when evaluating functions
## Parser ## Parser
- Should functions be operators? - Should functions be operators?
- Binary, hex, octal numbers - Binary, hex, octal numbers
## General ## General
- Better tests (assignment, many expressions in one context) - Better tests (assignment, many expressions in one context)
- Optional config file - Optional config file
- Optional history file - Optional history file
- evaluate straight from command line
- Package for debian, nix - Package for debian, nix
## Internals
- Non-recursive treeify - Non-recursive treeify
- Faster factorial function. Maybe use gamma instead? - Faster factorial function. Maybe use gamma instead?
- Arbitrary precision float (rug doesn't offer arbitrary exponents) - Arbitrary precision floats
- we don't need vectors as arguments to operators
## Math Features ## Math Features
- Mean, Median, Min - Mean, Median, Min
- Arbitrary base logarithm - Arbitrary base logarithm
- Derivatives
- CAS features (trig, roots and powers)
- Complex numbers - Complex numbers
- acot/acoth functions - acot/acoth functions
- Sums and products with functional arguments - Sums and products with functional arguments
- Add functions: gcd, inverse mod, dice - Add functions: gcd, inverse mod, dice
- Tuple operations
## Prompt ## Prompt
- Fix terminal color detection - Fix terminal color detection
- Live syntax/output (like firefox js terminal) - Live syntax/output (like firefox js terminal)
- Syntax highlighting - Syntax highlighting
- fish-style tab completion - Numbered history recall
- Numbered expressions, history recall
- Enable/disable unit sets (defaults?) - Enable/disable unit sets (defaults?)
- Consistent unit ordering - Consistent unit ordering
@ -57,5 +33,5 @@
- long prefixes (megatonne, etc) - long prefixes (megatonne, etc)
- HMS for degrees - HMS for degrees
- Exact radians, using pi constant? - Exact radians, using pi constant?
- Weird units: flops, lumen, lux, bel - Odd units: flops, lumen, lux, bel
- Command to list units - Command to list units

View File

@ -49,7 +49,7 @@ value = "1.602176634e-19 C"
enum_name = "ElectronMass" enum_name = "ElectronMass"
pretty_name = "Electron mass" pretty_name = "Electron mass"
strings = ["electronmass"] strings = ["electronmass"]
value = "9.1093837015-31 kg" value = "9.1093837015e-31 kg"
[[constant]] [[constant]]
enum_name = "ProtonMass" enum_name = "ProtonMass"
@ -205,4 +205,4 @@ value = "TW * hour"
[[constant]] [[constant]]
enum_name = "PWH" enum_name = "PWH"
strings = "PWh" strings = "PWh"
value = "PW * hour" value = "PW * hour"

19
default.nix Normal file
View File

@ -0,0 +1,19 @@
{ lib, fetchgit, rustPlatform }:
rustPlatform.buildRustPackage rec {
pname = "daisy";
version = "1.1.4";
cargoLock.lockFile = src + /Cargo.lock;
src = fetchgit {
url = "https://github.com/rm-dr/daisy.git";
rev = "v${version}";
sha256 = "sha256-aENuKtE1+tBRN0HZzRr8Gk+dVEYTiP6FNRz817Sk88o=";
};
meta = with lib; {
description = "A pretty command-line scientific calculator";
homepage = "https://github.com/rm-dr/daisy";
#license = licenses.GPL;
maintainers = [ maintainers.tailhook ];
};
}

2
server/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/site/node_modules
/pkg

View File

@ -7,7 +7,7 @@ networks:
services: services:
daisy: daisy:
build: ./. build: .
container_name: daisy container_name: daisy
restart: unless-stopped restart: unless-stopped

View File

@ -22,7 +22,6 @@
margin: 0; margin: 0;
padding: 0; padding: 0;
overflow: hidden;
height: 100vh; height: 100vh;
} }
@ -101,6 +100,11 @@
<a href="https://aur.archlinux.org/packages/daisy" target="_blank" rel="noopener noreferrer">AUR</a> <a href="https://aur.archlinux.org/packages/daisy" target="_blank" rel="noopener noreferrer">AUR</a>
</div> </div>
<script>
var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
if (mobile) { alert("This site may not work on mobile."); }
</script>
<script type="module"> <script type="module">
// See wasm-pack docs // See wasm-pack docs
// Build with `wasm-pack build --release --target web --out-dir pkg` // Build with `wasm-pack build --release --target web --out-dir pkg`

17
server/site/package-lock.json generated Normal file
View File

@ -0,0 +1,17 @@
{
"name": "site",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"dependencies": {
"xterm": "^5.3.0"
}
},
"node_modules/xterm": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/xterm/-/xterm-5.3.0.tgz",
"integrity": "sha512-8QqjlekLUFTrU6x7xck1MsPzPA571K5zNqWm0M0oroYEWVOptZ0+ubQSkQ3uxIEhcIHRujJy6emDWX4A7qyFzg=="
}
}
}

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 92 KiB

View File

@ -1,11 +1,22 @@
{ nixpkgs ? import <nixpkgs> { }}:
let let
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/f155f0cf4ea43c4e3c8918d2d327d44777b6cad4.tar.gz") {}; # If you set hash to an empty string, you'll get
# an error with the correct hash.
pinnedPkgs = nixpkgs.fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
rev = "4ecab3273592f27479a583fb6d975d4aba3486fe";
sha256 = "btHN1czJ6rzteeCuE/PNrdssqYD2nIA4w48miQAFloM=";
};
pkgs = import pinnedPkgs {};
in pkgs.mkShell { in pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
cargo cargo
rustc rustc
rustfmt rustfmt
m4 rust-analyzer
wasm-pack
]; ];
} }

3
site/.gitignore vendored
View File

@ -1,3 +0,0 @@
/node_modules
/package-lock.json
/pkg

View File

@ -19,6 +19,7 @@ pub fn eval_operator(context: &mut Context, g: &Expression) -> Result<Option<Exp
if args.len() != 1 {panic!()}; if args.len() != 1 {panic!()};
let a = &args[0]; let a = &args[0];
let mut args_ll = op_loc.clone();
if sh_vars.len() == 1 { if sh_vars.len() == 1 {
if let Expression::Tuple(l, v) = a { if let Expression::Tuple(l, v) = a {
@ -28,6 +29,7 @@ pub fn eval_operator(context: &mut Context, g: &Expression) -> Result<Option<Exp
)) ))
}; };
args_ll += a.get_linelocation();
context.add_shadow(sh_vars[0].clone(), Some(a.clone())); context.add_shadow(sh_vars[0].clone(), Some(a.clone()));
} else { } else {
let Expression::Tuple(l, v) = a else { let Expression::Tuple(l, v) = a else {
@ -46,16 +48,26 @@ pub fn eval_operator(context: &mut Context, g: &Expression) -> Result<Option<Exp
let mut i = 0; let mut i = 0;
while i < sh_vars.len() { while i < sh_vars.len() {
args_ll += v[i].get_linelocation();
context.add_shadow(sh_vars[i].clone(), Some(v[i].clone())); context.add_shadow(sh_vars[i].clone(), Some(v[i].clone()));
i += 1; i += 1;
} }
} }
let r = evaluate(context, &exp)?; let r = evaluate(context, &exp);
context.clear_shadow(); context.clear_shadow();
return Ok(Some(r)); match r {
Ok(mut r) => {
r.set_linelocation(&args_ll);
return Ok(Some(r));
},
Err( (_, err) ) => {
return Err((args_ll, err));
}
}
}, },
Operator::Negative => { Operator::Negative => {

View File

@ -68,15 +68,12 @@ cfg_if::cfg_if! {
return format!("\r\n{}", daisy_prompt(state)); return format!("\r\n{}", daisy_prompt(state));
} }
if in_str.trim() == "quit" {
return "[quit]".to_string();
} else {
let r = crate::do_string( unsafe { &mut (*state).context }, &in_str);
match r { let r = crate::do_string( unsafe { &mut (*state).context }, &in_str);
Ok(t) | Err(t) => {
out += t; match r {
} Ok(t) | Err(t) => {
out += t;
} }
} }
}, },
@ -91,7 +88,20 @@ cfg_if::cfg_if! {
//'\x04' | '\x03' //'\x04' | '\x03'
//=> { break 'outer; }, //=> { break 'outer; },
_ => { unsafe { (*state).promptbuffer.add_char(s.chars().next().unwrap()); } }, // Only process sane characters
_ => {
let c = s.chars().next().unwrap();
match c {
'a'..='z' | 'A'..='Z' | '0'..='9'
|'!'|'@'|'#'|'$'|'%'|'^'|'&'|'*'|'('|')'
|'?'|'~'|','|'.'|'['|']'|' '
|'<'|'>'|'/'|'_'|'-'|':'|'|'|'='|'+'|';'
=> { unsafe { (*state).promptbuffer.add_char(c); } },
_ => {}
}
},
}; };
let t = unsafe { (*state).promptbuffer.write_prompt(&mut (*state).context) }; let t = unsafe { (*state).promptbuffer.write_prompt(&mut (*state).context) };

View File

@ -120,7 +120,7 @@ pub fn main() -> Result<(), std::io::Error> {
// Only process sane characters // Only process sane characters
'a'..='z' | 'A'..='Z' | '0'..='9' 'a'..='z' | 'A'..='Z' | '0'..='9'
|'!'|'@'|'#'|'$'|'%'|'^'|'&'|'*'|'('|')' |'!'|'@'|'#'|'$'|'%'|'^'|'&'|'*'|'('|')'
|'?'|'~'|','|'.'|'['|']' |'?'|'~'|','|'.'|'['|']'|' '
|'<'|'>'|'/'|'_'|'-'|':'|'|'|'='|'+'|';' |'<'|'>'|'/'|'_'|'-'|':'|'|'|'='|'+'|';'
=> { pb.add_char(*q); }, => { pb.add_char(*q); },