grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] LUA script engine for grub2


From: Bean
Subject: Re: [PATCH] LUA script engine for grub2
Date: Thu, 9 Apr 2009 01:02:17 +0800

On Wed, Apr 8, 2009 at 10:40 PM, Colin D Bennett <address@hidden> wrote:
> Bean wrote:
>> 2009/4/8 Vesa Jääskeläinen <address@hidden>:
>> > Bean wrote:
>> >> Hi,
>> >>
>> >> This patch integrate the LUA script engine to grub2
>
> Cool!
>
>> I add a grub library to lua, now it only contain grub.run, but it
>> would be easy to add more function. I think it would be useful to add
>> function to interface with the video subsystem directly, so that lua
>> can be used to control the dynamic drawing of ui components.
>
> I actually did some preliminary work to make this possible.  I made a demo
> where text is painted by a Lua script and it animates “flying by” on the
> screen.   (http://grub.gibibit.com/files/gfxmenu-lua-1.iso.gz for a demo ISO.)
>
> Besides making the GRUB video API accessible (partially, so far) to Lua, I
> also made Lua able to implement GUI components in the graphical menu
> interface.  This is limited at this point and only paint() and destroy()
> methods can be implemented in Lua.  However, I think being able to implement
> new GUI components in Lua would be really great.
>
> If my code would be any help to you, I can send it to you.

Hi,

Oh, that looks great, just hope the new graphic interface can be merged soon.

For gui components, here is some of my thoughts. Perhaps we can add
api to register ui components, something like this:

grub_ui_register (&grub_menu_ui);

The structure may look like this:

struct grub_ui
{
  next
  name
  create
  destroy
  invoke
}

Then, we use an xml document to specify the screen layout and actions:

<grub ontimer="script1.draw_image()">
    <script id=script1 lang=lua>
       x = 100, y = 100
       function draw_image()
         x = x + 10
         grub.document.image1.move (x, y)
       end
    </script>
    <header id=header1 x= y= width= height= class= text=>
    </header>
    <menu id=menu1 x= y= width= height= class=>
    </menu>
    <image id=image1 src= x= y=>
    </image>
<grub>

In create function, we pass the attributes so that ui knows how to draw itself.
The ui can also implement extra named method, for example, image can
have move method. To call them, we can use the invoke function, for
example:

invoke ("move", argc, argv);

A similar interface can be implemented for lua ui components.

-- 
Bean




reply via email to

[Prev in Thread] Current Thread [Next in Thread]