vendor: bump lurker

master
q3k 2022-07-05 19:25:07 +02:00
parent 71a96638e5
commit e9ad7e59e3
1 changed files with 36 additions and 16 deletions

52
vendor/lurker.lua vendored
View File

@ -1,22 +1,31 @@
--
-- lurker
-- lurker
--
-- Copyright (c) 2015 rxi
-- Copyright (c) 2018 rxi
--
-- This library is free software; you can redistribute it and/or modify it
-- under the terms of the MIT license. See LICENSE for details.
--
-- Assumes lume is in the same directory as this file
local lume = require((...):gsub("[^/.\\]+$", "lume"))
-- Assumes lume is in the same directory as this file if it does not exist
-- as a global
local lume = rawget(_G, "lume") or require((...):gsub("[^/.\\]+$", "lume"))
local lurker = { _version = "1.0.1" }
local dir = love.filesystem.enumerate or love.filesystem.getDirectoryItems
local isdir = love.filesystem.isDirectory
local time = love.timer.getTime or os.time
local lastmodified = love.filesystem.getLastModified
local function isdir(path)
local info = love.filesystem.getInfo(path)
return info.type == "directory"
end
local function lastmodified(path)
local info = love.filesystem.getInfo(path, "file")
return info.modtime
end
local lovecallbacknames = {
"update",
@ -99,7 +108,7 @@ end
function lurker.onerror(e, nostacktrace)
lurker.print("An error occurred; switching to error state")
lurker.state = "error"
-- Release mouse
local setgrab = love.mouse.setGrab or love.mouse.setGrabbed
setgrab(false)
@ -121,34 +130,45 @@ function lurker.onerror(e, nostacktrace)
local stacktrace = nostacktrace and "" or
lume.trim((debug.traceback("", 2):gsub("\t", "")))
local msg = lume.format("{1}\n\n{2}", {e, stacktrace})
local colors = { 0xFF1E1E2C, 0xFFF0A3A3, 0xFF92B5B0, 0xFF66666A, 0xFFCDCDCD }
local colors = {
{ lume.color("#1e1e2c", 256) },
{ lume.color("#f0a3a3", 256) },
{ lume.color("#92b5b0", 256) },
{ lume.color("#66666a", 256) },
{ lume.color("#cdcdcd", 256) },
}
love.graphics.reset()
love.graphics.setFont(love.graphics.newFont(12))
love.draw = function()
local pad = 25
local width = love.graphics.getWidth()
local function drawhr(pos, color1, color2)
local animpos = lume.smooth(pad, width - pad - 8, lume.pingpong(time()))
if color1 then love.graphics.setColor(lume.rgba(color1)) end
if color1 then love.graphics.setColor(color1) end
love.graphics.rectangle("fill", pad, pos, width - pad*2, 1)
if color2 then love.graphics.setColor(lume.rgba(color2)) end
if color2 then love.graphics.setColor(color2) end
love.graphics.rectangle("fill", animpos, pos, 8, 1)
end
local function drawtext(str, x, y, color, limit)
love.graphics.setColor(lume.rgba(color))
love.graphics.setColor(color)
love.graphics[limit and "printf" or "print"](str, x, y, limit)
end
love.graphics.setBackgroundColor(lume.rgba(colors[1]))
love.graphics.setBackgroundColor(colors[1])
love.graphics.clear()
drawtext("An error has occurred", pad, pad, colors[2])
drawtext("lurker", width - love.graphics.getFont():getWidth("lurker") -
drawtext("lurker", width - love.graphics.getFont():getWidth("lurker") -
pad, pad, colors[4])
drawhr(pad + 32, colors[4], colors[5])
drawtext("If you fix the problem and update the file the program will " ..
"resume", pad, pad + 46, colors[3])
drawhr(pad + 72, colors[4], colors[5])
drawtext(msg, pad, pad + 90, colors[5], width - pad * 2)
love.graphics.reset()
end
end
@ -170,7 +190,7 @@ function lurker.exiterrorstate()
end
function lurker.update()
function lurker.update()
if lurker.state == "init" then
lurker.exitinitstate()
end
@ -207,7 +227,7 @@ end
function lurker.hotswapfile(f)
lurker.print("Hotswapping '{1}'...", {f})
if lurker.state == "error" then
if lurker.state == "error" then
lurker.exiterrorstate()
end
if lurker.preswap(f) then
@ -219,7 +239,7 @@ function lurker.hotswapfile(f)
local t, ok, err = lume.time(lume.hotswap, modname)
if ok then
lurker.print("Swapped '{1}' in {2} secs", {f, t})
else
else
lurker.print("Failed to swap '{1}' : {2}", {f, err})
if not lurker.quiet and lurker.protected then
lurker.lasterrorfile = f