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 
Pages (11): « First < Previous 1 2 3 [4] 5 6 7 8 Next > Last »
[WIP] MurgaLua Reference Tool
Author Message
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #31
RE: [WIP] MurgaLua Reference Tool - a little help?

I was pissed at the thing yesterday when I posted. Since then I have apologized to the script and we are civil to each other. Whether or not this will continue when I dig into it again remains to be seen. I've tweaked and poked and tested all sorts of things thinking some part of it is just being very particular about something without logical reason. I've checked for typos several times, looked for misplaced or accidentally uncommented commands, tried redraw() on every potential change, checked the indiviual files for problems (some were blanked for some reason, which explained one of my other issues), even tried rearranging the order of commands to see if one command was overriding another. The bottom line is that I made a change at some point which broke what was previously working, and there doesn't seem to be any reason for the break.

I may need to revert to a previous version and port only the changes that I know work, but it would be super to be able to learn what went wrong so I don't end up repeating it.

Another option, of course, would be to simply remove the notes check and provide a notes file for every widget, so activate/deactivate would no longer be an issue. If I did that, though, I wouldn't be learning.

08-17-2007 12:21 AM
Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #32
RE: [WIP] MurgaLua Reference Tool - a little help?

I do believe I've finally stumbled upon the cause of the trouble, although I don't have a solution.

The problem was not caused by a change to the main script, as I had originally thought, but by a widget I'd added. It just so happens that this particular widget was disabled in the most recent test release (the "broken" release), so you might never see it.
It is related to a multiple-menu problem i was having (and gave up on) not long ago, but I never saw the connection because I was using two different types of menus this time.

So....the trouble comes from, as far as I can tell, one of three possible sources:
1) A bug in FLTK
2) A bug in MurgaLua
3) Poorly-made menus (my fault)

The symtom occurs when you create two menus (of any type, apparently) and then use my_second_menu:add("something") to add a menu item to the second menu. This apparently breaks the first menu, preventing you from controlling its contents. It sounds like a bug to me, considering you can use the same logic to add to other widgets (a browser for example), but maybe i'm doing something wrong.

Now that I know where the problem lies I don't have to bother shooting into the dark, so maybe I can figure out the solution....maybe it just needs fltk:Fl_End() or something simple like that.
I might just have to study the "proper" way of creating menu items (Fl_Menu_Item), although it seems like an unnecessarily complicated process.

There is another smaller issue I've bumped into, though, that coincidentally is also causing the notes item to not display when it should. If one of the widget filenames contains a hyphen, the string.find(textfile) test fails to work for that file. This wasn't a problem earlier because I was using io.open(textfile) to test if the notes file existed, and the hyphen worked then. I switched to building a string containing all *.lua.txt filenames because I thought it would save having to try opening two files every time a widget is loaded. I'm sure it will be a simple fix, but I just thought it was odd.

EDIT: the smaller issue was fixed by using a "plain" (no expressions) string.find:
string.find(string,pattern,1,1)
the second "1" (or anything true) enables a plain find, and the first "1" (starting point) is required if the second is used

This post was last modified: 08-17-2007 08:07 AM by mikshaw.

08-17-2007 02:56 AM
Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #33
RE: [WIP] MurgaLua Reference Tool - a little help?

Update:
Replacing my_menu:add("menu item") with an Fl_Menu_Item array seems like it *should* work. It no longer causes trouble for the main menu, but I can't figure out how to create the menu item array.

According to the FLTK docs (Fl_Menu_Item), it looks like a fairly simple table, but when I try to use my_menu:menu(my_array) it doesn't seem to do anything. The FLTK docs calls the array a "structure", however, which makes me wonder. I don't know what a structure is, or whether it can be created in Lua.

I've tried this:

Code:
menuitems={
        "FL_ALIGN_CENTER",
        "FL_ALIGN_TOP",
        "FL_ALIGN_BOTTOM",
        "FL_ALIGN_LEFT",
        "FL_ALIGN_TOP_LEFT",
        "FL_ALIGN_BOTTOM_LEFT",
        "FL_ALIGN_RIGHT",
        "FL_ALIGN_TOP_RIGHT",
        "FL_ALIGN_BOTTOM_RIGHT",
        "FL_ALIGN_INSIDE",
        "FL_ALIGN_TEXT_OVER_IMAGE",
        "FL_ALIGN_CLIP",
        "FL_ALIGN_WRAP",
}

