-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathawm-debug.lua
52 lines (43 loc) · 1.12 KB
/
awm-debug.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
local naughty = require("naughty")
local gears = require("gears")
local serpent = require("serpent")
local dbg = require("sub.debugger.debugger")
local socket = require("socket")
local debug = {}
function debug.notifyDump(tbl, method)
naughty.notify({
title = "Debug",
text = method(tbl),
timeout = 0
})
end
function debug.dumpTable(tbl)
debug.notifyDump(tbl, gears.debug.dump_return)
end
function debug.dumpTableSerpent(tbl)
debug.notifyDump(tbl, serpent.block)
end
-- dbg.pretty dump
function debug.dumpTablePretty(tbl)
debug.notifyDump(tbl, dbg.pretty)
end
debug.dbg = dbg
dbg.auto_where = 5
dbg.port = 9000
dbg.read = function (prompt)
dbg.server = dbg.server or assert(socket.bind("localhost", dbg.port))
while not dbg.client do
dbg.client = dbg.server:accept()
end
dbg.client:send(prompt)
return dbg.client:receive()
end
-- dbg.write
dbg.write = function (str)
dbg.server = dbg.server or assert(socket.bind("localhost", dbg.port))
while not dbg.client do
dbg.client = dbg.server:accept()
end
dbg.client:send(str)
end
return debug