ha:rnd-menu-v1 {
	li:mouse {
		li:left {
			li:press            = { Tool(Press) }
			li:press-shift      = { Tool(Press) }
			li:press-ctrl       = { Tool(Press) }
			li:release          = { Tool(Release) }
			li:release-shift    = { Tool(Release) }
			li:release-ctrl     = { Tool(Release) }
		}
		li:middle {
			li:press              = { Pan(1) }
			li:release            = { Pan(0) }
		}
		li:right {
			li:press         = { }
			li:release       = { Tool(Escape); Popup(popup-obj, obj-type) }
			li:shift-release = { Popup(popup-obj-misc) }
			li:press-ctrl    = { Display(CycleCrosshair) }
		}
		li:scroll-up {
			li:press        = { Zoom(0.8) }
			li:press-shift  = { Scroll(up) }
			li:press-ctrl   = { Scroll(left) }
		}
		li:scroll-down {
			li:press       = { Zoom(1.25) }
			li:press-shift = { Scroll(down) }
			li:press-ctrl  = { Scroll(right) }
		}
	}

	# List of tool names for the toolbar.
	# Do not specify keys here, they are specified in the menu; the GUI will
	# not pick up keys from this subtree. There's also no action here: the
	# plugin handling this subtree will always pick the tool.
	li:toolbar_static {
		ha:circle    {tip={draw a circle (atomic, drawing primitive)}}
		ha:wirenet   {tip={draw a line segment for a network (wire-net)}}
		ha:line      {tip={draw a line (atomic, drawing primitive)}}
		ha:text      {tip={draw text on the sheet}}
		ha:rect      {tip={draw a rectangle (4 lines)}}
		ha:buffer    {tip={paste the current buffer on the board}}
		ha:remove    {tip={remove object at location clicked}}
		ha:rotate    {tip={rotate object by 90 degree at location clicked}}
		ha:xmirror   {tip={horizontal mirror (changes x coords)}}
		ha:ymirror   {tip={vertical mirror (changes y coords)}}
		ha:arrow     {tip={switch to arrow mode}}
		ha:lock      {tip={lock or unlock object clicked}}

		ha:move      {tip={drag&drop move objects}}
		ha:copy      {tip={drag&drop copy objects}}
		ha:polyedit  {tip={edit polygon (move corner)}}
	}

	li:main_menu {
		### File Menu
		ha:File {
			li:submenu {
				ha:Project... {
					li:submenu {
						ha:New root sheet        = { li:a={{<key>f;<key>n}; {Ctrl<Key>n};}; action=New(@, root); tip=Creates new root sheet in current project (adding it to the project file)}
						ha:New aux sheet         = { a={<key>f;Shift<key>n};                action=New(@, aux);  tip=Creates new auxiliary sheet in current project (adding it to the project file)}
						ha:New unlisted sheet    = {                                        action=New(@, unlisted);  tip=Creates new unlisted sheet in current project's directory (not adding it to the project file)}
						-
						ha:Load missing sheets   = {                                        action=ProjectLoadPartial(@);  tip=Loads missing sheets in a partially loaded project }
						-
						ha:New project           = {                                        action=ProjectNew();  tip=Creates a new project }
						ha:Project properties    = {                                        action=ProjectDialog(@); tip=Edit properties of current project }
						ha:Project stances       = {                                        action=StanceDialog(); tip=Edit stances (build options) of current project }
						-
						ha:Circuit simulation    = {                                        action=SimDialog(); tip=Edit simulation setups and run simulations }
					}
				}
				ha:Revert sheet         = { a={<key>f;<key>r};                     action=Revert(sheet); tip=Revert to the sheet stored on disk }
				ha:Unload sheet         = { a={<key>f;<key>u}; action=Unload(sheet) }
				-
				ha:Load...              = { a={<key>f;<key>o}; action=Load() }
				-
				ha:Save sheet...        = { li:a={{<key>f;<key>s}; {Ctrl<key>s};}; action=Save() }
				ha:Save sheet as...     = { a={<key>f;<key>a}; action=SaveAs() }
				ha:Save all in prj...   = { action=SaveAll(currprj) }
				-
				ha:Import {
					li:submenu {
						ha:Load symbol/group to paste-buffer = { li:action={BufferClear(); BufferLoad(Symbol); Tool(buffer); } }
						ha:Load back annotation file         = { li:action={Backann();} }
						ha:Load attribute table file         = { li:action={ImportAttbl();} }
					}
				}
				-
				ha:Print sheet...       = { a={<key>f;<key>p}; action=Print()}
				ha:Export Sheet...      = { a={<key>f;<key>e}; action=ExportDialog()}
				ha:Export Project...    = { a={<key>f;<key>j}; action=ExportProjectDialog()}
				-
				ha:Preferences...       = { a={<key>i;<key>c;<key>p}; action=preferences}
				ha:Maintenance {
					li:submenu {
						ha:Re-scan the symbol library     = { a={<key>i;<key>c;<key>r}; action=SymlibRehash(); tip={Re-read all configured symbol library directories, mapping all available symbols again. Run this after changing symbol library paths or creating a new root symbol dir.} }
						ha:Re-scan the devmap library     = { a={<key>i;<key>c;<key>d}; action=devmaplibRehash(); tip={Re-read all configured device map library directories, mapping all available devmaps again. Run this after changing devmap library paths or creating a new root devmap dir.} }
						ha:Re-scan the funcmap library    = { a={<key>i;<key>c;<key>u}; action=funcmaplibRehash(); tip={Re-read all configured funcmap library directories, mapping all available funcmaps again. Run this after changing funcmap library paths or creating a new root funcmap dir.} }
						ha:Data integrity check           = { a={<key>i;<key>c;<key>i}; action=Integrity() }
						-
						ha:Reload symbols in local lib    = { action=SymlibReloadAllLocal(); tip={Reload all symbols in the sheet local symbol lib from from external libraries. (Not undoable) } }
						ha:Clean devmap sheet local lib   = { action=DevmaplibCleanLocal(); tip={Remove all devmaps from the current sheet's local library; devmap files will be reloaded and reinserted in the local library upon the next compilation. } }
						ha:Clean funcmap sheet local lib  = { action=FuncmaplibCleanLocal(); tip={Remove all funcmaps from the current sheet's local library; funcmap files will be reloaded and reinserted in the local library upon the next compilation. } }
						-
						ha:Undo dialog (for debugging)    = { a={<key>u;<key>d;}; action=UndoDialog() }
					}
				}
				-
				ha:Quit                 = { a={<key>f;<key>q};          action=Quit() }
			}
		}

		ha:Edit {
			li:submenu {
				ha:Undo last operation          = { li:a={{<key>u; <Key>u}; {Ctrl<Key>z};};   action=Undo() }
				ha:Redo last undone operation   = { li:a={{<key>u; <Key>r}; {Ctrl<Key>y};};   action=Redo() }
				ha:Clear undo-buffer            = { a={<key>u; <Key>c}; action=Undo(ClearList) }
				-
				ha:Cut selection to buffer      = { li:a={{<key>e; <Key>x}; a=Ctrl<Key>x;};   li:action={ GetXY(Click to set the snap point for this buffer); BufferClear(Clear); BufferCut(MoveSelected); Tool(buffer) } }
				ha:Copy selection to buffer     = { li:a={{<key>e; <key>c}; {Ctrl<Key>c;};};  li:action={ GetXY(Click to set the snap point for this buffer); BufferClear(Clear); BufferCopy(); Unselect(All); Tool(buffer) } }
				ha:Paste buffer to layout       = {    a={Ctrl<Key>v;};                          action=Tool(buffer) }
				-
				ha:Remove object                = { li:a={{<key>e;<key>d};{<Key>Delete};}; li:action={Tool(Save); Tool(remove); GetXY(Click on object to remove); Tool(Press); Tool(Restore)} }
				ha:Whirl object (rotate 90 deg) = { li:a={{<key>e;<key>w};}; action=Rotate90(auto); }
				ha:Mirror object horizontally   = { li:a={{<key>e;<key>h};}; action=Mirror(auto, horizontal); }
				ha:Mirror object vertically     = { li:a={{<key>e;<key>v};}; action=Mirror(auto, vertical); }
				ha:Place template {
					li:submenu {
						ha:place terminal           = { a={<key>p;<key>t}; li:action={GetXy(Click where the new terminal should be placed); PlaceTerminal()}; }
						ha:place attribute text     = { a={<key>p;<key>a}; li:action={GetXy(Click where the new attribute should be placed); PlaceAttrib()}; }
					}
				}
				-
				ha:Change object {
					li:submenu {
						ha:Text string                   = { li:a={{<key>e;<key>t};};  action=EditText(Object) }
						ha:Stroke                        = { li:a={{<key>e;<key>s};}; action={pendialog(object)} }
						ha:Convert to extended object... = { a={<key>e; <key>o; <key>e}; action=Extobj(Object, convfrom) }
					}
				}
				ha:Change multiple objects {
					li:submenu {
						ha:Renumber symbols            = { li:a={{<key>e;<key>m;<key>r};};  action=RenumberDialog }
					}
				}
				ha:Object Properties...           = { a={<key>e; <key>p}; action=PropEdit(selection) }
			}
		}

		ha:View {
			li:submenu {
			ha:Grid {
				li:submenu {
					ha:Enable visible grid        = { a={<key>g; <key>v}; checked=editor/draw_grid; action=conf(toggle, editor/draw_grid, design) }
					ha:Enable local grid          = { a={<key>g; <key>l}; checked=editor/local_grid/enable; action=conf(toggle, editor/local_grid/enable, design) }
					ha:Grid size = {
						li:submenu {
							ha:No Grid                = { checked=ChkGridSize(none); action=SetGrid(1); update_on={editor/grid} }
							-
							@grid
							-
							ha:Previous grid          = { li:a={{<key>g; <key>b};{<char>[};}; action=Grid(down) }
							ha:Next grid              = { li:a={{<key>g; <key>f};{<char>]};}; action=Grid(up) }
							ha:Custom grid            = { li:a={{<key>g; <key>c};}; action=Grid(ask) }
							-
							ha:Grid *2                = { a={<key>g; <key>d}; action=SetGrid(*2) }
							ha:Grid /2                = { a={<key>g; <key>h}; action=SetGrid(/2) }
						}
					}
					ha:Grid properties = {
						li:submenu {
							ha:Enable local grid      = { checked=editor/local_grid/enable; action=conf(toggle, editor/local_grid/enable, design) }
							-
							ha:local grid radius 4    = { checked={conf(iseq, editor/local_grid/radius, 4)}; li:action={conf(set, editor/local_grid/radius, 4, design); conf(set, editor/local_grid/enable, 1, design) } update_on={} }
							ha:local grid radius 8    = { checked={conf(iseq, editor/local_grid/radius, 8)}; li:action={conf(set, editor/local_grid/radius, 8, design); conf(set, editor/local_grid/enable, 1, design) } update_on={} }
							ha:local grid radius 16   = { checked={conf(iseq, editor/local_grid/radius, 16)}; li:action={conf(set, editor/local_grid/radius, 16, design); conf(set, editor/local_grid/enable, 1, design) } update_on={} }
							ha:local grid radius 32   = { checked={conf(iseq, editor/local_grid/radius, 32)}; li:action={conf(set, editor/local_grid/radius, 32, design); conf(set, editor/local_grid/enable, 1, design) } update_on={} }
							-
							ha:sparse global grid     = { checked=editor/global_grid/sparse; action=conf(toggle, editor/global_grid/sparse, design) }
							ha:global grid density 4  = { checked={conf(iseq, editor/global_grid/min_dist_px, 4)}; li:action={conf(set, editor/global_grid/min_dist_px, 4, design); conf(set, editor/local_grid/enable, 0, design) } update_on={} }
							ha:global grid density 8  = { checked={conf(iseq, editor/global_grid/min_dist_px, 8)}; li:action={conf(set, editor/global_grid/min_dist_px, 8, design); conf(set, editor/local_grid/enable, 0, design) } update_on={} }
							ha:global grid density 16 = { checked={conf(iseq, editor/global_grid/min_dist_px, 16)}; li:action={conf(set, editor/global_grid/min_dist_px, 16, design); conf(set, editor/local_grid/enable, 0, design) } update_on={} }
						}
					}
#					ha:Realign grid               = { a={<key>g; <key>r}; action={ Display(RealignGrid) } }
					}
				}

				ha:Zoom {
					li:submenu {
						ha:Zoom In 20%            = { li:a={{<Key>z;<Key>z;}; {<char>+};} action=Zoom(-1.2) }
						ha:Zoom Out 20%           = { li:a={{<Key>z;<Key>x;}; {<char>-};} action=Zoom(+1.2) }
						ha:Zoom In 2X             = { action=Zoom(-2) }
						ha:Zoom Out 2X            = { action=Zoom(+2) }
						ha:Zoom to 0.025k/px      = { action={Zoom(=25)} }
						ha:Zoom to 0.05k/px       = { action={Zoom(=50)} }
						ha:Zoom to 0.10k/px       = { a={<Key>z;<Key>1;}; action={Zoom(=100)} }
						ha:Zoom to 0.25k/px       = { a={<Key>z;<Key>2;}; action={Zoom(=250)} }
						ha:Zoom to 0.50k/px       = { a={<Key>z;<Key>5;}; action={Zoom(=500)} }
						ha:Zoom In 20% and center = { li:action={Zoom(-1.2); Center()} }
						ha:Zoom Out 20% and center= { li:action={Zoom(+1.2); Center()} }
						-
						ha:Zoom Extents           = {      li:a={{<Key>z;<Key>e;}; {<key>v;<key>f};}; action=Zoom() }
						ha:Zoom to selection      = {      a={<Key>z;<Key>s;}; action=ZoomTo(selected) }
						-
						ha:Center cursor          = { a={<key>v; <key>c} action=Center() }
					}
				}
				ha:Current layer {
					li:submenu {
						ha:TODO             { li:a={{<Key>l;<Key>r}; {<Key>l;<Key>-};};         action=Layer(remove) }
					}
				}
				ha:Full screen                     = { checked=editor/fullscreen; a=<char>\\;  action=fullscreen(toggle) }
				ha:Reset {
					li:submenu {
						ha:Reset View                      = { a={<key>v; <key>r; <key>v}; sy:action={/scripts/view_reset}; tip={Reset all visibility related states to make sure all objects are visible} }
						ha:Reset GUI                       = { a={<key>v; <key>r; <key>g}; sy:action={/scripts/gui_reset}; tip={Reset all GUI related states } }
					}
				}
				ha:Sheet {
					li:submenu {
						ha:Previous                        = { li:a={{<key>v; <key>d; <key>p};{<char><};}; action={SwitchRelative(-1)}; tip={Switch to the previous sheet on the list of all-loaded-sheets} }
						ha:Next                            = { li:a={{<key>v; <key>d; <key>n};{<char>\>};}; action={SwitchRelative(+1)}; tip={Switch to the next sheet on the list of all-loaded-sheets} }
					}
				}
			}
		}


		ha:Mode = {
			li:submenu {
				ha:Lines and nets {
					li:submenu {
						ha:Cycle line clip/refraction (toggle) = { li:a={{<key>m; <key>l; <key>f}; {<char>/};}; action=conf(toggle, editor/line_refraction, design) }
						ha:Continuous draw (toggle)            = { li:a={{<key>m; <key>l; <key>c};}; action=conf(toggle, editor/line_cont, design) }
						ha:Rubber band mode                    = { a={<key>m; <key>r; <key>r}; checked=editor/rubber_band_mode; action=conf(toggle, editor/rubber_band_mode, design) }
						ha:Rubber band\: orthogonal lines      = { a={<key>m; <key>r; <key>o}; checked=editor/rubber_band_ortho; action=conf(toggle, editor/rubber_band_ortho, design) }
					}
				}
				ha:Drawing {
					li:submenu {
						ha:Lock floaters                    = { a={<key>m; <key>f; <key>l}; checked=editor/lock_floaters; action=ToggleFloaters(lock); }
						ha:Only floaters                    = { a={<key>m; <key>f; <key>o}; checked=editor/only_floaters; action=ToggleFloaters(only); }
					}
				}
				ha:Symbols and libraries {
					li:submenu {
						ha:Enable symbol auto-pasting to local lib = { a={<key>m; <key>s; <key>p}; checked=editor/paste_to_local_lib; action=conf(toggle, editor/paste_to_local_lib, design); tip={When enabled, symbols placed from (external) symbol library are first copied into the local symbol library then group references to the local copy are placed}}
					}
				}
				ha:Loose symbol (no sym lock) = { a={<key>m; <key>k; <key>s}; checked={propget(sheet, p/sheet/loose_sym)}; action={proptoggle(sheet, p/sheet/loose_sym)}; update_on={} }
				ha:Tool {
					li:submenu {
						ha:Circle         = { checked=ChkMode(circle);      li:a={{<key>t;<key>c};{<Key>F1};}; action=Tool(circle); update_on={editor/mode} }
						ha:Wirenet        = { checked=ChkMode(wirenet);     li:a={{<key>t;<key>w};{<Key>F2};}; action=Tool(wirenet); update_on={editor/mode} }
						ha:Line           = { checked=ChkMode(line);        li:a={{<key>t;<key>l};{<Key>F3};}; action=Tool(line); update_on={editor/mode} }
						ha:Text           = { checked=ChkMode(text);        li:a={{<key>t;<key>t};{<Key>F4};}; action=Tool(text); update_on={editor/mode} }
						ha:Rectangle      = { checked=ChkMode(rect);        li:a={{<key>t;<key>r};{<Key>F5};}; action=Tool(rect); update_on={editor/mode} }
						ha:Buffer         = { checked=ChkMode(buffer);      li:a={{<key>t;<key>b};{<Key>F7};}; action=Tool(buffer); update_on={editor/mode} }
						ha:Del/remove     = { checked=ChkMode(remove);      li:a={{<key>t;<key>d};{<Key>F8};}; action=Tool(remove); update_on={editor/mode} }
						ha:Whirl (rotate 90 deg) = {checked=ChkMode(rotate);li:a={{<key>t;<key>o};{<Key>F9};}; action=Tool(rotate); update_on={editor/mode} }
						ha:xmirror        = { checked=ChkMode(xmirror);     li:a={{<key>t;<key>x};}; action=Tool(xmirror); update_on={editor/mode} }
						ha:ymirror        = { checked=ChkMode(ymirror);     li:a={{<key>t;<key>y};}; action=Tool(ymirror); update_on={editor/mode} }
						ha:Arrow          = { checked=ChkMode(arrow);       li:a={{<key>t;<key>n};{<Key>F11};}; action=Tool(arrow); update_on={editor/mode} }
						ha:Lock           = { checked=ChkMode(lock);        li:a={{<key>t;<key>k};{<Key>F12};}; action=Tool(lock); update_on={editor/mode} }
						ha:Move           = { checked=ChkMode(move);        li:a={{<key>t;<key>m};}; action=Tool(move); update_on={editor/mode} }
						ha:Copy           = { checked=ChkMode(copy);        li:a={{<key>t;Shift<key>p};}; action=Tool(copy); update_on={editor/mode} }
						-
						ha:Cancel         = { a={<Key>Escape}; action=Tool(escape); }
						ha:Change pen     = { a={<Key>t;<Key>p}; action=Preferences(colors); }
					}
				} # Tool
			}
		}

		ha:Select = {
			li:submenu {
				ha:Select all visible objects on sheet = { a={<key>s; <key>a; <key>a;}; action=Select(All) }
				ha:Unselect all objects on sheet       = { a={<key>s; <key>u; <key>a;}; action=Unselect(All) }
				ha:Unselect all objects in projet      = { a={<key>s; <key>u; <key>p;}; action=Unselect(AllProject) }
				ha:Invert selection on sheet           = { a={<key>s; <key>i; }; action=Select(Invert) }
				-
				ha:Advanced search and select      = { a={<key>s; <key>s;} action=SearchDialog() }
				ha:List locked objects             = { a={<key>s; <key>l; <key>k;} action={query(view, "@.locked == 1")} }
				ha:List unnamed symbols            = { a={<key>s; <key>l; <key>u;} action={query(view, '@.a.role == "sym" || @.a.name ~ "[?]$"') } }
				-
				ha:Remove selected objects         = { a={<key>s; <key>r;} action=RemoveSelected() }
				ha:Convert selection to {
					li:submenu {
						ha:Polygon        = { a={<key>s;<key>c;<key>p}; li:action={GetXY(Click to set origin); Convert(selected, polygon);} }
						ha:Symbol         = { a={<key>s;<key>c;<key>s}; li:action={GetXY(Click to set origin); Convert(selected, symbol);} }
						ha:Terminal       = { a={<key>s;<key>c;<key>t}; li:action={GetXY(Click to set origin); Convert(selected, terminal);} }
						ha:Custom group   = { a={<key>s;<key>c;<key>g}; li:action={GetXY(Click to set origin); Convert(selected, group);} }
						ha:extended object= { a={<key>s; <key>c; <key>e;} action=Extobj(Selected, convfrom); }
					}
				}
				ha:Break up selected... {
					li:submenu {
						ha:objects        = { a={<key>s;<key>b;<key>b}; action=Breakup(selected, any, sheet); }
						ha:groups         = { a={<key>s;<key>b;<key>g}; action=Breakup(selected, group, sheet); }
						ha:polygons       = { a={<key>s;<key>b;<key>p}; action=Breakup(selected, poly, sheet); }
					}
				}
				ha:Change selected objects {
					li:submenu {
						ha:Edit properties       = { a={<key>s; <key>p}; action=propedit(selection) }
						ha:Testbench affiliation = { a={<key>s; <key>t}; action=TestBenchDialog(selected) }
						ha:Renumber on sheet...  = { a={<key>s; <key>n}; action=RenumberDialog(selected) }
						ha:Renumber in project...= { action=RenumberDialog(SelectedProject) }
					}
				}
			}
		} # Select

		ha:Buffer {
			li:submenu {
				ha:Rotate buffer 90 deg CCW (left)  = { a={<key>b;<key>r;<key>l}; action=Rotate90(Buffer, 1); }
				ha:Rotate buffer 90 deg CW (right)  = { a={<key>b;<key>r;<key>r}; action=Rotate90(Buffer, -1); }
				ha:Arbitrarily Rotate Buffer        = { a={<key>b;<key>r;<key>a}; action=Rotate(Buffer, ask); }
				ha:Mirror buffer (left/right)       = { a={<key>b;<key>m;<key>l}; action=Mirror(Buffer, horizontal);}
				ha:Mirror buffer (up/down)          = { a={<key>b;<key>m;<key>u}; action=Mirror(Buffer, vertical); }
#				ha:Scale                            = {  }
#				ha:Normalize                        = { a={<key>b;<key>n}; }
				-
				ha:Clear buffer                    = { a={<key>b;<key>c;<key>c;}; action=BufferClear() }
				ha:Save buffer content to file     = { a={<key>b;<key>f;<key>s;}; action=BufferSave(All) }
				ha:Load buffer content from file   = { a={<key>b;<key>f;<key>l;}; li:action={BufferClear(); BufferLoad(All); Tool(buffer);} }
				-
#				ha:Convert buffer to polygon       = { a={<key>b;<key>c;<key>p}; action=Convert(buffer, polygon); }
#				ha:Convert buffer to symbol        = { a={<key>b;<key>c;<key>s}; action=Convert(buffer, symbol); }
#				ha:Convert buffer to terminal      = { a={<key>b;<key>c;<key>t}; action=Convert(buffer, terminal); }
#				ha:Convert buffer to custom group  = { a={<key>b;<key>c;<key>g}; action=Convert(buffer, group); }
#				ha:Break up buffer                 = { a={<key>b;<key>b;<key>b}; action=Breakup(buffer, any, sheet); }
#				ha:Break up buffer groups          = { a={<key>b;<key>b;<key>g}; action=Breakup(buffer, group, sheet); }
#				ha:Break up buffer polygons        = { a={<key>b;<key>b;<key>p}; action=Breakup(buffer, poly, sheet); }
				-
				ha:Save buffer symbol to file      = { a={<key>b;<key>s;<key>s}; action=BufferSave(Symbol); tip={save one symbol group from the buffer as a group file} }
				ha:Save buffer group to file       = { a={<key>b;<key>s;<key>g}; action=BufferSave(Group); tip={save one group from the buffer as a group file} }
				ha:Load buffer symbol/group from file = { a={<key>b;<key>l;<key>s}; li:action={BufferClear(); BufferLoad(Symbol); Tool(buffer);}; tip={load one group from file into the paste buffer } }
				-
				ha:Buffer selection {
					li:submenu {
						ha:Select Buffer \#1 = { checked=BufferChk(1); a={<key>b;<Key>1;} action=BufferSwitch(1); update_on={editor/buffer_number} }
						ha:Select Buffer \#2 = { checked=BufferChk(2); a={<key>b;<Key>2;} action=BufferSwitch(2); update_on={editor/buffer_number} }
						ha:Select Buffer \#3 = { checked=BufferChk(3); a={<key>b;<Key>3;} action=BufferSwitch(3); update_on={editor/buffer_number} }
						ha:Select Buffer \#4 = { checked=BufferChk(4); a={<key>b;<Key>4;} action=BufferSwitch(4); update_on={editor/buffer_number} }
						ha:Select scratchpad = { checked=BufferChk(5); a={<key>b;<Key>5;} action=BufferSwitch(5); update_on={editor/buffer_number} }
					}
				}
			}
		} # Buffer

		ha:Attributes {
			li:submenu {
				ha:Generic group {
					li:submenu {
						ha:Change role        = { a={<key>a;<key>o;}; action=QuickAttr(object, role); tip={Change the role attribute of a group} }
						ha:Change name        = { a={<key>a;<key>n;}; action=AttributeDialog(object, name); tip={Change the name attribute of a group (refdes, pin number, etc)} }
					}
				}
				ha:Symbol {
					li:submenu {
						ha:Change name (refdes) = { a={<key>a;<key>r}; action=AttributeDialog(object, name); tip={Change the name attribute of a group (refdes)} }
						ha:Change value         = { a={<key>a;<key>v}; action=AttributeDialog(object, value); tip={Change the value attribute of a group} }
						ha:Change slot num      = { a={<key>a;<key>s}; action=AttributeDialog(object, -slot); tip={Change the slot number attribute of a group} }
						ha:Change devmap        = { a={<key>a;<key>d;}; action=QuickAttr(object, devmap); tip={Change the devmap attribute of a symbol (device+footprint+pinout mapping) } }
						ha:Change portmap       = { a={<key>a;<key>p;}; action=QuickAttr(object, portmap); tip={Change the portmap attribute of a group} }
						ha:Change connections   = { a={<key>a;<key>c;}; action=QuickAttr(object, connect); tip={Change the symbol terminal to network connection list } }
						ha:Change footprint     = { a={<key>a;<key>f}; action=AttributeDialog(object, footprint); tip={Change the footprint attribute of a group} }
						ha:Change funcmap       = { a={<key>a;<key>u;}; action=QuickAttr(object, funcmap); tip={Change the funcmap attribute of a symbol (alternative pin function map) } }
					}
				}
				-
				ha:Change name (refdes) = { a={<key>a;<key>a}; action=AttributeDialog(object, name); tip={Invoke attribute editor} }
			}
		} # Attributes

		ha:Plugins {
			li:submenu {
				ha:feature plugins   = {
					# submenu dedicated for feature plugins to register their menu items
					li:submenu {
						@feature_plugins
					}
				}
				ha:script            = {
					# submenu dedicated for user scripts to register their menu items
					li:submenu {
						@scripts
					}
				}
				ha:Manage plugins... = { a={<Key>p;<Key>m;<Key>p;}; action=ManagePlugins() }
				ha:Manage scripts... = { a={<Key>p;<Key>m;<Key>s;}; action=BrowseScripts() }
			}
		} # Plugins

		ha:Window {
			li:submenu {
				ha:Message Log    = { a={<Key>w;<Key>m}; action=LogDialog() }
				ha:Command Entry  = { li:a={a={<Key>w;<Key>c}; {<char>:};}  action=Command() }
				ha:Tree view      = { a={<Key>w;<Key>t}; action=TreeDialog() }
				ha:Abstract model = { a={<Key>w;<Key>a}; action=AbstractDialog() }
				ha:Viewport       = { a={<Key>w;<Key>v}; action=ViewPortDialog() }
				-
				ha:Library        = { a={<Key>w;<Key>l}; action=LibraryDialog(symbol, sheet) }
				ha:devmaps        = { a={<Key>w;<Key>w;<Key>d}; action=LibraryDialog(devmap, sheet) }
				ha:funcmaps       = { a={<Key>w;<Key>w;<Key>u}; action=LibraryDialog(funcmap, sheet) }
				ha:spice libs     = { a={<Key>w;<Key>w;<Key>s}; action=LibraryDialog(spicelib, sheet) }
				-
				ha:Key Bindings {
					li:submenu {
#						ha:Cycle object being dragged   = { li:a={{<char>,};{<key>e;<key>y;};}; action=CycleDrag() }
						ha:Step Cursor {
							li:submenu {
								ha:Step Up                      = { li:a={{<Key>Up};{<Key>k;<Key>k};}; action=Cursor(Warp,0,-1,grid) }
								ha:Step Down                    = { li:a={{<Key>Down};{<Key>k;<Key>j};}; action=Cursor(Warp,0,1,grid) }
								ha:Step Left                    = { li:a={{<Key>Left};{<Key>k;<Key>h};}; action=Cursor(Warp,-1,0,grid) }
								ha:Step Right                   = { li:a={{<Key>Right};{<Key>k;<Key>l};}; action=Cursor(Warp,1,0,grid) }
								ha:Step +Up                     = { a=Shift<Key>Up; action=Cursor(Pan,0,-50,view) }
								ha:Step +Down                   = { a=Shift<Key>Down; action=Cursor(Pan,0,50,view) }
								ha:Step +Left                   = { a=Shift<Key>Left; action=Cursor(Pan,-50,0,view) }
								ha:Step +Right                  = { a=Shift<Key>Right; action=Cursor(Pan,50,0,view) }
								ha:Scroll Up                    = { li:a={{Ctrl<Key>Up};{<Key>j;<Key>k};}; action=Scroll(up) }
								ha:Scroll Down                  = { li:a={{Ctrl<Key>Down};{<Key>j;<Key>j};}; action=Scroll(down) }
								ha:Scroll Left                  = { li:a={{Ctrl<Key>Left};{<Key>j;<Key>h};}; action=Scroll(left) }
								ha:Scroll Right                 = { li:a={{Ctrl<Key>Right};{<Key>j;<Key>l};}; action=Scroll(right) }
								ha:Click (left)                 = { li:a={{<Key>Enter};{<Key>k;<Key>space};}; li:action={Tool(Press); Tool(Release)} }
								ha:Click (right)                = { a={<Key>k;<Key>r}; li:action={Tool(Release); Popup(popup-obj, obj-type)} }
							}
						}
						ha:attribute layer keys {
							li:submenu {
								anon3=@layerkeys
							}
						}
						ha:generic layer keys {
							li:submenu {
								ha:Select previous layer    = { a={<Key>l; <Key>k}; action=LayerByStack(Select, Prev); }
								ha:Select next layer        = { a={<Key>l; <Key>l}; action=LayerByStack(Select, Next); }
								-
								ha:Select Layer 1           = { a=<Key>1; action=SelectLayer(1) }
								ha:Select Layer 2           = { a=<Key>2; action=SelectLayer(2) }
								ha:Select Layer 3           = { a=<Key>3; action=SelectLayer(3) }
								ha:Select Layer 4           = { a=<Key>4; action=SelectLayer(4) }
								ha:Select Layer 5           = { a=<Key>5; action=SelectLayer(5) }
								ha:Select Layer 6           = { a=<Key>6; action=SelectLayer(6) }
								ha:Select Layer 7           = { a=<Key>7; action=SelectLayer(7) }
								ha:Select Layer 8           = { a=<Key>8; action=SelectLayer(8) }
								ha:Select Layer 9           = { a=<Key>9; action=SelectLayer(9) }
								ha:Select Layer 10          = { a=<Key>0; action=SelectLayer(10) }
								ha:Select Layer 11          = { a=Alt<Key>1; action=SelectLayer(11) }
								ha:Select Layer 12          = { a=Alt<Key>2; action=SelectLayer(12) }
								ha:Select Layer 13          = { a=Alt<Key>3; action=SelectLayer(13) }
								ha:Select Layer 14          = { a=Alt<Key>4; action=SelectLayer(14) }
								ha:Select Layer 15          = { a=Alt<Key>5; action=SelectLayer(15) }
								ha:Select Layer 16          = { a=Alt<Key>6; action=SelectLayer(16) }
								ha:Select Layer 17          = { a=Alt<Key>7; action=SelectLayer(17) }
								ha:Select Layer 18          = { a=Alt<Key>8; action=SelectLayer(18) }
								ha:Select Layer 19          = { a=Alt<Key>9; action=SelectLayer(19) }
								ha:Select Layer 20          = { a=Alt<Key>0; action=SelectLayer(20) }
								-
								ha:Toggle Layer 1           = { a=Ctrl<Key>1; action=ToggleView(1) }
								ha:Toggle Layer 2           = { a=Ctrl<Key>2; action=ToggleView(2) }
								ha:Toggle Layer 3           = { a=Ctrl<Key>3; action=ToggleView(3) }
								ha:Toggle Layer 4           = { a=Ctrl<Key>4; action=ToggleView(4) }
								ha:Toggle Layer 5           = { a=Ctrl<Key>5; action=ToggleView(5) }
								ha:Toggle Layer 6           = { a=Ctrl<Key>6; action=ToggleView(6) }
								ha:Toggle Layer 7           = { a=Ctrl<Key>7; action=ToggleView(7) }
								ha:Toggle Layer 8           = { a=Ctrl<Key>8; action=ToggleView(8) }
								ha:Toggle Layer 9           = { a=Ctrl<Key>9; action=ToggleView(9) }
								ha:Toggle Layer 10          = { a=Ctrl<Key>0; action=ToggleView(10) }
								ha:Toggle Layer 11          = { a=Ctrl-Alt<Key>1; action=ToggleView(11) }
								ha:Toggle Layer 12          = { a=Ctrl-Alt<Key>2; action=ToggleView(12) }
								ha:Toggle Layer 13          = { a=Ctrl-Alt<Key>3; action=ToggleView(13) }
								ha:Toggle Layer 14          = { a=Ctrl-Alt<Key>4; action=ToggleView(14) }
								ha:Toggle Layer 15          = { a=Ctrl-Alt<Key>5; action=ToggleView(15) }
								ha:Toggle Layer 16          = { a=Ctrl-Alt<Key>6; action=ToggleView(16) }
								ha:Toggle Layer 17          = { a=Ctrl-Alt<Key>7; action=ToggleView(17) }
								ha:Toggle Layer 18          = { a=Ctrl-Alt<Key>8; action=ToggleView(18) }
								ha:Toggle Layer 19          = { a=Ctrl-Alt<Key>9; action=ToggleView(19) }
								ha:Toggle Layer 20          = { a=Ctrl-Alt<Key>0; action=ToggleView(20) }
							}
						} # layer keys

						ha:polygon drawing {
							li:submenu {
								ha:Polygon PreviousPoint        = { a={<Key>p; <Key>p; <Key>p}; action=Polygon(PreviousPoint) }
								ha:Polygon Close                = { a={<Key>p; <Key>p; <Key>c}; action=Polygon(Close) }
							}
						}
					}
				}
				ha:About...       = { li:a={{<key>i;<key>a};}; action=About() }
			}
		}
	} #main_menu

	li:popups {
# context sensitive right click: popup per object type under the cursor

		ha:layer {
			li:submenu {
				ha:TODO             { }
			}
		}

		ha:popup-obj-polygon {
			li:submenu {
				ha:edit polygon properties...       { action=propedit(object) }
				ha:polygon in tree view...          { action=TreeDialog(object) }
			}
		}

		ha:popup-obj-arc {
			li:submenu {
				ha:edit arc properties...           { action=propedit(object) }
				ha:arc in tree view...              { action=TreeDialog(object) }
				ha:Convert to extended object... =  { action=Extobj(Object, convfrom) }
			}
		}

		ha:popup-obj-line {
			li:submenu {
				ha:edit line properties...          { action=propedit(object) }
				ha:line in tree view...             { action=TreeDialog(object) }
				ha:Convert to extended object... =  { action=Extobj(Object, convfrom) }
			}
		}

		ha:popup-obj-text {
			li:submenu {
				ha:edit text properties...          { action=propedit(object) }
				ha:text in tree view...             { action=TreeDialog(object) }
				ha:edit text string                 { action=EditText(Object) }
				ha:Convert to extended object... =  { action=Extobj(Object, convfrom) }
			}
		}

		ha:popup-obj-symbol {
			li:submenu {
				ha:edit symbol properties...        { action=propedit(object) }
				ha:edit symbol attributes...        { action=AttributeDialog(last-click) }
				ha:edit symbol pens...              { action=pendialog(object, non-modal) }
				ha:symbol in tree view...           { action=TreeDialog(object) }
				-
				ha:Change name (refdes)             { action=AttributeDialog(object, name); tip={Change the name attribute of a group (refdes)} }
				ha:Change devmap                    { action=QuickAttr(object, devmap); tip={Change the devmap attribute of a symbol (device+footprint+pinout mapping) } }
				ha:Change funcmap                   { action=QuickAttr(object, funcmap); tip={Change the funcmap attribute of a symbol (alternative pin function mapping) } }
				ha:Per port funcmap...              { action=FuncmapComponentDialog(object); tip={Open the per port alternate function table for the component the symbol creates } }
				ha:Conditional... {
					li:submenu {
						ha:DNP (do not populate)        { action=ConditionalDialog(object, dnp); tip="Condition to mark the the component Do-Not-Populate in export" }
						ha:omit (no-export)             { action=ConditionalDialog(object, omit); tip="Condition to omit the component from exports" }
					}
				}
				ha:Testbench affiliation =          { action=TestBenchDialog(object) }
				-
				ha:update symbol from ext. lib               { }
				ha:move symbol to local lib ref.             { action=SymLocLib(object, toref); }
				ha:convert from local lib ref. to embedded   { action=SymLocLib(object, togrp); }
			}
		}

		ha:popup-obj-terminal {
			li:submenu {
				ha:edit terminal properties...        { action=propedit(object) }
				ha:edit terminal attributes...        { action=AttributeDialog(last-click) }
				ha:edit terminal pens...              { action=pendialog(object, non-modal) }
				ha:funcmap\: change alternate function...{ action=FuncmapPortDialog(object); tip={Open a dialog box to select alternate function of the pin if the component features alternate funcmap } }
				ha:terminal in tree view...           { action=TreeDialog(object) }
				ha:set terminal name                  { action={message(ERROR, not yet implemented)}; }
			}
		}

		ha:popup-obj-wire-net {
			li:submenu {
				ha:edit wirenet properties...       { action=propedit(parent) }
				ha:edit net attributes...           { action=AttributeDialog(parent) }
				ha:wirenet object in tree view...   { action=TreeDialog(object) }
				-
				ha:Conditional... {
					li:submenu {
						ha:omit (no-export)             { action=ConditionalDialog(object, omit); tip="Condition to omit the component from exports" }
					}
				}
			}
		}

		ha:popup-obj-extobj {
			li:submenu {
				ha:edit group properties...         { action=propedit(object) }
				ha:edit group attributes...         { action=AttributeDialog(object) }
				ha:object in tree view...           { action=TreeDialog(object) }
				-
				ha:update extended object           { action=Extobj(object, update) }
				ha:edit extended object...          { action=Extobj(object, edit) }
				-
				ha:Conditional... {
					li:submenu {
						ha:omit (no-export)             { action=ConditionalDialog(object, omit); tip="Condition to omit the component from exports" }
					}
				}
			}
		}

		ha:popup-obj-user-grp-unknown {
			li:submenu {
				ha:edit group properties...         { action=propedit(object) }
				ha:edit group attributes...         { action=AttributeDialog(last-click) }
				ha:edit group pens...               { action=pendialog(object, non-modal) }
				ha:group in tree view...            { action=TreeDialog(object) }
			}
		}

		ha:sheet {
			li:submenu {
				ha:edit sheet properties...         { action=propedit(sheet) }
				ha:edit sheet attributes...         { action=AttributeDialog(sheet) }
				ha:edit sheet pens...               { action={PenDialog(object=/2)} }
			}
		}

		ha:symbol-as-sheet {
			li:submenu {
				ha:edit top symbol properties...         { action=propedit(sheet) }
				ha:edit top symbol attributes...         { action=AttributeDialog(sheet) }
				ha:edit top symbol pens...               { action={PenDialog(object=/2)} }
			}
		}

	} #popups

	ha:scripts {
		# set all visibility related conf nodes (view/mode/drawing in the menu)
		# to safe defaults that makes sure everything is visible
		mode_reset {
#			conf(set, editor/wireframe_draw, 0, design);
#			conf(set, editor/thin_draw, 0, design);
#			conf(set, editor/thin_draw_poly, 0, design);
			Display(Redraw);
		}

		# set all visibility related states to safe defaults that makes sure
		# everything is visible
		li:view_reset {
			sy:mdr = {/scripts/mode_reset}
#TODO:			LayerVisReset();
			zoom();
		}

		# set all GUI states to safe defaults to get the UI to a known state
		li:gui_reset {
			sy:vr = {/scripts/view_reset}
			fullscreen(off);
			conf(set, editor/draw_grid, 1, design);
			conf(set, editor/local_grid/enable, 0, design);
			Tool(arrow);
#			Display(Redraw);
		}
	} # scripts

} # root
