-
Notifications
You must be signed in to change notification settings - Fork 62
Table projector #1674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
7h3kk1d
wants to merge
94
commits into
dev
Choose a base branch
from
dataframe-projector
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+335
−10
Open
Table projector #1674
Changes from 89 commits
Commits
Show all changes
94 commits
Select commit
Hold shift + click to select a range
9222c73
Add DataFrame projector and related styles
7h3kk1d 2954934
Abbreviate data in dataframes
7h3kk1d 9d82322
Remove debug statements and fix build
7h3kk1d 0fedf62
Remove commented-out color
7h3kk1d def7f47
Improve dynamic sizing of DataFrameProj
7h3kk1d 870aa80
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d cbada86
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d 99f44f2
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d 001dbf5
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d 53a9ce1
Merge remote-tracking branch 'origin/dataframe-projection' into dataf…
7h3kk1d 07ffd37
Fix compilation
7h3kk1d 173c4bd
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d 5c85f9f
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d 66c5794
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d 99822a3
Fix: update abbreviation function to use strip_ascriptions instead of…
7h3kk1d fa4a07f
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d 65bebf0
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d 9d13288
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d bd4b665
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d 1295678
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d 8810c15
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d accd35b
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d b7cf243
for table projector
7h3kk1d a52715b
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d 9c4a797
Rename DataFrame to Table
7h3kk1d e876a01
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d 7c38c6b
Project tables in evaluation output
7h3kk1d aefdcf1
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d 98ddf77
Merge branch 'dataframe-projection' into dataframe-projector
7h3kk1d ea3f127
Merge branch 'dev' into dataframe-projector
7h3kk1d 223262e
Merge branch 'dev' into dataframe-projector
7h3kk1d 934a224
Merge branch 'dev' into dataframe-projector
7h3kk1d a833ece
Merge branch 'dev' into dataframe-projector
7h3kk1d 5d504e8
Merge branch 'dev' into dataframe-projector
7h3kk1d c534142
Merge branch 'dev' into dataframe-projector
7h3kk1d ff267b2
Merge branch 'dev' into dataframe-projector
7h3kk1d 04d9070
Merge branch 'dev' into dataframe-projector
7h3kk1d b0c6ac6
Merge branch 'dev' into dataframe-projector
7h3kk1d fe6096b
Beginning table projector dynamics
7h3kk1d b7e35f6
worst closure selector
7h3kk1d 4007565
Add closure navigation buttons to table header
7h3kk1d 490d757
add column drop to table probe projector
7h3kk1d 3ba2a2b
Add column menu with options for dropping, renaming, and rearranging …
7h3kk1d f03b6df
Add close menu functionality to column menu actions
7h3kk1d 80bb634
Mark params unused
7h3kk1d e8a2ec2
parse fields
7h3kk1d 2b53b53
Submenu
7h3kk1d cb9c590
awaiting type hole inference
7h3kk1d 6eba36a
parse to convert
7h3kk1d 9882413
Add conversion functions for column types in TableProbe
7h3kk1d 75b346c
Add comparison functions for int, float, sint, and nat types
7h3kk1d 3b85132
Add sorting functionality for columns in TableProbe
7h3kk1d f02e1eb
Refactor column conversion functions to a single generic function
7h3kk1d e8db220
Update TableProbe name formatting
7h3kk1d d52e32e
Add column movement functionality
7h3kk1d fc76bd3
Refactor move_column function to accept dynamic type as a parameter
7h3kk1d dc96367
Refactor column movement logic to use a dedicated can_move_column fun…
7h3kk1d 4fe6c68
dry
7h3kk1d 24d073e
fix conversion functions
7h3kk1d fe1ba4e
Refactor conversion logic to use a dedicated conversion_functions fun…
7h3kk1d 4051a0c
Refactor conversion functions to return tuples of display names and f…
7h3kk1d 0303815
Cleanup
7h3kk1d eae4c3d
Add newline for reverse function ap
7h3kk1d 0d2298d
Stop folding functions in projector syntax
7h3kk1d a9c29f4
More actions
7h3kk1d 7f7b563
Fix exp to segment for reverse ap
7h3kk1d 480f861
add helper functions for pipelining
7h3kk1d 509bc31
Implement rename_column with prompt for now
7h3kk1d ea614f2
Switch get_dynamic_type to only get a single closures type
7h3kk1d bfb3a0a
spaces in projector names don't work
7h3kk1d 3017e0e
Merge branch 'dev' into dataframe-projector
7h3kk1d 89cf729
Merge remote-tracking branch 'origin/dev' into dataframe-projector
7h3kk1d 6b575cd
Merge branch 'dev' into dataframe-projector
7h3kk1d fa730f8
Fix compilation
7h3kk1d 90b2f6b
Merge branch 'dev' into dataframe-projector
7h3kk1d 9bf045e
Merge branch 'dev' into dataframe-projector
7h3kk1d f4b005e
Merge branch 'dev' into dataframe-projector
7h3kk1d 9021ccf
Merge remote-tracking branch 'origin/dev' into dataframe-projector
7h3kk1d 75542da
Remove debug print statements from ExpToSegment and TableProj
7h3kk1d 16f615d
Refactor project_table_if to remove unnecessary braces
7h3kk1d a95720c
Merge remote-tracking branch 'origin/dev' into dataframe-projector
7h3kk1d dd2ce82
Add Table to livelit projectors list
7h3kk1d 0908972
Merge branch 'dev' into dataframe-projector
7h3kk1d c9a5754
Remove debug print statements from exp_to_pretty function
7h3kk1d 28f2877
Fix error message in project_table_if function
7h3kk1d 71a7cd5
Refactor extract_labeled_tuple_entries and table_of functionsto not u…
7h3kk1d afabba7
Use table projector in tables doc slide
7h3kk1d d56a5f2
Remove unused key_handler function from TableProj.re
7h3kk1d 77a37b3
Update table styles and color variables for improved contrast
7h3kk1d 0d6b44e
Remove unused code
7h3kk1d a65d591
Table styles
7h3kk1d 78918c5
Merge branch 'dev' into dataframe-projector
7h3kk1d c87a990
Fix error message in get function for table retrieval
7h3kk1d 698d3ee
Merge branch 'dev' into dataframe-projector
7h3kk1d File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,181 @@ | ||
| open Util; | ||
| open Virtual_dom.Vdom; | ||
| open ProjectorBase; | ||
| open Language; | ||
|
|
||
| let max_column_length = 12; | ||
|
|
||
| let rec extract_labeled_tuple_entries = | ||
| (exp: Exp.t): option(list((LabeledTuple.label, DHExp.t))) => { | ||
| switch (exp.term) { | ||
| | Parens(e) => extract_labeled_tuple_entries(e) | ||
| | Tuple(es) => | ||
| OptUtil.traverse( | ||
| (e: Exp.t) => { | ||
| switch (e.term) { | ||
| | TupLabel({term: Label(l), _}, inner) => Some((l, inner)) | ||
| | _ => None | ||
| } | ||
| }, | ||
| es, | ||
| ) | ||
| | _ => None | ||
| }; | ||
| }; | ||
|
|
||
| let table_of = | ||
| (any: Any.t): option((list(LabeledTuple.label), list(list(Exp.t)))) => | ||
| switch (any) { | ||
| | Exp({term: ListLit(es), _}) => | ||
| switch ( | ||
| OptUtil.traverse( | ||
| e => extract_labeled_tuple_entries(e) |> Option.map(List.split), | ||
| es, | ||
| ) | ||
| ) { | ||
| | Some(data: list((list(string), list(TermBase.exp_t)))) => | ||
| let (headers: list(list(string)), rows: list(list(TermBase.exp_t))) = | ||
| List.split(data); | ||
|
|
||
| // If all the headers aren't the same return None | ||
| switch (headers) { | ||
| | [] => None | ||
| | [h, ..._] when List.for_all(x => x == h, headers) => | ||
| let headers = h; | ||
| Some((headers, rows)); | ||
|
|
||
| | _ => None | ||
| }; | ||
| | None => None | ||
| } | ||
| | _ => None | ||
| }; | ||
|
|
||
| let get = (info: info): (list(LabeledTuple.label), list(list(Exp.t))) => | ||
| switch (info.syntax |> info.utility.seg_to_term) { | ||
| | Some(s) => | ||
| switch (table_of(s)) { | ||
| | Some(s) => s | ||
| | None => failwith("TextArea: get: Not a table") | ||
| } | ||
| | None => failwith("TextArea: get: Not a table") | ||
| }; | ||
|
|
||
| let len_seg = (utility: utility, seg: Segment.t): int => | ||
| seg |> utility.seg_to_string |> String.length; | ||
|
|
||
| let seg_of_exp = (utility: utility, exp: Exp.t): (Segment.t, int) => { | ||
| let seg = utility.term_to_seg(Exp(exp)); | ||
| (seg, len_seg(utility, seg)); | ||
| }; | ||
|
|
||
| let abbreviated_seg_of = | ||
| (utility: utility, available: int, exp: Exp.t): (Segment.t, int) => { | ||
| let (abbr_exp, _length) = | ||
| exp |> DHExp.strip_ascriptions |> Abbreviate.abbreviate_exp(~available); | ||
| seg_of_exp(utility, abbr_exp); | ||
| }; | ||
| let length_cls = (length: int): string => | ||
| if (length > 10) { | ||
| "extra"; | ||
| } else if (length > 9) { | ||
| "s6"; | ||
| } else if (length > 8) { | ||
| "s5"; | ||
| } else if (length > 7) { | ||
| "s4"; | ||
| } else if (length > 6) { | ||
| "s3"; | ||
| } else if (length > 5) { | ||
| "s2"; | ||
| } else if (length > 4) { | ||
| "s1"; | ||
| } else { | ||
| "s0"; | ||
| }; | ||
| let value_view = (_info: info, utility: utility, view_seg, exp) => { | ||
| let (seg, length) = abbreviated_seg_of(utility, max_column_length, exp); | ||
|
|
||
| Node.div( | ||
| ~attrs=[Attr.classes(["value", length_cls(length)])], | ||
| [view_seg(Sort.Exp, seg)], | ||
| ); | ||
| }; | ||
|
|
||
| let table = | ||
| ( | ||
| info, | ||
| ~parent as _: external_action => Ui_effect.t(unit), | ||
| (headers, rows): (list(LabeledTuple.label), list(list(Exp.t))), | ||
| ~view_seg: (Sort.t, Segment.t) => Node.t, | ||
| ) => | ||
| Node.table( | ||
| ~attrs=[Attr.classes(["table"])], | ||
| [ | ||
| Node.thead([ | ||
| Node.tr(List.map(h => Node.th([Node.text(h)]), headers)), | ||
| ]), | ||
| Node.tbody( | ||
| List.map( | ||
| row => | ||
| Node.tr( | ||
| List.map( | ||
| e => Node.td([value_view(info, info.utility, view_seg, e)]), | ||
| row, | ||
| ), | ||
| ), | ||
| rows, | ||
| ), | ||
| ), | ||
| ], | ||
| ); | ||
|
|
||
| module M: Projector = { | ||
| [@deriving (show({with_path: false}), sexp, yojson)] | ||
| type model = unit; | ||
| [@deriving (show({with_path: false}), sexp, yojson)] | ||
| type action = unit; | ||
|
|
||
| let init = (any: Any.t) => | ||
| switch (table_of(any)) { | ||
| | Some(_) => Some() | ||
| | None => None | ||
| }; | ||
|
|
||
| let focusable = | ||
| Focusable.{ | ||
| pointer: None, | ||
| keyboard: None, | ||
| }; | ||
| let dynamics = false; | ||
| let placeholder = (_, info) => { | ||
| let (header, rows): (list(string), list(list(TermBase.exp_t))) = | ||
| info |> get; | ||
| let max_header_length = | ||
| header |> List.map(String.length) |> List.fold_left((+), 0); | ||
| let max_row_length = | ||
| rows | ||
| |> List.map(row => | ||
| row | ||
| |> List.map(e => | ||
| Abbreviate.abbreviate_exp(~available=max_column_length, e) | ||
| |> snd | ||
| ) | ||
| |> List.fold_left((+), 0, _) | ||
| ) | ||
| |> List.fold_left(max, 0, _); | ||
| let max_length = max(max_header_length, max_row_length); | ||
|
|
||
| let num_rows = List.length(rows); | ||
| let num_cols = List.length(header); | ||
| ProjectorCore.Shape.{ | ||
| vertical: Block(min(num_rows + 1, 10)), // +1 for header row | ||
| /* +2 for left and right padding */ | ||
| horizontal: 4 + max_length * 1 + num_cols * 2 // +2 for left and right padding | ||
| }; | ||
| }; | ||
| let update = (model, _, _) => model; | ||
|
|
||
| let view = ({info, parent, view_seg, _}: View.args(model, action)): View.t => | ||
| View.mk(table(info, ~view_seg, ~parent, info |> get)); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.