From 1ce0af3aa7e95b7945e0bbdba456d0328335e6ca Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Mon, 16 Mar 2015 00:25:20 +0100 Subject: Use different colors for different types of edits Remove on-hover explanations and replace the now-useless gutter with line numbers. Explanations will be reintroduced in a later commit. --- monkey/monkey.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'monkey/monkey.py') diff --git a/monkey/monkey.py b/monkey/monkey.py index 3f58ee8..8f57235 100755 --- a/monkey/monkey.py +++ b/monkey/monkey.py @@ -267,14 +267,22 @@ def fix_hints(code, path): messages = [] for step_type, idx, a, b in path: if step_type == 'add_rule': + type = 'insert' msg = 'Add another rule.' - start = program[idx].pos - end = start + start = program[idx].pos-1 + end = start+2 elif step_type == 'add_part': - msg = 'Add another goal.' + type = 'insert' + msg = 'Add another goal to this rule.' + start = program[idx].pos-1 + end = start+2 + elif step_type == 'remove_rule': + type = 'remove' + msg = 'Remove this rule.' start = program[idx].pos - end = start + end = program[idx + len(a) - 1].pos elif step_type == 'remove_part': + type = 'remove' msg = 'Remove this goal.' start = program[idx].pos end = idx + len(a) - 1 @@ -282,7 +290,8 @@ def fix_hints(code, path): end -= 1 end = program[end].pos + len(program[end].val) elif step_type == 'change_part': - msg = 'Check this goal.' + type = 'change' + msg = 'Check this part.' first = 0 while idx+first < len(program)-1 and first < len(a) and first < len(b) and a[first] == b[first]: first += 1 @@ -291,11 +300,7 @@ def fix_hints(code, path): last -= 1 start = program[idx+first].pos end = program[idx+last].pos + len(program[idx+last].val) - elif step_type == 'remove_rule': - msg = 'Remove this rule.' - start = program[idx].pos - end = program[idx + len(a) - 1].pos - messages.append(((start, end), msg)) + messages.append(({'type': type, 'start': start, 'end': end}, msg)) program[idx:idx+len(a)] = [t.clone(pos=program[idx].pos) for t in b] -- cgit v1.2.1