Skip to content
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

edit action history panel #97

Merged
merged 68 commits into from
Feb 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
a507954
Implement undo and redo
PPER Jan 2, 2020
58f0135
Merge branch 'dev' into undo
PPER Jan 2, 2020
627d26c
Fix duplicate `user_newlines`
adamsmd Jan 2, 2020
24dee2c
modify redo and undo
PPER Jan 2, 2020
4c39c75
resolve conflict
PPER Jan 2, 2020
34f4cb7
integrate into new module UndoHistory
PPER Jan 2, 2020
8b16042
Test zoe's ssh
PPER Jan 2, 2020
2e14acc
modify Zlist.shift_next and prev to return option type
PPER Jan 3, 2020
8d2aba4
small adjustment
PPER Jan 4, 2020
d37d48c
add function undoable_action
PPER Jan 4, 2020
c42da01
undo and redo button
PPER Jan 4, 2020
94b007b
history panel
PPER Jan 4, 2020
defd7ec
history panel draft
PPER Jan 7, 2020
f21fecd
Merge branch 'dev' into undo
PPER Jan 7, 2020
7bf0378
history panel
PPER Jan 7, 2020
867c99a
resolve confilt after merging dev
PPER Jan 7, 2020
31a100d
basic history panel without group
PPER Jan 10, 2020
db0edab
set different classes to prev and suc history
PPER Jan 10, 2020
2e3dd0e
click to go to certain edit-state
PPER Jan 10, 2020
f3c99e1
basic history panel
PPER Jan 10, 2020
5bc2ad3
modify display history content
PPER Jan 10, 2020
ec01112
finish basic panel, start to group edit actions
PPER Jan 10, 2020
90f2734
some problems on red/undo shift
PPER Jan 11, 2020
cc68601
history panel with grouping
PPER Jan 11, 2020
7f02a54
finish basic edit action his panel
PPER Jan 11, 2020
b5c71e0
modify ui. start to add card state
PPER Jan 11, 2020
c6fd05c
add overall expand control button
PPER Jan 11, 2020
1576b9a
fix toggle-all hidden history button
PPER Jan 11, 2020
6d78894
complete edit action panel without card splited
PPER Jan 11, 2020
61968f8
undo_history store cardstacks_state
PPER Jan 14, 2020
323a3b4
readable data structure
PPER Jan 17, 2020
ca64f96
make code more readable. start to try to swap suffix and prefix
PPER Jan 17, 2020
5433dee
bug in line 121 in historypanel.re
PPER Jan 17, 2020
f6906c0
fix order but have bugs in clicking
PPER Jan 17, 2020
81631d4
fix clicking
PPER Jan 17, 2020
0aa3be0
rename state_list to group_entries
PPER Jan 17, 2020
c3d33e9
reverse store order
PPER Jan 19, 2020
ff0da59
make cardstacks into seperate file
PPER Jan 21, 2020
dab07cf
generate id when generate visualization
PPER Jan 21, 2020
7dbb4d9
delete id in undo_history
PPER Jan 21, 2020
5a210e2
add some comment
PPER Jan 21, 2020
5a4ecfb
history panel
PPER Jan 21, 2020
d582439
merge
PPER Jan 29, 2020
4bc7429
fix bug after merging dev, start to try new grouping
PPER Jan 29, 2020
326fd53
extract cursor_term
PPER Feb 1, 2020
3fa0230
fix extract cursor term
PPER Feb 1, 2020
08cd1ac
start to change undohistory data type
PPER Feb 1, 2020
81b13a5
update cursor_term
PPER Feb 1, 2020
9328b87
remove cursor_term form CursorInfo and add to UndoHistory
PPER Feb 1, 2020
e3bb4ad
finish grouping, start to build a func of display string
PPER Feb 1, 2020
8070b58
display string draft
PPER Feb 1, 2020
3944994
zline need to be modified
PPER Feb 2, 2020
ba0adb8
finish basic new version of panel, start to improve empty lines grouping
PPER Feb 2, 2020
e56b25f
fix empty line group
PPER Feb 2, 2020
e8340a4
try to display 'clear lines' when cursor at the front of the hole and…
PPER Feb 2, 2020
e4450b1
clear some unused functions and comments
PPER Feb 2, 2020
c4affdf
add some comments
PPER Feb 2, 2020
6e40072
final check, add some comments
PPER Feb 3, 2020
bb25380
formatting
cyrus- Feb 4, 2020
f2b332b
construct keyword
PPER Feb 4, 2020
34bb4fa
display delete content
PPER Feb 4, 2020
9bec234
change dom div
PPER Feb 5, 2020
3375dcb
fix some display case
PPER Feb 5, 2020
bb38190
resolve conflict
PPER Feb 5, 2020
eb894a2
delete some comments
PPER Feb 5, 2020
9c0d470
refmt
cyrus- Feb 6, 2020
228c239
merge to new dev
PPER Feb 12, 2020
b505ff6
add new line detection
PPER Feb 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/hazelcore/semantics/Action.re
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@ type t =
| Backspace
| Construct(shape);

