User Tools

Site Tools


geda:pcb_register_actions_explained

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

geda:pcb_register_actions_explained [2018/01/28 10:23] (current)
cparker created
Line 1: Line 1:
 +**REGISTER_ACTIONS - REGISTER_FLAGS - REGISTER_ATTRIBUTES**
 +
 +Every action file must register its actions in the HID.
 +The action file will have an <code c>#​include "​hid.h"</​code>​ which define the REGISTER_* macros.
 +Then somewhere in the file you add:
 +
 +<​code>​REGISTER_ACTIONS(exampledo_action_list)</​code>​
 +This will be expanded by the preprocessor into:
 +<code c>
 +void register_exampledo_action_list()
 +{ hid_register_actions(exampledo_action_list,​1);​ }
 +</​code>​
 +
 +During the build process the files //​**core_lists.h**//​ and //​**gtk_lists.h**//​ are created. These files contain nothing more than a collection of REGISTER_* instructions it found in its source files.\\ So //​**core_lists.h**//​ and //​**gtk_lists.h**//​ will contain:
 +<​code>​REGISTER_ACTION(exampledo_action_list)</​code>​
 +
 +In the file //​**main.c**//​ around the __main__ functions we find the instruction:​
 +<code c>#​include "​dolists.h"</​code>​
 +And soon after that we find
 +<code c>#​include "​core_lists.h"</​code>​
 +
 +Because //​**dolists.h**//​ redefines the REGISTER_* macros, the macros in //​**core_lists.h**//​
 +<​code>​REGISTER_ACTIONS(exampledo_action_list)</​code>​
 +will be expanded by the preprocessor into:
 +<code c>
 +external void register_exampledo_action_list();​
 +register_exampledo_action_list();​
 +</​code>​
 +And therefore it will call all functions to register the actions at the beginning of the main function.
 +
 +==== Options ====
 +
 +|REGISTER_ACTIONS|These actions can be called though the user command window (start with ":"​ in the PCB program.|
 +|REGISTER_FLAGS|These flags initiate a functions when set or unset.\\ E.g. in file //​**flags.c**//​ we find <code c>​HID_Flag flags_flag_list[] = {
 +  {"​style", ​               FlagCurrentStyle,​ NULL},
 +  {"​grid", ​                ​FlagGrid, ​        ​NULL},</​code>​The "​grid"​ flags is associated with the menu flag: **View->​enable visible grid** and makes the connection to the ''​FlagGrid()''​ function.\\ If you select **View->​enable visible grid** the function ''​FlagGrid''​ will be called.|
 +|REGISTER_ATTRIBUTES|In //​**main.c**//​ there is a call to this macro: ''​REGISTER_ATTRIBUTES (main_attribute_list)''​\\ The main_attribute_list defines the command-line options.\\ Most of the HID also use this macro, to add their command line options as well.|
  
geda/pcb_register_actions_explained.txt ยท Last modified: 2018/01/28 10:23 by cparker