Skip to content

Commit 8168fa4

Browse files
committed
1.7 stuff
The master branch was reverted to 1.7 because it was very unstable (bugs and stuff that wasn't mentioned on the documentation page yet) - features will come back with 2.0 - fixed debug window - fixed flexbox not sending drag events to it's children - small docs updates for 1.7 - removed the examples because the are outdated
1 parent 33753f6 commit 8168fa4

75 files changed

Lines changed: 2807 additions & 2812 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Basalt/libraries/basaltDraw.lua

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
local tHex = require("tHex")
2+
local utils = require("utils")
3+
local split = utils.splitString
24
local sub,rep = string.sub,string.rep
35

46
return function(drawTerm)
@@ -40,27 +42,33 @@ return function(drawTerm)
4042
if #t == #fg and #t == #bg then
4143
if y >= 1 and y <= height then
4244
if x + #t > 0 and x <= width then
43-
local startN = x < 1 and 1 - x + 1 or 1
44-
local endN = x + #t > width and width - x + 1 or #t
45-
45+
local newCacheT, newCacheFG, newCacheBG
4646
local oldCacheT, oldCacheFG, oldCacheBG = cacheT[y], cacheFG[y], cacheBG[y]
47-
48-
local newCacheT = sub(oldCacheT, 1, x - 1) .. sub(t, startN, endN)
49-
local newCacheFG = sub(oldCacheFG, 1, x - 1) .. sub(fg, startN, endN)
50-
local newCacheBG = sub(oldCacheBG, 1, x - 1) .. sub(bg, startN, endN)
51-
47+
local startN, endN = 1, #t
48+
49+
if x < 1 then
50+
startN = 1 - x + 1
51+
endN = width - x + 1
52+
elseif x + #t > width then
53+
endN = width - x + 1
54+
end
55+
56+
newCacheT = sub(oldCacheT, 1, x - 1) .. sub(t, startN, endN)
57+
newCacheFG = sub(oldCacheFG, 1, x - 1) .. sub(fg, startN, endN)
58+
newCacheBG = sub(oldCacheBG, 1, x - 1) .. sub(bg, startN, endN)
59+
5260
if x + #t <= width then
5361
newCacheT = newCacheT .. sub(oldCacheT, x + #t, width)
5462
newCacheFG = newCacheFG .. sub(oldCacheFG, x + #t, width)
5563
newCacheBG = newCacheBG .. sub(oldCacheBG, x + #t, width)
5664
end
57-
65+
5866
cacheT[y], cacheFG[y], cacheBG[y] = newCacheT,newCacheFG,newCacheBG
5967
end
6068
end
6169
end
6270
end
63-
71+
6472
local function setText(x, y, t)
6573
if y >= 1 and y <= height then
6674
if x + #t > 0 and x <= width then
@@ -86,7 +94,7 @@ return function(drawTerm)
8694
end
8795
end
8896

89-
local function setBg(x, y, bg)
97+
local function setBG(x, y, bg)
9098
if y >= 1 and y <= height then
9199
if x + #bg > 0 and x <= width then
92100
local newCacheBG
@@ -111,7 +119,7 @@ return function(drawTerm)
111119
end
112120
end
113121

114-
local function setFg(x, y, fg)
122+
local function setFG(x, y, fg)
115123
if y >= 1 and y <= height then
116124
if x + #fg > 0 and x <= width then
117125
local newCacheFG
@@ -136,6 +144,32 @@ return function(drawTerm)
136144
end
137145
end
138146

147+
--[[
148+
local function setText(x, y, text)
149+
if (y >= 1) and (y <= height) then
150+
local emptyLine = rep(" ", #text)
151+
blit(x, y, text, emptyLine, emptyLine)
152+
end
153+
end
154+
155+
local function setFG(x, y, colorStr)
156+
if (y >= 1) and (y <= height) then
157+
local w = #colorStr
158+
local emptyLine = rep(" ", w)
159+
local text = sub(cacheT[y], x, w)
160+
blit(x, y, text, colorStr, emptyLine)
161+
end
162+
end
163+
164+
local function setBG(x, y, colorStr)
165+
if (y >= 1) and (y <= height) then
166+
local w = #colorStr
167+
local emptyLine = rep(" ", w)
168+
local text = sub(cacheT[y], x, w)
169+
blit(x, y, text, emptyLine, colorStr)
170+
end
171+
end]]
172+
139173
local drawHelper = {
140174
setSize = function(w, h)
141175
width, height = w, h
@@ -146,17 +180,17 @@ return function(drawTerm)
146180
mirrorTerm = mirror
147181
end,
148182

149-
setBg = function(x, y, colorStr)
150-
setBg(x, y, colorStr)
183+
setBG = function(x, y, colorStr)
184+
setBG(x, y, colorStr)
151185
end,
152186

153187
setText = function(x, y, text)
154188
setText(x, y, text)
155189
end,
156190

157-
setFg = function(x, y, colorStr)
158-
setFg(x, y, colorStr)
159-
end,
191+
setFG = function(x, y, colorStr)
192+
setFG(x, y, colorStr)
193+
end;
160194

161195
blit = function(x, y, t, fg, bg)
162196
blit(x, y, t, fg, bg)
@@ -165,13 +199,13 @@ return function(drawTerm)
165199
drawBackgroundBox = function(x, y, width, height, bgCol)
166200
local colorStr = rep(tHex[bgCol], width)
167201
for n = 1, height do
168-
setBg(x, y + (n - 1), colorStr)
202+
setBG(x, y + (n - 1), colorStr)
169203
end
170204
end,
171205
drawForegroundBox = function(x, y, width, height, fgCol)
172206
local colorStr = rep(tHex[fgCol], width)
173207
for n = 1, height do
174-
setFg(x, y + (n - 1), colorStr)
208+
setFG(x, y + (n - 1), colorStr)
175209
end
176210
end,
177211
drawTextBox = function(x, y, width, height, symbol)

Basalt/libraries/basaltEvent.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
local tableCount = require("utils").tableCount
2-
31
return function()
42
local events = {}
53

@@ -20,7 +18,7 @@ return function()
2018
end,
2119

2220
getEventCount = function(self, _event)
23-
return _event~=nil and events[_event]~=nil and tableCount(events[_event]) or tableCount(events)
21+
return events[_event]~=nil and #events[_event] or 0
2422
end,
2523

2624
getEvents = function(self)

0 commit comments

Comments
 (0)