and this:

Code:
menuitems={
        {"FL_ALIGN_CENTER"},
        {"FL_ALIGN_TOP"},
        {"FL_ALIGN_BOTTOM"},
        {"FL_ALIGN_LEFT"},
        {"FL_ALIGN_TOP_LEFT"},
        {"FL_ALIGN_BOTTOM_LEFT"},
        {"FL_ALIGN_RIGHT"},
        {"FL_ALIGN_TOP_RIGHT"},
        {"FL_ALIGN_BOTTOM_RIGHT"},
        {"FL_ALIGN_INSIDE"},
        {"FL_ALIGN_TEXT_OVER_IMAGE"},
        {"FL_ALIGN_CLIP"},
        {"FL_ALIGN_WRAP"},
        {0}
}

and this:

Code:
menuitems={
        {"FL_ALIGN_CENTER", 0, 0, 0, 0},
        {"FL_ALIGN_TOP", 0, 0, 0, 0},
        {"FL_ALIGN_BOTTOM", 0, 0, 0, 0},
        {"FL_ALIGN_LEFT", 0, 0, 0, 0},
        {"FL_ALIGN_TOP_LEFT", 0, 0, 0, 0},
        {"FL_ALIGN_BOTTOM_LEFT", 0, 0, 0, 0},
        {"FL_ALIGN_RIGHT", 0, 0, 0, 0},
        {"FL_ALIGN_TOP_RIGHT", 0, 0, 0, 0},
        {"FL_ALIGN_BOTTOM_RIGHT", 0, 0, 0, 0},
        {"FL_ALIGN_INSIDE", 0, 0, 0, 0},
        {"FL_ALIGN_TEXT_OVER_IMAGE", 0, 0, 0, 0},
        {"FL_ALIGN_CLIP", 0, 0, 0, 0},
        {"FL_ALIGN_WRAP", 0, 0, 0, 0},
        {0}
}

and none work. I have no idea what else can be tried.

Update:
I found a semi-adequate solution that at least allows me to modify the appearance of existing menu items in a multi-menu script:
http://www.murga-projects.com/forum/show...hp?tid=154

This post was last modified: 08-18-2007 01:48 AM by mikshaw.

08-17-2007 05:49 AM
Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #34
RE: [WIP] MurgaLua Reference Tool - a little help?

The last package was deleted, as it didn't work. This is alpha 1, which should still be considered a test release. I have many more improvements and widgets to add in the future, but not sure when I'll get to it in the next several days.[attachment=15]

Note: At one point yesterday I experienced a segfault durning a widget load. I was not able to reproduce it, but I have a suspicion that it relates to the recently-added "menu removal" code which accompanied the "menu addition" code I just put in to fix my last problem.

This post was last modified: 08-19-2007 02:06 AM by mikshaw.

08-19-2007 01:43 AM
Find all posts by this user Quote this message in a reply
chrimo
Member
***


Posts: 94
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #35
RE: [WIP] MurgaLua Reference Tool - a little help?

Hi mikshaw,

it works at OSX 10.4.10 (PPC) when changing

Code:
demo_appdir=string.gsub(arg[0],"(.*)"..demo_sep..".*","%1") -- data directory

to

Code:
demo_appdir=".";



Cool demos, thanks  for all your work...
This will help me, while  exploring murgaLua with "try and error" very much!
Bye
Christian

This post was last modified: 08-19-2007 09:02 AM by chrimo.

08-19-2007 08:59 AM
Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #36
RE: [WIP] MurgaLua Reference Tool - a little help?

I got another segfault today, and decided it would be best if I stuck with only one menu for now. So I deleted the dropdown menu from the align sample and just left it with the numeric slider (the constants are now listed in the notes file for that sample).

Still adding more stuff. I got into reading about system fonts and decided to get something about that included. Finally figured out how to get a reliable font string for truetype fonts, so that was cool.

Your fix for the demo_appdir variable is what I originally had done. I changed it because I wanted to be able to run it from any directory, regardless of where the program is located. Your fix requires that you cd to the application directory before running it.
I thought OSX was based on BSD, which would mean that it has the same directory separator as Linux. What do you get when you print(arg[0]) or print(demo_appdir)? does it include a full path to the script?

This post was last modified: 08-19-2007 09:43 AM by mikshaw.

