Skip to content

Commit

Permalink
latest cbqn&iced, add tooltips, support windows, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
x86y committed Jun 22, 2023
1 parent b64bc03 commit 3f38acb
Show file tree
Hide file tree
Showing 116 changed files with 6,998 additions and 1,197 deletions.
Binary file added BQN.wasm
Binary file not shown.
4,322 changes: 3,383 additions & 939 deletions Cargo.lock

Large diffs are not rendered by default.

25 changes: 18 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,30 @@ edition = "2021"

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
once_cell = "1.15"
serde_json = "1.0.97"
once_cell = "1.18"
async-std = "1.0"
directories-next = "2.0"
cbqn = "0.0.8"
cbqn = { version = "0.1.0", default-features=false, optional = true }
phf = "0.11.1"
unicode-segmentation = "1.10.1"
iced = { version = "0.7.0", features = ["async-std", "debug"] }
iced_native = "0.8.0"
iced_style = "0.6.0"
itertools = "0.10.5"
iced = { git = "https://github.com/iced-rs/iced", features = ["async-std", "debug"], rev = "b38f7d28372712e345672515d8c1643bc040c1f1" }
iced_core = { git = "https://github.com/iced-rs/iced", rev = "b38f7d28372712e345672515d8c1643bc040c1f1" }
iced_runtime = { git = "https://github.com/iced-rs/iced", rev = "b38f7d28372712e345672515d8c1643bc040c1f1" }
iced_style = { git = "https://github.com/iced-rs/iced", rev = "b38f7d28372712e345672515d8c1643bc040c1f1" }
itertools = "0.11.0"
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
ngnk = { version = "0.2.3", optional = true}


[package.metadata.bundle]
name = "Beacon"
identifier = "io.github.me.bqn"
icon = ["assets/[email protected]"]

[features]
default = ["bqnnative"]
k = ["dep:ngnk"]
bqnnative = ["cbqn/native-backend"]
bqnwasm = ["cbqn/wasi-backend"]
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,22 @@ A native and a cross platform guide for BQN array programming language.
- Glyph toolbar (hover documentation missing for now)
- Tabs (Ctrl + n,p to go to next/prev tab & Ctrl + t,q to open/close a tab)
- History & tabs persistence
- Cross-platform (installation not yet streamlined for Windows though)
- Cross-platform


## Instructions
## Linux/MacOS instructions
```sh
> git clone https://github.com/x86y/beacon
> cd beacon
> cargo run --release
```

## Windows instructions
```sh
> git clone https://github.com/x86y/beacon
> cd beacon
> BQN_WASM=./BQN.wasm cargo run --release --no-default-features --features=bqnwasm
```

