Skip to content

Commit

Permalink
Finish ref documentation v1
Browse files Browse the repository at this point in the history
  • Loading branch information
rendaw committed Sep 23, 2017
1 parent d9aed99 commit 8a25678
Show file tree
Hide file tree
Showing 17 changed files with 336 additions and 289 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public boolean isModified() {
return false;
return past.size() > 1 || !past.getLast().isEmpty();
} else {
return clearLevel != fixedTop();
return !clearLevel.equals(fixedTop());
}
}

Expand All @@ -183,7 +183,7 @@ public void clearModified(final Context context) {
finishChange(context);
final Integer oldClearLevel = clearLevel;
clearLevel = fixedTop();
if (clearLevel != oldClearLevel)
if (!Objects.equals(clearLevel, oldClearLevel))
modifiedStateListeners.forEach(l -> l.changed(false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.zarbosoft.merman.editor.wall.BrickInterface;
import com.zarbosoft.merman.editor.wall.bricks.BrickSpace;
import com.zarbosoft.merman.syntax.front.FrontSymbol;
import com.zarbosoft.merman.syntax.middle.MiddleArray;
import com.zarbosoft.merman.syntax.middle.MiddleArrayBase;
import com.zarbosoft.merman.syntax.style.Style;
import com.zarbosoft.merman.syntax.symbol.Symbol;
import com.zarbosoft.rendaw.common.DeadCode;
Expand Down Expand Up @@ -937,8 +937,7 @@ public boolean run(final Context context) {
private class ActionPaste extends ActionBase {
@Override
public boolean run(final Context context) {

final List<Atom> atoms = context.uncopy(((MiddleArray) self.value.middle()).type);
final List<Atom> atoms = context.uncopy(((MiddleArrayBase) self.value.middle()).type);
if (atoms.isEmpty())
return false;
context.history.apply(context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,25 +510,27 @@ public void clear(final Context context) {
@Override
public void receiveText(final Context context, final String text) {
String preview = value.get();
preview = preview.substring(0, range.beginOffset) +
text +
preview.substring(range.endOffset, preview.length());
if (!value.middle.matcher.match(preview)) {
if (range.endOffset == value.length() && last(atomVisual().children) == VisualPrimitive.this) {
context.history.finishChange(context);
final Value.Parent parent = atomVisual().atom.parent;
final Atom gap = context.syntax.suffixGap.create(true, atomVisual().atom);
parent.replace(context, gap);
gap.data.get("gap").selectDown(context);
context.selection.receiveText(context, text);
if (value.middle.matcher != null) {
preview = preview.substring(0, range.beginOffset) +
text +
preview.substring(range.endOffset, preview.length());
if (!value.middle.matcher.match(preview)) {
if (range.endOffset == value.length() && last(atomVisual().children) == VisualPrimitive.this) {
context.history.finishChange(context);
final Value.Parent parent = atomVisual().atom.parent;
final Atom gap = context.syntax.suffixGap.create(true, atomVisual().atom);
parent.replace(context, gap);
gap.data.get("gap").selectDown(context);
context.selection.receiveText(context, text);
}
return;
}
} else {
if (range.beginOffset != range.endOffset)
context.history.apply(context,
value.changeRemove(range.beginOffset, range.endOffset - range.beginOffset)
);
context.history.apply(context, value.changeAdd(range.beginOffset, text));
}
if (range.beginOffset != range.endOffset)
context.history.apply(context,
value.changeRemove(range.beginOffset, range.endOffset - range.beginOffset)
);
context.history.apply(context, value.changeAdd(range.beginOffset, text));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

@Configuration(name = "array")
public class BackArray extends BackPart {
@Configuration
public String name;
@Configuration
public List<BackPart> elements = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.zarbosoft.merman.syntax.AtomType;
import com.zarbosoft.merman.syntax.Syntax;
import com.zarbosoft.merman.syntax.middle.MiddlePrimitive;
import com.zarbosoft.merman.syntax.middle.primitive.Pattern;
import com.zarbosoft.pidgoon.Node;
import com.zarbosoft.pidgoon.events.Event;
import com.zarbosoft.pidgoon.events.Operator;
Expand All @@ -25,11 +24,11 @@ public class BackDataKey extends BackPart {
@Override
public Node buildBackRule(final Syntax syntax, final AtomType atomType) {
final MiddlePrimitive middle = atomType.getDataPrimitive(this.middle);
final Pattern.Matcher matcher = middle.pattern.new Matcher();
return new Operator(new Terminal() {
@Override
protected boolean matches(final Event event) {
return event instanceof EKeyEvent && matcher.match(((EKeyEvent) event).value);
return event instanceof EKeyEvent &&
(middle.matcher == null || middle.matcher.match(((EKeyEvent) event).value));
}
}, store -> {
store = (Store) store.pushStack(new Pair<>(this.middle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.zarbosoft.merman.syntax.AtomType;
import com.zarbosoft.merman.syntax.Syntax;
import com.zarbosoft.merman.syntax.middle.MiddlePrimitive;
import com.zarbosoft.merman.syntax.middle.primitive.Pattern;
import com.zarbosoft.pidgoon.Node;
import com.zarbosoft.pidgoon.events.Event;
import com.zarbosoft.pidgoon.events.Operator;
Expand All @@ -25,11 +24,11 @@ public class BackDataPrimitive extends BackPart {
@Override
public Node buildBackRule(final Syntax syntax, final AtomType atomType) {
final MiddlePrimitive middle = atomType.getDataPrimitive(this.middle);
final Pattern.Matcher matcher = middle.pattern.new Matcher();
return new Operator(new Terminal() {
@Override
protected boolean matches(final Event event) {
return event instanceof EPrimitiveEvent && matcher.match(((EPrimitiveEvent) event).value);
return event instanceof EPrimitiveEvent &&
(middle.matcher == null || middle.matcher.match(((EPrimitiveEvent) event).value));
}
}, store -> {
store = (Store) store.pushStack(new Pair<>(this.middle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.zarbosoft.merman.syntax.AtomType;
import com.zarbosoft.merman.syntax.Syntax;
import com.zarbosoft.merman.syntax.middle.MiddlePrimitive;
import com.zarbosoft.merman.syntax.middle.primitive.Pattern;
import com.zarbosoft.pidgoon.Node;
import com.zarbosoft.pidgoon.events.Event;
import com.zarbosoft.pidgoon.events.Operator;
Expand All @@ -29,11 +28,11 @@ public class BackDataType extends BackPart {
@Override
public Node buildBackRule(final Syntax syntax, final AtomType atomType) {
final MiddlePrimitive middle = atomType.getDataPrimitive(this.type);
final Pattern.Matcher matcher = middle.pattern.new Matcher();
return new Sequence().add(new Operator(new Terminal() {
@Override
protected boolean matches(final Event event) {
return event instanceof ETypeEvent && matcher.match(((ETypeEvent) event).value);
return event instanceof ETypeEvent &&
(middle.matcher == null || middle.matcher.match(((ETypeEvent) event).value));
}
}, store -> {
store = (Store) store.pushStack(new Pair<>(this.type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
import com.zarbosoft.merman.editor.visual.tags.PartTag;
import com.zarbosoft.merman.editor.visual.tags.Tag;
import com.zarbosoft.merman.editor.visual.visuals.VisualNestedFromArray;
import com.zarbosoft.merman.modules.hotkeys.grammar.Node;
import com.zarbosoft.merman.syntax.AtomType;
import com.zarbosoft.merman.syntax.middle.MiddleArray;
import com.zarbosoft.merman.syntax.symbol.Symbol;
import org.pcollections.HashTreePSet;
import org.pcollections.PSet;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
Expand All @@ -33,9 +31,6 @@ public String middle() {
public String middle;
private MiddleArray dataType;

@Configuration(optional = true)
public Map<String, Node> hotkeys = new HashMap<>();

@Override
public Visual createVisual(
final Context context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
import com.zarbosoft.merman.editor.visual.tags.PartTag;
import com.zarbosoft.merman.editor.visual.tags.Tag;
import com.zarbosoft.merman.editor.visual.visuals.VisualNested;
import com.zarbosoft.merman.modules.hotkeys.grammar.Node;
import com.zarbosoft.merman.syntax.AtomType;
import com.zarbosoft.merman.syntax.middle.MiddleAtom;
import com.zarbosoft.merman.syntax.symbol.Symbol;
import com.zarbosoft.merman.syntax.symbol.SymbolText;
import org.pcollections.PSet;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
Expand All @@ -34,9 +32,6 @@ public String middle() {
public String middle;
private MiddleAtom dataType;

@Configuration(optional = true)
public Map<String, Node> hotkeys = new HashMap<>();

@Configuration(optional = true)
public Symbol ellipsis = new SymbolText("...");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
import com.zarbosoft.merman.editor.visual.tags.PartTag;
import com.zarbosoft.merman.editor.visual.tags.Tag;
import com.zarbosoft.merman.editor.visual.visuals.VisualPrimitive;
import com.zarbosoft.merman.modules.hotkeys.grammar.Node;
import com.zarbosoft.merman.syntax.AtomType;
import com.zarbosoft.merman.syntax.middle.MiddlePrimitive;
import org.pcollections.HashTreePSet;
import org.pcollections.PSet;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
Expand All @@ -33,9 +31,6 @@ public class FrontDataPrimitive extends FrontPart {

private MiddlePrimitive dataType;

@Configuration(optional = true)
public Map<String, Node> hotkeys = new HashMap<>();

@Override
public Visual createVisual(
final Context context,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.zarbosoft.merman.syntax.middle.MiddleArrayBase;
import com.zarbosoft.merman.syntax.middle.MiddleAtom;
import com.zarbosoft.merman.syntax.middle.MiddlePrimitive;
import com.zarbosoft.merman.syntax.middle.primitive.Pattern;
import com.zarbosoft.merman.syntax.style.BoxStyle;
import com.zarbosoft.merman.syntax.style.Style;
import com.zarbosoft.merman.syntax.symbol.SymbolText;
Expand Down Expand Up @@ -403,7 +404,7 @@ public com.zarbosoft.pidgoon.Node matchGrammar(final FreeAtomType type) {
} else if (part instanceof FrontDataPrimitive) {
final MiddlePrimitive middle =
(MiddlePrimitive) type.middle.get(((FrontDataPrimitive) part).middle);
out.add(middle.pattern.build());
out.add((middle.pattern == null ? Pattern.repeatedAny : middle.pattern).build());
} else
throw new DeadCode();
}
Expand Down Expand Up @@ -435,7 +436,7 @@ public ParseResult parse(final Context context, final FreeAtomType type, final S
} else if (front instanceof FrontDataPrimitive) {
final MiddlePrimitive middle =
(MiddlePrimitive) type.middle.get(((FrontDataPrimitive) front).middle);
grammar.add("root", middle.pattern.build());
grammar.add("root", (middle.pattern == null ? Pattern.repeatedAny : middle.pattern).build());
} else
throw new DeadCode();
final Pair<ParseContext, Position> longest = new Parse<>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
import java.util.Map;
import java.util.Set;

import static com.zarbosoft.merman.syntax.middle.primitive.Pattern.repeatedAny;

@Configuration(name = "primitive")
public class MiddlePrimitive extends MiddlePart {

@Configuration(optional = true)
public Pattern pattern = repeatedAny;
public Pattern pattern = null;

public Pattern.Matcher matcher = null;

Expand All @@ -35,12 +33,12 @@ public ValuePrimitive get(final Map<String, com.zarbosoft.merman.document.values

@Override
public void finish(final Set<String> allTypes, final Set<String> scalarTypes) {
matcher = pattern.new Matcher();
if (pattern != null)
matcher = pattern.new Matcher();
}

@Override
public com.zarbosoft.merman.document.values.Value create(final Syntax syntax) {
return new ValuePrimitive(this, "");
}

}
10 changes: 0 additions & 10 deletions core/src/main/java/com/zarbosoft/merman/syntax/style/Style.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,6 @@ public class Style {
@Configuration(optional = true)
public Integer rotate = null;

// Shape only

@Configuration(optional = true)
public Integer converse = null;

@Configuration(optional = true)
public Integer transverse = null;

// Space only

@Configuration(optional = true)
Expand All @@ -93,8 +85,6 @@ public static class Baked {
public int fontSize = 14;
public String image = null;
public int rotate = 0;
public int converse = 12;
public int transverse = 12;
public int space = 0;
public BoxStyle.Baked box = new BoxStyle.Baked();
public ObboxStyle.Baked obbox = new ObboxStyle.Baked();
Expand Down
Loading

0 comments on commit 8a25678

Please sign in to comment.