function Util.EmulateTabstops(f,F)local R=""for q=1,#f,1 do local k=f:sub(q,q)R=R..(k=="\t"and string.rep(" ",F-#R%F)or k)end return R end function Util.Mutex()local f={}local F=false return function()if F then table.insert(f,coroutine.running())coroutine.yield()else F=true end return function()if#f>0 then coroutine.resume(table.remove(f,1))else F=false end end end end return Util
--- Emulates tabstops with spaces
function Util.EmulateTabstops(text, tabWidth)
	local result = ""
	for i = 1, #text do
		local char = text:sub(i, i)

		result = result .. (char == "\t" and string.rep(" ", tabWidth - #result % tabWidth) or char)
	end
	return result
end

function Util.Mutex()
	local queue = {}
	local locked = false

	return function()
		if locked then
			table.insert(queue, coroutine.running())
			coroutine.yield()
		else
			locked = true
		end

		return function()
			if #queue > 0 then
				coroutine.resume(table.remove(queue, 1))
			else
				locked = false
			end
		end
	end
end

return Util