The code relies a lot on detegr's bqn bindings, and uses tooltip documentation files from his bqnlsp/genhelp tool! Check it out at:
https://sr.ht/~detegr/bqnlsp/
Binary file modified assets/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main() {
println!("cargo:rustc-link-search=native=./");
println!("cargo:rustc-link-lib=k");
}
Binary file added libk.so
Binary file not shown.
103 changes: 103 additions & 0 deletions src/docs/content.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/// Taken from detegr's bqnlsp/genhelp
/// https://sr.ht/~detegr/bqnlsp/
pub fn glyph_to_documentation(g: char) -> &'static str {
match g {
'+' => include_str!("mds/conjugate_add.md"),
'-' => include_str!("mds/negate_subtract.md"),
'×' => include_str!("mds/sign_multiply.md"),
'÷' => include_str!("mds/reciprocal_divide.md"),
'⋆' => include_str!("mds/exponential_power.md"),
'√' => include_str!("mds/squareroot_root.md"),
'⌊' => include_str!("mds/floor_minimum.md"),
'⌈' => include_str!("mds/ceiling_maximum.md"),
'∧' => include_str!("mds/sortup_and.md"),
'∨' => include_str!("mds/sortdown_or.md"),
'¬' => include_str!("mds/not_span.md"),
'|' => include_str!("mds/absolutevalue_modulus.md"),
'≤' => include_str!("mds/lessthanorequalto.md"),
'<' => include_str!("mds/enclose_lessthan.md"),
'>' => include_str!("mds/merge_greaterthan.md"),
'≥' => include_str!("mds/greaterthanorequalto.md"),
'=' => include_str!("mds/rank_equals.md"),
'≠' => include_str!("mds/length_notequals.md"),
'≡' => include_str!("mds/depth_match.md"),
'≢' => include_str!("mds/shape_notmatch.md"),
'⊣' => include_str!("mds/identity_left.md"),
'⊢' => include_str!("mds/identity_right.md"),
'⥊' => include_str!("mds/deshape_reshape.md"),
'∾' => include_str!("mds/join_jointo.md"),
'≍' => include_str!("mds/solo_couple.md"),
'⋈' => include_str!("mds/enlist_pair.md"),
'↑' => include_str!("mds/prefixes_take.md"),
'↓' => include_str!("mds/suffixes_drop.md"),
'↕' => include_str!("mds/range_windows.md"),
'«' => include_str!("mds/shiftbefore.md"),
'»' => include_str!("mds/shiftafter.md"),
'⌽' => include_str!("mds/reverse_rotate.md"),
'⍉' => include_str!("mds/transpose_reorderaxes.md"),
'/' => include_str!("mds/indices_replicate.md"),
'⍋' => include_str!("mds/gradeup_binsup.md"),
'⍒' => include_str!("mds/gradedown_binsdown.md"),
'⊏' => include_str!("mds/firstcell_select.md"),
'⊑' => include_str!("mds/first_pick.md"),
'⊐' => include_str!("mds/classify_indexof.md"),
'⊒' => include_str!("mds/occurrencecount_progressiveindexof.md"),
'∊' => include_str!("mds/markfirst_memberof.md"),
'⍷' => include_str!("mds/deduplicate_find.md"),
'⊔' => include_str!("mds/groupindices_group.md"),
'!' => include_str!("mds/assert_assertwithmessage.md"),
'˙' => include_str!("mds/constant.md"),
'˜' => include_str!("mds/self_swap.md"),
'∘' => include_str!("mds/atop.md"),
'○' => include_str!("mds/over.md"),
'⊸' => include_str!("mds/before_bind.md"),
'⟜' => include_str!("mds/after_bind.md"),
'⌾' => include_str!("mds/under.md"),
'⊘' => include_str!("mds/valences.md"),
'◶' => include_str!("mds/choose.md"),
'⎊' => include_str!("mds/catch.md"),
'⎉' => include_str!("mds/rank.md"),
'˘' => include_str!("mds/cells.md"),
'⚇' => include_str!("mds/depth.md"),
'¨' => include_str!("mds/each.md"),
'⌜' => include_str!("mds/table.md"),
'⍟' => include_str!("mds/repeat.md"),
'⁼' => include_str!("mds/undo.md"),
'´' => include_str!("mds/fold.md"),
'˝' => include_str!("mds/insert.md"),
'`' => include_str!("mds/scan.md"),
'←' => include_str!("mds/define.md"),
'⇐' => include_str!("mds/export.md"),
'↩' => include_str!("mds/change.md"),
',' => include_str!("mds/separator.md"),
'.' => include_str!("mds/namespacefield.md"),
'(' => include_str!("mds/beginexpression.md"),
')' => include_str!("mds/endexpression.md"),
'{' => include_str!("mds/beginblock.md"),
'}' => include_str!("mds/endblock.md"),
';' => include_str!("mds/nextbody.md"),
':' => include_str!("mds/header.md"),
'?' => include_str!("mds/predicate.md"),
'⟨' => include_str!("mds/beginlist.md"),
'⟩' => include_str!("mds/endlist.md"),
'[' => include_str!("mds/beginarray.md"),
']' => include_str!("mds/endarray.md"),
'‿' => include_str!("mds/strand.md"),
'·' => include_str!("mds/nothing.md"),
'•' => include_str!("mds/system.md"),
'𝕨' => include_str!("mds/leftargument.md"),
'𝕩' => include_str!("mds/rightargument.md"),
'𝔽' => include_str!("mds/modifierleftoperand.md"),
'𝔾' => include_str!("mds/2-modifierrightoperand.md"),
'𝕊' => include_str!("mds/currentfunction.md"),
'𝕣' => include_str!("mds/currentmodifier.md"),
'¯' => include_str!("mds/minus.md"),
'π' => include_str!("mds/pi.md"),
'∞' => include_str!("mds/infinity.md"),
'@' => include_str!("mds/nullcharacter.md"),
'#' => include_str!("mds/comment.md"),
'\'' => include_str!("mds/character.md"),
'"' => include_str!("mds/string.md"),
_ => unreachable!(),
}
}
11 changes: 11 additions & 0 deletions src/docs/mds/2-modifierrightoperand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Mathematical Double-struck G (`𝔾`)

