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
RE: Exploring tables

A few changes now:
Syntax highlighting according to the object type.
You don't need to click the button anymore (it's still there because I have other plans for it).
Functions now give a little bit of info (not much, but it's all I know how to get at this time).
Resizable window

TODO:
Navigate backward rather than having to start back at _G every time.
Try to figure out how to provide more info about selected functions.
Maybe try to do some column layout (multiple browsers?)

Code:
#!/usr/bin/murgaLua

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
    if type(v)=="table" then
      outpoot:add("@b"..tostring(k))
    elseif type(v)=="function" then
      outpoot:add("@C1"..tostring(k).." (function)")
    elseif type(v)=="number" then
      outpoot:add("@C5"..tostring(k).." (number)\t"..tostring(v))
    elseif type(v)=="userdata" then
      outpoot:add("@C9"..tostring(k).." (userdata)\t\t"..tostring(v))
    elseif type(v)=="string" then
      outpoot:add("@C4"..tostring(k).." (string)\t\t"..tostring(v))
    else
      outpoot:add(tostring(k))
    end
  end
end

function which_is_it()
  local this_text=outpoot:text(outpoot:value())
  if outpoot:value() > 0 and type(current_table) == "table" then
    for k,v in pairs(current_table) do
      if this_text == "@b"..tostring(k) then
        current_table=v
        title:label(tostring(k))
        lookittable()
        break
      end
      if string.find(this_text,tostring(k).."%s%(function%)$") then
        current_table=debug.getinfo(v)
        title:label(tostring(k))
        lookittable()
        break
      end
    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:callback(which_is_it)

butt=fltk:Fl_Button(10,10,80,30,"view table")
butt:callback(which_is_it)

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
)

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

This post was last modified: 09-07-2007 01:35 PM by mikshaw.

09-07-2007 01:18 PM
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: