From a14c946d25f743f55e7d1135319fb042bd18fb15 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sun, 17 Oct 2021 21:45:28 +0200 Subject: Refactoring --- src/field.nim | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/field.nim b/src/field.nim index c4b73a2..595a05a 100644 --- a/src/field.nim +++ b/src/field.nim @@ -9,23 +9,25 @@ type lines: seq[Line] func Blank*(f: var Field, x, y: int) = - if y < f.y or y >= f.y+f.lines.len: # outside the field + let ly = f.lines.len + if y < f.y or y >= f.y+ly: # outside the field return var l = addr f.lines[y-f.y] - if x < l.x or x >= l.x+l.columns.len: # outside the field + let ll = l.columns.len + if x < l.x or x >= l.x+ll: # outside the field return - if x > l.x and x < l.x+l.columns.len-1: # just set the value + if x > l.x and x < l.x+ll-1: # just set the value l.columns[x-l.x] = int(' ') return - if l.columns.len == 1: # this was the last character on the line + if ll == 1: # this was the last character on the line if y == f.y: # we need to trim the leading lines var i = 1 while f.lines[i].columns.len == 0: inc i f.y += i - f.lines = f.lines[i..