diff options
-rw-r--r-- | life.tlv | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/life.tlv b/life.tlv index eb9662f..27aad4f 100644 --- a/life.tlv +++ b/life.tlv @@ -77,6 +77,21 @@ > window:mvaddstr(oldy, oldx, '') >end - __teliva_timestamp: original + check: + >function check(x, msg) + > if x then + > Window:addch('.') + > else + > print('F - '..msg) + > print(' '..str(x)..' is false/nil') + > teliva_num_test_failures = teliva_num_test_failures + 1 + > -- overlay first test failure on editors + > if teliva_first_failure == nil then + > teliva_first_failure = msg + > end + > end + >end +- __teliva_timestamp: original check_eq: >function check_eq(x, expected, msg) > if eq(x, expected) then @@ -177,8 +192,7 @@ > end > return result >end -- __teliva_timestamp: - >Mon Feb 21 17:45:04 2022 +- __teliva_timestamp: original sort_letters: >function sort_letters(s) > tmp = {} @@ -240,13 +254,30 @@ > h.__index = function(table, key) > return rawget(h, key) > end + > h.attrset = function(self, x) + > self.scr.attrs = x + > end + > h.attron = function(self, x) + > -- currently same as attrset since Lua 5.1 doesn't have bitwise operators + > -- doesn't support multiple attrs at once + >-- local old = self.scr.attrs + >-- self.scr.attrs = old|x + > self.scr.attrs = x + > end + > h.attroff = function(self, x) + > -- currently borked since Lua 5.1 doesn't have bitwise operators + > -- doesn't support multiple attrs at once + >-- local old = self.scr.attrs + >-- self.scr.attrs = old & (~x) + > self.scr.attrs = curses.A_NORMAL + > end > h.getch = function(self) > return table.remove(h.kbd, 1) > end > h.addch = function(self, c) > local scr = self.scr > if scr.cursy <= scr.h then - > scr[scr.cursy][scr.cursx] = c + > scr[scr.cursy][scr.cursx] = {data=c, attrs=scr.attrs} > scr.cursx = scr.cursx+1 > if scr.cursx > scr.w then > scr.cursy = scr.cursy+1 @@ -262,13 +293,16 @@ > h.mvaddch = function(self, y, x, c) > self.scr.cursy = y > self.scr.cursx = x - > self.addch(c) + > self:addch(c) > end > h.mvaddstr = function(self, y, x, s) > self.scr.cursy = y > self.scr.cursx = x > self:addstr(s) > end + > h.clear = function(self) + > clear_scr(self.scr) + > end > return h >end - __teliva_timestamp: original @@ -285,21 +319,26 @@ >function scr(props) > props.cursx = 1 > props.cursy = 1 + > clear_scr(props) + > return props + >end +- __teliva_timestamp: original + clear_scr: + >function clear_scr(props) > for y=1,props.h do > props[y] = {} > for x=1,props.w do - > props[y][x] = ' ' + > props[y][x] = {data=' ', attrs=curses.A_NORMAL} > end > end > return props >end -- __teliva_timestamp: - >Thu Mar 3 22:04:15 2022 +- __teliva_timestamp: original check_screen: >function check_screen(window, contents, message) > local x, y = 1, 1 > for i=1,contents:len() do - > check_eq(contents[i], window.scr[y][x], message..'/'..y..','..x) + > check_eq(window.scr[y][x].data, contents[i], message..'/'..y..','..x) > x = x+1 > if x > window.scr.w then > y = y+1 |