Skip to content

Commit

Permalink
Don't apply an Editor operation unless it can be applied to all
Browse files Browse the repository at this point in the history
active cuts.
  • Loading branch information
lowrie committed Dec 31, 2015
1 parent ef634d7 commit 6351d75
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
30 changes: 18 additions & 12 deletions spacing.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,15 @@ def cut_move_left(self):
c.xmax = min(c.xmin + w, self.boards[0].width)
self.cuts[f] = c
op.append(f)
if len(noop) > 0:
self.cuts = cuts_save
return 'No cuts moved: unable to move indices ' + `noop`
if len(op) > 0 or delete_cut:
self.undo_cuts.append(cuts_save)
if len(op) > 0:
msg = 'Moved cut indices ' + `op` + ' to left 1 increment'
else:
msg = 'Moved no cuts'
if len(noop) > 0:
msg += '; unable to move indices ' + `noop`
if delete_cut:
msg += '; deleted cut 0'
self.cut_delete(0)
Expand Down Expand Up @@ -402,14 +403,15 @@ def cut_move_right(self):
c.xmin = max(c.xmax - w, 0)
self.cuts[f] = c
op.append(f)
if len(noop) > 0:
self.cuts = cuts_save
return 'No cuts moved: unable to move indices ' + `noop`
if len(op) > 0 or delete_cut:
self.undo_cuts.append(cuts_save)
if len(op) > 0:
msg = 'Moved cut indices ' + `op` + ' to right 1 increment'
else:
msg = 'Moved no cuts'
if len(noop) > 0:
msg += '; unable to move indices ' + `noop`
if delete_cut:
f = len(self.cuts) - 1
msg += '; deleted cut %d' % f
Expand All @@ -433,13 +435,14 @@ def cut_widen_left(self):
op.append(f)
else:
noop.append(f)
if len(noop) > 0:
self.cuts = cuts_save
return 'No cuts widened: unable to widen indices ' + `noop`
if len(op) > 0:
self.undo_cuts.append(cuts_save)
msg = 'Widened cut indices ' + `op` + ' on left 1 increment'
else:
msg = 'Widened no cuts'
if len(noop) > 0:
msg += '; unable to widen indices ' + `noop`
return msg

def cut_widen_right(self):
Expand All @@ -458,13 +461,14 @@ def cut_widen_right(self):
op.append(f)
else:
noop.append(f)
if len(noop) > 0:
self.cuts = cuts_save
return 'No cuts widened: unable to widen indices ' + `noop`
if len(op) > 0:
self.undo_cuts.append(cuts_save)
msg = 'Widened cut indices ' + `op` + ' on right 1 increment'
else:
msg = 'Widened no cuts'
if len(noop) > 0:
msg += '; unable to widen indices ' + `noop`
return msg

def cut_trim_left(self):
Expand All @@ -485,13 +489,14 @@ def cut_trim_left(self):
c.xmin += 1
self.cuts[f] = c
op.append(f)
if len(noop) > 0:
self.cuts = cuts_save
return 'No cuts trimmed: unable to trim indices ' + `noop`
if len(op) > 0:
self.undo_cuts.append(cuts_save)
msg = 'Trimmed cut indices ' + `op` + ' on left 1 increment'
else:
msg = 'Trimmed no cuts'
if len(noop) > 0:
msg += '; unable to trim indices ' + `noop`
return msg

def cut_trim_right(self):
Expand All @@ -512,13 +517,14 @@ def cut_trim_right(self):
c.xmax -= 1
self.cuts[f] = c
op.append(f)
if len(noop) > 0:
self.cuts = cuts_save
return 'No cuts trimmed: unable to trim indices ' + `noop`
if len(op) > 0:
self.undo_cuts.append(cuts_save)
msg = 'Trimmed cut indices ' + `op` + ' on right 1 increment'
else:
msg = 'Trimmed no cuts'
if len(noop) > 0:
msg += '; unable to trim indices ' + `noop`
return msg

def cut_increment_cursor(self, inc):
Expand Down
2 changes: 1 addition & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import math, fractions, os, glob

VERSION = '0.7.0'
VERSION = '0.7.1'

def my_round(f):
'''
Expand Down

0 comments on commit 6351d75

Please sign in to comment.