News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
Exploring tables
Author Message
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #1
Exploring tables

While exploring the built-in tables in MurgaLua, I discovered that there are several parts of FLTK that are not documented...classes, methods, constants, and functions. So I whipped up this tool to let me quickly run down through various tables, starting with _G.

It needs work, since it does occasionally crash, and it doesn't really do anything other than display the contents of a selected table (tables are displayed in bold font).

Code:
#!/usr/bin/murgaLua-0.5.5

-- Change the default box
Fl:set_boxtype(fltk.FL_UP_BOX,fltk.FL_THIN_UP_BOX)
Fl:set_boxtype(fltk.FL_DOWN_BOX,fltk.FL_THIN_DOWN_BOX)

function lookittable()
  outpoot:clear()
  table.sort(current_table)
  --for k,v in pairs(current_table) do outpoot:add(tostring(k).."\t\t"..tostring(v)) end
  for k,v in pairs(current_table) do
      if type(v)=="table" then
          outpoot:add("@b"..tostring(k))
      else
          outpoot:add(tostring(k))
      end
end
end

ww=400
wh=360

w=fltk:Fl_Double_Window(ww,wh,"view murga tables")

outpoot=fltk:Fl_Hold_Browser(10,40,ww-20,wh-50)
--outpoot:column_widths((ww-20)/2) -- not supported?
--outpoot:textfont(fltk.FL_COURIER)

butt=fltk:Fl_Button(10,10,80,30,"view table")
butt:callback(
function()
  if outpoot:value() > 0 and type(current_table) == "table" then
    for k,v in pairs(current_table) do
      --if string.find(outpoot:text(outpoot:value()),"^"..tostring(k).."%s") and type(v) == "table" then
      if outpoot:text(outpoot:value()) == "@b"..tostring(k) then
    current_table=v
    title:label(tostring(k))
        lookittable()
    break
      end
    end
  end
end
)

title=fltk:Fl_Box(90,10,ww-180,30)
title:box(fltk.FL_THIN_UP_BOX)

resetbutt=fltk:Fl_Button(ww-90,10,80,30,"restart")
resetbutt:callback(
function()
title:label("_G")
current_table=_G
lookittable()
end
)

current_table=_G
lookittable()
w:show()
Fl:run()

09-07-2007 06:53 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
Exploring tables - mikshaw - 09-07-2007 06:53 AM
RE: Exploring tables - chrimo - 09-07-2007, 07:28 AM
RE: Exploring tables - mikshaw - 09-07-2007, 01:18 PM
RE: Exploring tables - mikshaw - 09-08-2007, 09:22 AM
RE: Exploring tables - mikshaw - 09-12-2007, 09:40 AM
RE: Exploring tables - mikshaw - 01-22-2008, 05:23 AM
RE: Exploring tables - mikshaw - 03-24-2008, 11:36 AM
RE: Exploring tables - mikshaw - 04-24-2008, 06:07 AM
RE: Exploring tables - petermac - 08-05-2008, 10:05 AM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: