Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions lib/action/action_region.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
library action_region;

import 'package:code_steps/editor/ace_facade.dart';
import 'package:code_steps/editor/lesson_code_editor_component.dart';
import 'package:code_steps/lesson_serializer.dart';
import 'package:code_steps/action/step_action.dart';
import 'package:ace/ace.dart';

class ActionRegion {
Set<StepActionType> actions;
Range range;
AceRange range;

ActionRegion(this.range, [this.actions]) {
if (this.actions == null) this.actions = new Set<StepActionType>();
Expand Down
15 changes: 11 additions & 4 deletions lib/action/step.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import 'dart:async';
import 'package:code_steps/action/action_region.dart';

class Step {
String explanation;
String code;
Set<ActionRegion> activeRegions;
Set<ActionRegion> regions;

Step(this.explanation, this.code, this.activeRegions) {
this.activeRegions ??= new Set<ActionRegion>();
Step(this.explanation, this.code, this.regions) {
this.regions ??= new Set<ActionRegion>();
}

Map toJson() => {'explanation': explanation, 'regions': activeRegions};
Map toJson() {
print('toJson called');
return {'TODO': 'FIXME'};
}

static Step deserialize(Map data) {
if (data['regions'] == null || data['code'] == null || data['explanation'] == null) {
print('malformed step: ${data.keys}');
}
Set<ActionRegion> regions = (data['regions'] as List)
.map((data_region) => ActionRegion.deserialize(data_region))
.toSet();
Expand Down
12 changes: 6 additions & 6 deletions lib/action/step_actions_provider.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:angular2/core.dart';
import 'package:ace/ace.dart' as ace;
import 'package:code_steps/action/step_action.dart';
import 'package:code_steps/editor/ace_facade.dart';
import 'package:code_steps/lesson_serializer.dart';

@Injectable()
Expand All @@ -11,16 +11,16 @@ class StepActionsProvider extends Injectable {
transformers = new Map.fromIterable(StepActionType.values,
value: (t) => _generateTagWrap(t));

transformers[StepActionType.Pass](
[new RegionInsert([])], new ace.Range(0, 0, 0, 0));
// transformers[StepActionType.Pass](
// [new RegionInsert([])], new Range(0, 0, 0, 0));

// override default tag actions for certain types
transformers.addAll({
StepActionType.Hide: _hide
});
}

static final Function _hide = (List<RegionInsert> lines, ace.Range range) {
static final Function _hide = (List<RegionInsert> lines, AceRange range) {
RegionInsert startLine = lines[range.start.row];
if (range.start.row == range.end.row) {
startLine.delete(range.start.column, range.end.column);
Expand All @@ -39,8 +39,8 @@ class StepActionsProvider extends Injectable {
String typeString = LessonSerializer.stepActionTypeHelper.stringFromEnum(t);
String openTag = '<cs-region class="action-${typeString.toLowerCase()}">';
String closeTag = '</cs-region>';
return (List<RegionInsert> lines, ace.Range range) {
if (range.isEmpty) {
return (List<RegionInsert> lines, AceRange range) {
if (range.isEmpty()) {
print('WARN: empty range $range');
return;
}
Expand Down
9 changes: 6 additions & 3 deletions lib/editor/ace_editor_component.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import 'package:angular2/core.dart';
import 'package:ace/ace.dart' as ace;

import 'ace_facade.dart';
@Component(
selector: 'ace-edit',
template: '',
styleUrls: const ['css/ace_editor_component.css'])
class AceEditorComponent implements OnInit {
static int _uniq_id_num = 0;
ace.Editor aceController;
Editor aceController;
ElementRef elementRef;
@Output('onInit')
EventEmitter init = new EventEmitter();
Expand All @@ -18,9 +17,13 @@ class AceEditorComponent implements OnInit {
ngOnInit() {
if (dom_id.length == 0) dom_id = 'ace-edit-${_uniq_id_num++}';
aceController = ace.edit(elementRef.nativeElement.id);
aceController.$blockScrolling = double.INFINITY; // disables scroll warning spam in ace 1.2.6
init.emit(this);
}

String get text => aceController.getValue();
set text(String newValue) => aceController.setValue(newValue);

String get dom_id => elementRef.nativeElement.id;
set dom_id(id) => elementRef.nativeElement.id = id;
}
Loading