summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2015-03-16 00:25:20 +0100
committerAleš Smodiš <aless@guru.si>2015-08-11 14:26:03 +0200
commit1ce0af3aa7e95b7945e0bbdba456d0328335e6ca (patch)
treedf993a9566b37c9f003dae5ce4e635358ed250a3
parent5c2f8dc526ff12abbf5e33965680fbf91645b274 (diff)
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.
-rwxr-xr-xmonkey/monkey.py25
1 files changed, 15 insertions, 10 deletions
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]