/* group entries in undo_history if their shapes are similar */
let can_group_shape = (shape_1: shape, shape_2: shape): bool => {
switch (shape_1, shape_2) {
| (SLine, SLine)
| (SChar(_), _) => true
| (SParenthesized, _)
| (SList, _)
| (SAsc, _)
| (SLam, _)
| (SListNil, _)
| (SInj(_), _)
| (SLet, _)
| (SLine, _)
| (SCase, _)
| (SOp(_), _)
| (SApPalette(_), _) => false
};
};

module Outcome = {
type t('success) =
| Succeeded('success)
Expand Down
158 changes: 158 additions & 0 deletions src/hazelcore/semantics/CursorInfo.re
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ type typed =
| OnLine
| OnRule;

type cursor_term =
| Exp(CursorPosition.t, UHExp.operand)
| Pat(CursorPosition.t, UHPat.operand)
| Typ(CursorPosition.t, UHTyp.operand)
| ExpOp(CursorPosition.t, UHExp.operator)
| PatOp(CursorPosition.t, UHPat.operator)
| TypOp(CursorPosition.t, UHTyp.operator)
| Line(CursorPosition.t, UHExp.line)
| Rule(CursorPosition.t, UHExp.rule);

// TODO refactor into variants
// based on term family and shape
[@deriving sexp]
Expand All @@ -90,6 +100,154 @@ type t = {
uses: option(UsageAnalysis.uses_list),
};

let rec extract_cursor_term = (exp: ZExp.t): (option(cursor_term), bool) => {
let cursor_term = extract_cursor_exp_term(exp);
let prev_is_empty_line = {
let prefix = ZList.prj_prefix(exp);
switch (ListUtil.split_last(prefix)) {
| None => false
| Some((_, elt)) => UHExp.is_empty_line(elt)
};
};
(cursor_term, prev_is_empty_line);
}
and extract_cursor_exp_term = (exp: ZExp.t): option(cursor_term) => {
extract_from_zline(ZList.prj_z(exp));
}
and extract_from_zline = (zline: ZExp.zline): option(cursor_term) => {
switch (zline) {
| CursorL(cursor_pos, uex_line) => Some(Line(cursor_pos, uex_line))
| ExpLineZ(zopseq) => extract_from_zexp_opseq(zopseq)
| LetLineZP(zpat, _, _) => extract_cursor_pat_term(zpat)
| LetLineZA(_, ztyp, _) => extract_cursor_type_term(ztyp)
| LetLineZE(_, _, zexp) => extract_cursor_exp_term(zexp)
};
}
and extract_from_zexp_operand =
(zexp_operand: ZExp.zoperand): option(cursor_term) => {
switch (zexp_operand) {
| CursorE(cursor_pos, operand) => Some(Exp(cursor_pos, operand))
| ParenthesizedZ(zexp) => extract_cursor_exp_term(zexp)
| LamZP(_, zpat, _, _) => extract_cursor_pat_term(zpat)
| LamZA(_, _, ztyp, _) => extract_cursor_type_term(ztyp)
| LamZE(_, _, _, zexp)
| InjZ(_, _, zexp)
| CaseZE(_, zexp, _, _) => extract_cursor_exp_term(zexp)
| CaseZR(_, _, zrules, _) => extract_from_zrules(zrules)
| CaseZA(_, _, _, ztyp) => extract_cursor_type_term(ztyp)
| ApPaletteZ(_, _, _, _) => failwith("ApPalette is not implemented")
};
}
and extract_from_zrules = (zrules: ZExp.zrules): option(cursor_term) => {
let zrule = ZList.prj_z(zrules);
switch (zrule) {
| CursorR(cursor_pos, uex_rule) => Some(Rule(cursor_pos, uex_rule))
| RuleZP(zpat, _) => extract_cursor_pat_term(zpat)
| RuleZE(_, zexp) => extract_cursor_exp_term(zexp)
};
}
and extract_from_zexp_opseq = (zopseq: ZExp.zopseq): option(cursor_term) => {
switch (zopseq) {
| ZOpSeq(_, zseq) =>
switch (zseq) {
| ZOperand(zoperand, _) => extract_from_zexp_operand(zoperand)
| ZOperator(zoperator, _) =>
let (cursor_pos, uop) = zoperator;
Some(ExpOp(cursor_pos, uop));
}
};
}
and extract_cursor_pat_term = (zpat: ZPat.t): option(cursor_term) => {
switch (zpat) {
| ZOpSeq(_, zseq) =>
switch (zseq) {
| ZOperand(zpat_operand, _) => extract_from_zpat_operand(zpat_operand)
| ZOperator(zpat_operator, _) =>
let (cursor_pos, uop) = zpat_operator;
Some(PatOp(cursor_pos, uop));
}
};
}
and extract_from_zpat_operand =
(zpat_operand: ZPat.zoperand): option(cursor_term) => {
switch (zpat_operand) {
| CursorP(cursor_pos, upat_operand) => Some(Pat(cursor_pos, upat_operand))
| ParenthesizedZ(zpat)
| InjZ(_, _, zpat) => extract_cursor_pat_term(zpat)
};
}
and extract_cursor_type_term = (ztyp: ZTyp.t): option(cursor_term) => {
switch (ztyp) {
| ZOpSeq(_, zseq) =>
switch (zseq) {
| ZOperand(ztyp_operand, _) => extract_from_ztyp_operand(ztyp_operand)
| ZOperator(ztyp_operator, _) =>
let (cursor_pos, uop) = ztyp_operator;
Some(TypOp(cursor_pos, uop));
}
};
}
and extract_from_ztyp_operand =
(ztyp_operand: ZTyp.zoperand): option(cursor_term) => {
switch (ztyp_operand) {
| CursorT(cursor_pos, utyp_operand) => Some(Typ(cursor_pos, utyp_operand))
| ParenthesizedZ(ztyp)
| ListZ(ztyp) => extract_cursor_type_term(ztyp)
};
};

let can_group_cursor_term =
(cursor_term_1: option(cursor_term), cursor_term_2: option(cursor_term))
: bool => {
switch (cursor_term_1, cursor_term_2) {
| (None, _)
| (_, None) => false
| (Some(cur1), Some(cur2)) =>
switch (cur1, cur2) {
| (Exp(_, op1), Exp(_, op2)) => UHExp.can_group_operand(op1, op2)
| (Pat(_, op1), Pat(_, op2)) => UHPat.can_group_operand(op1, op2)
| (Line(_, line1), Line(_, line2)) =>
UHExp.can_group_lines(line1, line2)
| (Exp(_, _), _)
| (Pat(_, _), _)
| (Typ(_, _), _)
| (ExpOp(_, _), _)
| (PatOp(_, _), _)
| (TypOp(_, _), _)
| (Line(_, _), _)
| (Rule(_, _), _) => false
}
};
};
let is_hole = (cursor_term: option(cursor_term)): bool => {
switch (cursor_term) {
| None => false
| Some(cursor_term') =>
switch (cursor_term') {
| Exp(_, exp) => UHExp.operand_is_hole(exp)
| Pat(_, pat) => UHPat.operand_is_hole(pat)
| Typ(_, typ) => UHTyp.operand_is_hole(typ)
| ExpOp(_, _)
| PatOp(_, _)
| TypOp(_, _)
| Line(_, _)
| Rule(_, _) => false
}
};
};

let get_cursor_pos = (cursor_term: cursor_term) => {
switch (cursor_term) {
| Exp(cursor_pos, _)
| Pat(cursor_pos, _)
| Typ(cursor_pos, _)
| ExpOp(cursor_pos, _)
| PatOp(cursor_pos, _)
| TypOp(cursor_pos, _)
| Line(cursor_pos, _)
| Rule(cursor_pos, _) => cursor_pos
};
};
let mk = (~uses=?, typed, ctx) => {typed, ctx, uses};

let get_ctx = ci => ci.ctx;
Expand Down
3 changes: 1 addition & 2 deletions src/hazelcore/semantics/ErrStatus.re
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ module HoleReason = {
type t =
| TypeInconsistent
| WrongLength;
};
} /* Variable: `err` */;

/* Variable: `err` */
[@deriving sexp]
type t =
| NotInHole
Expand Down
6 changes: 3 additions & 3 deletions src/hazelcore/semantics/Monads.re
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* TODO: we might want to just use this API?

https://github.com/rgrinberg/ocaml-mtl/blob/master/lib/mtl.ml
https://github.com/rgrinberg/ocaml-mtl/blob/master/lib/mtl.ml

Though it's a bit heavy, especially with the extra type parameter...
Though it's a bit heavy, especially with the extra type parameter...

In any case, that's a good reference. */
In any case, that's a good reference. */

module type MONAD = {
[@deriving sexp]
Expand Down
Loading