[Bf-funboard] Command Line

Janek Kozicki bf-funboard@blender.org
Tue, 1 Jun 2004 23:12:52 +0200


Tom,

I've found only two posts on mailing list about your work. Correct me if
there are any I missed.

Tom Musgrove said:

> OK here is a short term solution for custom keybindings - it is compile 
> time, so it isn't the correct long term solution.  However, it is trivial to 
> do now, and it makes a future 'real solution' much eaiser to implement.

that sounds good. I vote for 'long term solution'.
 
> Essentially we set up a file that for each key has a really long name that 
> describes the function

to make things clear, the naming:

you call "really long name", I call "blender command"
you call "the function"    , I call "blender action"

 
> ie
> 
> EDITMODE_SELECT_MESH = RMB
> 
> if there are mulltiple ways to do the same action then the second way is 
> appended with a 2 ie
> 
> EDITMODE_ZOOM = SCROLLMOUSE
> EDITMODE_ZOOM2 = ALT+CTRL+LMB
> 
> etc.

I propose essentially the same thing. Only file format I suggested is a
little bit different.

> then, we have the text descriptions above #defined, thus when we go to 
> compile, we end up with the same code.

oh. so you are making #define for each of those commands?
 
> However, those who really want different keybindings no longer need to hunt 
> through dozens of different files.  Also, this could make it much easier to 
> create predefined sets of keybindings for the popular alternatives.
> 
> What do you think?

great for start :) lets now make a 'long term solution' ;)))


> Hi Janek,
> 
> I'm currently seperating the keybinding definitions from the event 
> evaluation and function definitions.
> 

<big snip, which I have carefully read>

> etc.
> 
> if the global handler doesn't handle it, is passed to a system_handler();
> 
> if the system_handler doesn't handle it, then it prints a notice to the 
> console that it couldn't handle the event.


I get it.
The thing that I am afraid of is ... the approach (sorry):

> switch(SPACE_TYPE) {

forces every keybinding to have SPACE_TYPE defined for all keybindings.
Which is not always true (like general keybindings).

Please tell me how much hassle[*] it would be to do it the way I suggest:

define keybindings following way:

#
mode             omod         object_mode  [**]
mode             3win         3d_window
mode             osel         object_is_selected

# [conditions] [key] [name_of_the_command]
omod,3win,osel   f            toggle_face_display 
#

1. A certain [key] combination is pressed
2. search for that [key] combination in a list of keybindings
3. if this [key] combination is found 
     then loop through all [conditions] of this [key] to check if all are true.
     If yes,
       then call the function.
4. if this [key] combination is not found in the list of keybindings then 
   call global_handler() and after that system_handler()


I wrote it in engliesh language instead of C, because I don't have names
for all those variables that this would require. And it is also easier
to read, isn't it? ;)

Now, see that the only difference lies within the order of checking. And
by this way we get rid of countless switch()es, and do it all in a nice,
easy to read loop.


> I can send a list of the files I've finished with (and the file changes 
> themselves that show what I've done), as well as the files that still remain 
> if you like.

yes, please.

You are working on separete copy of blender, or you changes are working,
and get incorporated into blender "live" ?



[*] hassle includes the trouble with modyfing the work you already have
done, as well as technical problems with implementing a new way to do
it.

[**] in fact the function object_mode() will be:
bool object_mode() {
  return SPACE_TYPE==OBJECT_something;
}

-- 
Janek Kozicki                                                         |