[Top][All Lists]

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

Idea: use menu hook to implement the savedefault command

From: Bean
Subject: Idea: use menu hook to implement the savedefault command
Date: Tue, 12 Aug 2008 05:03:10 +0800


Now it's possible to implement savedefault with load_env and save_env,
but the problem is we need to add it to every menuitem, it's tedious
process, and new item don't get it automatically.

I'm thinking about using menu hook to solve this. I can think of two

1. Function interface

We can install hooks, which get called just before the menu is invoked.

2. Script interface

We can use certain variable to specific the command to use, for example:

set MENU_PRELOAD=save_env default

The first menu is easier to implement, but the second one is more flexible.

btw, we can also use this to implement the password command. Just
before the menu is executed, we call the hook. If the password is not
match, we return false and it quit. But it's a little tricky this
time, as some item may not be protected. For this, we introduce
another concept, the attributes of an menu item. For example, we can
set an lock attribute that indicate that this item should be verified
for password. The attribute list is passed to the hook function, so
they can just lookup it's value and decide what to do.

Note that the attribute concept is already used in Colin's GSOC
project, it uses to specific the icon of a boot item, we just extent
it to include other attributes.



reply via email to

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