08-19-2007 09:38 AM
Find all posts by this user Quote this message in a reply
chrimo
Member
***


Posts: 94
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #37
RE: [WIP] MurgaLua Reference Tool - a little help?

mikshaw Wrote:
I thought OSX was based on BSD, which would mean that it has the same directory separator as Linux. What do you get when you print(arg[0]) or print(demo_appdir)? does it include a full path to the script?


Hi mirkshaw,

the answer is quite simple Big Grin
you prefer, executing widget.lua directly and use #!/usr/bin/murgaLua...

This is very easy, but not default at any system...
My binpath is /usr/local/bin/murgaLua and your default didn't work.

But when executing murgaLua widget.lua, you script fails and returns NIL.
murgaLua: widgets.lua:215: cannot open widgets.lua/script: Not a directory
stack traceback:
[C]: in function 'dir'
widgets.lua:215: in main chunk
[C]:

You have to check, from where your script is called and get different range of parameters... When executing "murgaLua widget.lua" you have an offeset of +1

Another issue, why not using #! is, when downloading and extracting to any directory, you have no execute rights for widget.lua.
This can be handled by an installer script only Big Grin

Bye
Christian

This post was last modified: 08-20-2007 02:57 AM by chrimo.

08-20-2007 02:54 AM
Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #38
RE: [WIP] MurgaLua Reference Tool - a little help?

Quote:
When executing "murgaLua widget.lua" you have an offeset of +1

I had no idea. I thought arg[0] *always* returned the path to the script, but I guess if the script is called as an argument to the mugaLua command it would be arg[1]. Thanks for that info. I'll have to look into it further, because I really would like to keep it so it could be run from any directory without needing to manually edit the demo_appdir variable.

Quote:
why not using #! is, when downloading and extracting to any directory, you have no execute rights for widget.lua.
This can be handled by an installer script only

This shouldn't be the case if its extracted with permissions intact. If your permissions are changed when extracting a file onto a POSIX system (linux/unix/osx), you can quickly fix it by chmodding the file +x for owner (you). All the other files included with the package do not need more than read permission.
I have a "keep it simple" mentality when it comes to distributing files. In other words, I see no reason for installer scripts for anything I make. They are simple tar.gz archives. On linux, the customs of using #!/path/to/interpreter and of making sure executable files are indeed set to be executable are widely practiced, and I have no desire to change that, since it works well.

The only thing I plan to change in this area is to hopefully make it so running the script itself and running it as an argument to the murgaLua command will result in the same behavior.

08-20-2007 10:31 AM
Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #39
RE: [WIP] MurgaLua Reference Tool - a little help?

Ok, I was correct in assuming that arg[0] always returns the full path to the script.
The problem comes from the way I was determining the directory path. If the script is run in the current directory as an argument to murgaLua, there is no directory separator (variable name demo_sep) in the string, and so it returns the name of the script instead.

Here's a quick fix to that, although it could probably be done better:

Code:
if string.find(arg[0],demo_sep) then
  demo_appdir=string.gsub(arg[0],"(.*)"..demo_sep..".*","%1") -- data directory
  demo_title=string.gsub(arg[0],".*"..demo_sep.."(.*)","%1")
else
  demo_appdir="."
  demo_title=arg[0]
end

It hasn't been tested on Windows yet to see if demo_sep needs to be preceded by % or yet another backslash in string.find

08-21-2007 01:45 AM
Find all posts by this user Quote this message in a reply
JohnMurga
Administrator
*******


Posts: 381
Group: Administrators
Joined: Apr 2007
Status: Offline
Reputation: 2
Post: #40
RE: [WIP] MurgaLua Reference Tool - a little help?

mikshaw Wrote:
It hasn't been tested on Windows yet to see if demo_sep needs to be preceded by % or yet another backslash in string.find


It works as long as I start it from the current directory :

./widgets.lua
or
../bin/Windows/murgaLua.exe widgets.lua

(And it is pretty awesome (!!!))

If I do :

../bin/Windows/murgaLua.exe widgets_demo-alpha1/widgets.lua
or
./widgets_demo-alpha1/widgets.lua

It doesn't work.

Cheers
JohnM

08-21-2007 04:53 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Pages (11): « First < Previous 1 2 3 [4] 5 6 7 8 Next > Last »
Post Reply  Post Thread 

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

Forum Jump: