This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Exception.traceback( level, count, userspace ) | |
| local trace = {} | |
| level = (level or 1) + 1 | |
| if level > 2 then | |
| local i = 1 | |
| while #trace < count do | |
| local src = select( 2, pcall( error, "", level + i ) ):gsub( ": $", "" ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local __debug_line_tracker={ | |
| {16,0,"subdir.abc",2}, | |
| {1,0,"test_build.main",4} | |
| } | |
| local function __get_src_and_line( line ) | |
| for i = 1, #__debug_line_tracker do | |
| local t = __debug_line_tracker[i] | |
| if line >= t[1] and line <= t[1] + t[2] then | |
| return t[3], t[4] + line - t[1] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- create a state to use when compiling the package | |
| local substate = preprocess.create_state( file:match "(.+)/" or "" ) | |
| -- names that the package localises (used to add these to the package table) | |
| local localised_names = {} | |
| local localised = {} | |
| -- copy minify status across | |
| substate.microminify = state.microminify | |
| substate.minify.active = state.minify.active |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local function splitspaced( str ) | |
| local s, f = str:find "%S+" | |
| local segments = {} | |
| local i = 1 | |
| while s do | |
| local seg = str:sub( s, f ) | |
| local pos = seg:find "'" or seg:find '"' | |
| if pos then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local sheets | |
| local __debug_err_map={ | |
| } | |
| local __debug_err_pats={ | |
| ["lua.arithmetic"]={{"attempt to perform arithmetic __(%w+) on (%w+) and (%w+)","failed to %1 ${1} (%2) and ${2} (%3)"}} | |
| } | |
| local __debug_line_tracker={ | |
| {119,122,"main",1}, | |
| {123,141,"/sheets/src/v0.0.4/sheets",1}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local function microminify( line, state ) | |
| local segments = {} | |
| local i, n = 1, 1 | |
| local res = {} | |
| local is_word = false | |
| if state.in_string then | |
| local pos = find_non_escaped( line, state.string_closer, 1 ) | |
| if pos then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local app = sheets.Application() | |
| local container = app.screen + sheets.Container( 0, 0, app.screen.width, app.screen.height ) | |
| local right = container + sheets.Button( "51 - self.width", 1, "#self.text + 4", 3, "Right" ) | |
| :set_ID "right" | |
| :set_width_transition( sheets.Transition.smooth ) | |
| local button1 = container + sheets.Button( 5, 0, "$$right.x - self.x", 5, "Hello world!" ) | |
| :set_ID "button1" | |
| :set_x_transition( sheets.Transition.smooth ) | |
| local centred = container + sheets.Button( "(parent.width - self.width) / 4 - 0.75", 12, 20, 5, "I am quarter x" ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local app = sheets.Application() | |
| local container = app.screen + sheets.Container( 0, 0, app.screen.width, app.screen.height ) | |
| local right = container + sheets.Button( "51 - self.width", 1, "#self.text + 4", 3, "Right" ) | |
| :set_ID "right" | |
| local button1 = container + sheets.Button( 5, 0, "$$right.x - self.x", 5, "Hello world!" ) | |
| :set_ID "button1" | |
| local centred = container + sheets.Button( "(parent.width - self.width) / 4 - 0.25", 12, 20, 5, "I am quarter x" ) | |
| local initial_anchor = container + sheets.Button( 20, 6, 20, 3, "!$.anchor == self & 'Initial anchor' | 'Non-anchor'" ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local function node_query_internal( query ) | |
| if query.type == QUERY_ID then | |
| return ("n.id=='%s'"):format( query.value ) | |
| elseif query.type == QUERY_TAG then | |
| return ("n:has_tag'%s'"):format( query.value ) | |
| elseif query.type == QUERY_ALL then | |
| return "true" | |
| elseif query.type == QUERY_CLASS then | |
| -- TODO: check if type_of() accepts a string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local app = sheets.Application() | |
| local button1 = app.screen + sheets.Button( 0, 0, 20, 5, "Hello world!" ) | |
| local right = app.screen + sheets.Button( 0, 1, 7, 3, "Right" ) | |
| local old = { [button1] = {}, [right] = {} } | |
| right:set_ID "right" |