## `𝔾`: 2-Modifier Right operand
[→full documentation](https://mlochbaum.github.io/BQN/doc/block.html#operands)

A variable assigned to the right operand of a 2-modifier block. `𝕘` can be used to access the right operand as a subject.

```bqn
5 +{𝕘}3 1
3
```
100 changes: 100 additions & 0 deletions src/docs/mds/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# REPL Help

| Symbol | Link |
|--------|------|
| `+` | [Conjugate, Add](conjugate_add.md) |
| `-` | [Negate, Subtract](negate_subtract.md) |
| `×` | [Sign, Multiply](sign_multiply.md) |
| `÷` | [Reciprocal, Divide](reciprocal_divide.md) |
| `` | [Exponential, Power](exponential_power.md) |
| `` | [Square root, Root](squareroot_root.md) |
| `` | [Floor, Minimum](floor_minimum.md) |
| `` | [Ceiling, Maximum](ceiling_maximum.md) |
| `` | [Sort Up, Logical And](sortup_and.md) |
| `` | [Sort Down, Logical Or](sortdown_or.md) |
| `¬` | [Logical Not, Span](not_span.md) |
| `\|` | [Absolute Value, Modulus](absolutevalue_modulus.md) |
| `` | [Lesser Than or Equal To](lessthanorequalto.md) |
| `<` | [Enclose, Lesser Than](enclose_lessthan.md) |
| `>` | [Merge, Greater Than](merge_greaterthan.md) |
| `` | [Greater Than or Equal To](greaterthanorequalto.md) |
| `=` | [Rank, Equal To](rank_equals.md) |
| `` | [Length, Not Equal To](length_notequals.md) |
| `` | [Depth, Match](depth_match.md) |
| `` | [Shape, Not Match](shape_notmatch.md) |
| `` | [Identity, Left](identity_left.md) |
| `` | [Identity, Right](identity_right.md) |
| `` | [Deshape, Reshape](deshape_reshape.md) |
| `` | [Join, Join To](join_jointo.md) |
| `` | [Solo, Couple](solo_couple.md) |
| `` | [Enlist, Pair](enlist_pair.md) |
| `` | [Prefixes, Take](prefixes_take.md) |
| `` | [Suffixes, Drop](suffixes_drop.md) |
| `` | [Range, Windows](range_windows.md) |
| `«` | [Nudge Back, Shift Before](shiftbefore.md) |
| `»` | [Nudge, Shift After](shiftafter.md) |
| `` | [Reverse, Rotate](reverse_rotate.md) |
| `` | [Transpose, Reorder Axes](transpose_reorderaxes.md) |
| `/` | [Indices, Replicate](indices_replicate.md) |
| `` | [Grade Up, Bins Up](gradeup_binsup.md) |
| `` | [Grade Down, Bins Down](gradedown_binsdown.md) |
| `` | [First Cell, Select](firstcell_select.md) |
| `` | [First, Pick](first_pick.md) |
| `` | [Classify, Index Of](classify_indexof.md) |
| `` | [Occurrence Count, Progressive Index Of](occurrencecount_progressiveindexof.md) |
| `` | [Mark Firsts, Member Of](markfirst_memberof.md) |
| `` | [Deduplicate, Find](deduplicate_find.md) |
| `` | [Group Indices, Group](groupindices_group.md) |
| `!` | [Assert, Assert With Message](assert_assertwithmessage.md) |
| `˙` | [Constant](constant.md) |
| `˜` | [Self, Swap](self_swap.md) |
| `` | [Atop, Dyadic Atop](atop.md) |
| `` | [Atop, Over](over.md) |
| `` | [Bind Left, Before, Dyadic Before](before_bind.md) |
| `` | [Bind, After, Dyadic After](after_bind.md) |
| `` | [Under](under.md) |
| `` | [Valences, Dyadic Valences](valences.md) |
| `` | [Choose](choose.md) |
| `` | [Catch](catch.md) |
| `` | [Rank](rank.md) |
| `˘` | [Cells](cells.md) |
| `` | [Depth](depth.md) |
| `¨` | [Each](each.md) |
| `` | [Table](table.md) |
| `` | [Repeat](repeat.md) |
| `` | [Undo](undo.md) |
| `´` | [Fold, Fold With Initial](fold.md) |
| `˝` | [Insert, Insert With Initial](insert.md) |
| `` ` `` | [Scan, Scan With initial](scan.md) |
| `` | [Define](define.md) |
| `` | [Export Definition, Export names](export.md) |
| `` | [Change, Modify](change.md) |
| `,` or `` | [Separator](separator.md) |
| `.` | [Namespace Field](namespacefield.md) |
| `(` | [Begin Expression](beginexpression.md) |
| `)` | [End Expression](endexpression.md) |
| `{` | [Begin Block](beginblock.md) |
| `}` | [End Block](endblock.md) |
| `;` | [Next Body](nextbody.md) |
| `:` | [Header](header.md) |
| `?` | [Predicate](predicate.md) |
| `` | [Begin list](beginlist.md) |
| `` | [End list](endlist.md) |
| `[` | [Begin array](beginarray.md) |
| `]` | [End array](endarray.md) |
| `` | [Strand](strand.md) |
| `·` | [Nothing](nothing.md) |
| `` | [System](system.md) |
| `𝕨` | [Left Argument](leftargument.md) |
| `𝕩` | [Right Argument](rightargument.md) |
| `𝔽` | [Modifier Left operand](modifierleftoperand.md) |
| `𝔾` | [2-Modifier Right operand](2-modifierrightoperand.md) |
| `𝕊` | [Current Function](currentfunction.md) |
| `𝕣` | [Current Modifier](currentmodifier.md) |
| `¯` | [Minus](minus.md) |
| `π` | [Pi](pi.md) |
| `` | [Infinity](infinity.md) |
| `@` | [Null Character](nullcharacter.md) |
| `#` | [Comment](comment.md) |
| `'` | [Character](character.md) |
| `"` | [String](string.md) |
33 changes: 33 additions & 0 deletions src/docs/mds/absolutevalue_modulus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Pipe (`|`)

## `| 𝕩`: Absolute Value
[→full documentation](https://mlochbaum.github.io/BQN/doc/arithmetic.html#additional-arithmetic)

Absolute Value of `𝕩`.

[Pervasive.](https://mlochbaum.github.io/BQN/doc/arithmetic.html#pervasion)

```bqn
| ¯2
2
| 1‿3‿¯4‿3
⟨ 1 3 4 3 ⟩
```
## `𝕨 | 𝕩`: Modulus
[→full documentation](https://mlochbaum.github.io/BQN/doc/arithmetic.html#additional-arithmetic)

Remainder of `𝕩` divided by `𝕨`.

[Pervasive.](https://mlochbaum.github.io/BQN/doc/arithmetic.html#pervasion)

```bqn
1 | 3
0
2 | 3‿4‿¯5
⟨ 1 0 1 ⟩
```
56 changes: 56 additions & 0 deletions src/docs/mds/after_bind.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Left Multimap (``)

## `𝔽⟜𝕘 𝕩`: Bind
[→full documentation](https://mlochbaum.github.io/BQN/doc/hook.html#bind)

Supply `𝕘` as a right argument to `𝔽` (`𝕩 𝔽 𝕘`).

`𝕘` is a constant, `𝔽` must be dyadic.

```bqn
-⟜3 9
6
- 3 9
Double subjects (missing ‿?)
9 - 3
6
```
## `𝔽⟜𝔾 𝕩`: After
[→full documentation](https://mlochbaum.github.io/BQN/doc/hook.html)

Apply `𝔾` to `𝕩`, and supply it as a right argument to `𝔽` (`𝕩 𝔽 (𝔾 𝕩)`).

`𝔽` must be dyadic, `𝔾` must be monadic.

```bqn
×⟜- 9
¯81
× - 9
¯1
9 × (- 9)
¯81
```
## `𝕨 𝔽⟜𝔾 𝕩`: Dyadic After
[→full documentation](https://mlochbaum.github.io/BQN/doc/hook.html)

Apply `𝔾` to `𝕩`, and supply it as a right argument to `𝔽` (`𝕨 𝔽 (𝔾 𝕩)`).

`𝔽` must be dyadic, `𝔾` must be monadic.

```bqn
2 ×⟜- 1
¯2
2 × (- 1)
¯2
```
Loading

0 comments on commit 3f38acb

Please sign in to comment.