ha:rnd-menu-v1 {
	li:mouse {
		li:left {
			li:press            = { Tool(Press) }
			li:press-shift      = { Tool(Press) }
			li:press-ctrl       = { Tool(Save); Tool(arrow); Tool(Restore); 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         = { Tool(Stroke) }
			li:release       = { Tool(Release); Popup(popup-obj, obj-type) }
			li:shift-release = { Popup(popup-obj-misc) }
		}
		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:via       {tip={place a via on the board}}
		ha:line      {tip={draw a line segment (trace) on the board}}
		ha:arc       {tip={draw an arc segment (trace) on the board}}
		ha:text      {tip={draw text on the board}}
		ha:rectangle {tip={draw a rectangular polygon on the board}}
		ha:poly      {tip={draw a polygon on the board}}
		ha:polyhole  {tip={cut out a hole from existing polygons on the board}}
		ha:buffer    {tip={paste the current buffer on the board}}
		ha:remove    {tip={remove an object from the board}}
		ha:rotate    {tip={rotate an object on the board}}
		ha:insert    {tip={insert a point in a trace or polygon contour}}
		ha:thermal   {tip={change thermal connectivity of a pin or via}}
		ha:arrow     {tip={switch to arrow mode}}
		ha:lock      {tip={lock or unlock objects on the board}}
	}

	li:main_menu {

		ha:File {
			li:submenu {
				ha:Start New Layout                  = { li:a={{<key>f;<key>n}; {Ctrl<Key>n};}; action=New() }
				ha:Revert                            = { a={<key>f;<key>r};          action=Load(Revert,none); tip=Revert to the layout stored on disk }
				-
				ha:Load layout...                    = { li:a={{<key>f;<key>o};{<key>f;<key>l};}  action=Load(Layout); tip=Load a layout from a file }
				-
				ha:Save Layout                       = { li:a={{<key>f;<key>s}; {Ctrl<Key>s};};        action=Save(Layout); tip=Saves current layout }
				ha:Save Layout As...                 = { li:a={{<key>f;<key>a}; {Shift Ctrl<Key>s};};  action=Save(LayoutAs); tip=Saves current layout into a new file }
				-
				ha:Import {
					li:submenu {
						ha:Import schematics...              = {a={<key>f;<key>f;<key>s};    action=ImportSch() }
						ha:Configure import schematics...    = {                             action=ImportSch(dialog) }
						@import_top
						ha:Import AnyLoad (or lht config)    = {                             action=AnyLoad() }
						-
						ha:Load subcircuit data to paste-buffer = {                          li:action={PasteBuffer(Clear); Load(ElementTobuffer)} }
						ha:Load layout data to paste-buffer  = {                             li:action={PasteBuffer(Clear); Load(LayoutTobuffer)} }
						ha:Load pixmap to paste-buffer gfx   = {                             li:action={PasteBuffer(Clear); LoadPixmap(); Tool(buffer);} }
						@import_geo
						-
						@import_sch
						ha:Load netlist file (detect format) = {                             action=Load(Netlist) }
					}
				}
				-
				ha:Save connection data of {
					li:submenu {
						ha:a single element                  = {                  li:action={ Save(ElementConnections) } }
						ha:all elements                      = {                  action=Save(AllConnections) }
						ha:unused pins                       = {                  action=Save(AllUnusedPins) }
						ha:netlist patch for back annotation = {li:a={{<key>f;<key>x;<key>p}; {<key>a;<key>b;<key>x};}; action=SavePatch() }
					}
				}
				ha:Print layout...      = { a={<key>f;<key>p}; action=Print()}
				ha:Export layout...     = { a={<key>f;<key>e}; action=ExportGUI()}
				ha:Export with CAM job...={ a={<key>f;<key>c}; action=cam()}
				ha:Reports {
					li:submenu {
						ha:Generate object report  = { a={<key>i;<key>r}; action=ReportObject() }
						ha:Generate drill summary  = { a={<key>i;<key>d}; action=Report(DrillReport) }
						ha:Report found padstacks  = { a={<key>i;<key>f}; action=Report(FoundPins) }
					}
				}
				-
				ha:Preferences...       = { a={<key>i;<key>c;<key>p}; action=preferences}
				ha:Maintenance {
					li:submenu {
						ha:Re-scan the footprint library  = { a={<key>i;<key>c;<key>r}; action=fp_rehash() }
						ha:Data integrity check           = { a={<key>i;<key>c;<key>i}; action=Integrity() }
						-
						ha:Edit current font              = { action=FontEdit() }
						ha:Edit on-disk font              = { action={ LoadFontFrom("", 126); conf(set, design/text_font_id, 126, design); FontEdit() } }
						ha:Save font from font editor     = { action=FontSave() }
						-
						ha:Undo dialog (for debugging)    = { a={<key>u;<key>d;}; action=UndoDialog() }
					}
				}
				-
				ha:Quit Program         = { li:a={{<key>f;<key>q}; {Ctrl<Key>q};}; action=Quit() }
			}
		} # File

		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); PasteBuffer(Clear); PasteBuffer(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); PasteBuffer(Clear); PasteBuffer(AddSelected); Unselect(All); Tool(buffer) } }
				ha:Paste buffer to layout       = { li:a={{<key>e; <Key>v}; a=Ctrl<Key>v;};   action=Tool(buffer) }
				-
				ha:Remove object                = { li:a={{<key>e;<key>d};{<Key>Delete};}; li:action={Tool(Save); Tool(remove); Tool(Press); Tool(Restore)} }
				ha:Change object {
					li:submenu {
						ha:Set Same Style           = { a={<key>e; <key>s; <key>s}; action=SetSame() }
						ha:Apply Pen to object      = { a={<key>e; <key>a; <key>p}; action=ApplyPen() }
						ha:Flip Object              = { a={<key>e; <key>i}; action=Flip(Object) }
						ha:Move to current layer    = { a={<key>e; <key>l}; action=MoveToCurrentLayer(Object) }
						ha:ChangeJoin Object        = { a={<key>e; <key>j}; action=ChangeJoin(Object) }
						ha:Convert to extended object... = { a={<key>e; <key>s; <key>x}; action=ExtobjConvFrom(Object, @gui) }
						ha:Edit text or terminal ID... = { li:a={{<key>e;<key>t};};  action=ChangeName(Object) }
						ha:Geometry {
							li:submenu {
								ha:Clearance +2 mil             = { a={<key>e; <key>g; <key>c}; action=ChangeClearSize(Object,+2,mil) }
								ha:Clearance -2 mil             = { a={<key>e; <key>g; Shift<key>c}; action=ChangeClearSize(Object,-2,mil) }
								ha:ChangeSizes to Route style   = { a={<key>e; <key>g; <key>y}; action=ChangeSizes(Object,style,mil) }
								ha:ChangeSize +5 mil            = { a={<key>e; <key>g; <key>s}; action=ChangeSize(Object,+5,mil) }
								ha:ChangeSize -5 mil            = { a={<key>e; <key>g; Shift<key>s}; action=ChangeSize(Object,-5,mil) }
								ha:ChangeDrill +5 mil           = { a={<key>e; <key>g; <key>d}; action=ChangeDrillSize(Object,+5,mil) }
								ha:ChangeDrill -5 mil           = { a={<key>e; <key>g; Shift<key>d}; action=ChangeDrillSize(Object,-5,mil) }
								-
								ha:Edit padstack geometry/prototype = {a={<key>e; <key>g; <key>g}; action=padstackedit }
							}
						}
					}
				} # Change object
				ha:Add/place object {
					li:submenu {
						ha:Place mark                       = { li:a={{<key>a;<key>m}; {<key>a;<key>w}; }; action=MarkCrosshair() }
						ha:Place via                        = { a={<key>a;<key>v}; li:action={Tool(Save); Tool(via); Tool(Press); Tool(Restore);} }
						ha:Start routing a line             = { a={<key>a;<key>l}; li:action={Tool(Save); Tool(line); Tool(Press); } }
						ha:Start routing an arc             = { a={<key>a;<key>a}; li:action={Tool(Save); Tool(arc); Tool(Press); } }
					}
				}
				-
				ha:Edit properties of {
					li:submenu {
						ha:Layout                     = { action=Propedit(board) }
						ha:Current Layer              = { action={Propedit(layer)} }
						ha:Current Layer Group        = { action={Propedit(layergrp)} }
					}
				}
				ha:Route Styles {
					li:submenu {
						@routestyles
						-
						ha:Edit...                    = { action=AdjustStyle() }
					}
				}
				ha:Board padstack prototypes...   = { action=pstklib() }
				-
				ha:Subcircuit {
					li:submenu {
						ha:Layer bindings...          = { a={<key>e; <key>s; <key>b}; action=LayerBinding() }
						ha:External editor...         = { a={<key>e; <key>s; <key>e}; li:action={ GetXY(Click on the subcircuit to edit); extedit(object) } }
						ha:Refdes                     = { a={<key>e; <key>s; <key>r}; action=ChangeName(Subc) }
					}
				}
				ha:Object flags...                = { a={<key>e; <key>f}; action=FlagEdit() }
				ha:Object Properties...           = { a={<key>e; <key>p}; action=PropEdit(selection) }
			}
		} # Edit

		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 units {
						li:submenu {
							ha:mil                    = { a={<key>g; <key>i}; checked=ChkGridUnits(mil); action=SetUnits(mil); update_on={editor/grid_unit} }
							ha:mm                     = { a={<key>g; <key>m}; checked=ChkGridUnits(mm); action=SetUnits(mm); update_on={editor/grid_unit} }
						}
					}
					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 -5mil             = { action=SetGrid(-5,mil) }
							ha:Grid +5mil             = { action=SetGrid(+5,mil) }
							ha:Grid -0.05mm           = { action=SetGrid(-0.05,mm) }
							ha:Grid +0.05mm           = { action=SetGrid(+0.05,mm) }
						}
					}
					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:Displayed subcircuit ID {
					li:submenu {
						ha:refdes                 = { a={<key>v; <key>s; <key>r}; checked=ChkSubcID(%a.refdes%); action=Display(SubcID, "%a.refdes%"); update_on={editor/subc_id} }
						ha:footprint              = { a={<key>v; <key>s; <key>f}; checked=ChkSubcID(%a.footprint%); action=Display(SubcID,"%a.footprint%"); update_on={editor/subc_id} }
						ha:value                  = { a={<key>v; <key>s; <key>v}; checked=ChkSubcID(%a.value%); action=Display(SubcID,"%a.value%"); update_on={editor/subc_id} }
						ha:refdes+value           = { a={<key>v; <key>s; <key>s}; checked=ChkSubcID(%a.refdes%\\n%a.value%); action=Display(SubcID,"%a.refdes%\\\\n%a.value%"); update_on={editor/subc_id} }
						ha:user configured        = { a={<key>v; <key>s; <key>c}; action=Display(SubcID); }
					}
				}
				ha:Displayed terminal ID {
					li:submenu {
						ha:term                   = { a={<key>v; <key>t; <key>t}; checked=ChkTermID(%a.term%); action=Display(TermID, "%a.term%"); update_on={editor/term_id} }
						ha:name                   = { a={<key>v; <key>t; <key>n}; checked=ChkTermID(%a.name%); action=Display(TermID, "%a.name%"); update_on={editor/term_id} }
						ha:term+name              = { a={<key>v; <key>t; <key>s}; checked=ChkTermID("%a.term%,%a.name%"); action=Display(TermID, "%a.term%,%a.name%"); update_on={editor/term_id} }
						ha:user configured        = { a={<key>v; <key>t; <key>c}; action=Display(TermID); }
					}
				}
				ha:Zoom and side {
					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.1mil/px      = { action={Zoom(=0.1mil)} }
						ha:Zoom to 0.01mm/px      = { action={Zoom(=0.01mm)} }
						ha:Zoom to 1mil/px        = { action={Zoom(=1mil)} }
						ha:Zoom to 0.05mm/px      = { action={Zoom(=0.05mm)} }
						ha:Zoom to 2.5mil/px      = { action={Zoom(=2.5mil)} }
						ha:Zoom to 0.1mm/px       = { action={Zoom(=0.1mm)} }
						ha:Zoom to 10mil/px       = { action={Zoom(=10mil)} }
						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:Zoom to found          = {      a={<Key>z;<Key>f;}; action=ZoomTo(found) }
						-
						ha:Flip up/down           = { checked=editor/view/flip_y; a=<Key>Tab; action=SwapSides(V) }
						ha:Flip left/right        = { checked=editor/view/flip_x; a=Shift<Key>Tab; action=SwapSides(H) }
						ha:Spin 180 degrees       = { a=Ctrl<Key>Tab; action=SwapSides(R) }
						ha:Swap Sides             = { a=Ctrl Shift<Key>Tab; action=SwapSides() }
						-
						ha:Center cursor          = { a={<key>v; <key>c} action=Center() }
					}
				}
				ha:Layers {
					li:submenu {
						ha:Shown Layers {
							li:submenu {
								@layerview
								-
								ha:Edit Layer Groups      = { action=Preferences("layers") }
							}
						}
						ha:Current Layer {
							li:submenu {
								anon2=@layerpick
								-
								ha:Delete current layer   = { action=MoveLayer(c,-1) }
								ha:Add new layer          = { action=MoveLayer(-1,c) }
								ha:Move current layer up  = { action=MoveLayer(c,step-) }
								ha:Move current layer down= { action=MoveLayer(c,step+) }
							}
						}
					}
				}
				ha:Show padstack numbers in a subc = { a={<key>v; <key>n} action=Display(PinOrPadName) }
				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 } }
					}
				}
			}
		} # View

		ha:Mode = {
			li:submenu {
				ha:Routing {
					li:submenu {
						ha:'All-direction' lines            = { li:a={{<key>m; <key>l; <key>a}; {<char>.};}; checked=editor/all_direction_lines; action=conf(toggle, editor/all_direction_lines, design); update_on={editor/all_direction_lines} }
						ha:Cycle line clip/refraction       = { li:a={{<key>m; <key>l; <key>f}; {<char>/};}; action=Display(CycleClip) }
						ha:Auto swap line start angle       = { checked=editor/swap_start_direction; action=conf(toggle, editor/swap_start_direction, design) }
						ha:Auto enforce style clearance     = { a={<key>m; <key>l; <key>d}; checked=editor/auto_drc; action=conf(toggle, editor/auto_drc, design) }
						ha:Automatic trace merging          = { a={<key>m; <key>l; <key>m}; checked=editor/trace_auto_merge; action=conf(toggle, editor/trace_auto_merge, 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 keeps middle line dir= { a={<key>m; <key>r; <key>m}; checked=editor/rubber_band_keep_midlinedir; action=conf(toggle, editor/rubber_band_keep_midlinedir, design) }
						-
						ha:Route radius +0.5                = { li:a={{<key>r; <key>r; <char>+}; {<key>r; <key>r; <key>p};}; action=conf(delta, editor/route_radius, +0.5, design); }
						ha:Route radius -0.5                = { li:a={{<key>r; <key>r; <char>-}; {<key>r; <key>r; <key>m};}; action=conf(delta, editor/route_radius, -0.5, design); }
						-
						ha:New lines, arcs clear polygons   = { a={<key>m; <key>l; <key>c}; checked=editor/clear_line; action=conf(toggle, editor/clear_line, design) }
						ha:New polygons are full ones       = { a={<key>m; <key>p; <key>f}; checked=editor/full_poly; action=conf(toggle, editor/full_poly, design) }
						ha:New polygons clear polygons      = { a={<key>m; <key>p; <key>c}; checked=editor/clear_polypoly; action=conf(toggle, editor/clear_polypoly, design) }
						ha:Polygon clip inhibit (toggle)    = { a={<key>m; <key>p; <key>i}; checked=ClipInhibit(check); action=ClipInhibit(toggle); update_on={temp/clip_inhibit_chg} }
					}
				}
				ha:Cursor/snap {
					li:submenu {
						ha:Orthogonal moves                 = { a={<key>m; <key>c; <key>o}; checked=editor/orthogonal_moves; action=conf(toggle, editor/orthogonal_moves, design) }
						ha:Crosshair snaps to padstacks     = { a={<key>m; <key>c; <key>p}; checked=editor/snap_pin; action=conf(toggle, editor/snap_pin, design) }
						ha:Crosshair snaps to off-grid points on lines = { a={<key>m; <key>c; <key>s};checked=editor/snap_offgrid_line; action=conf(toggle, editor/snap_offgrid_line, design) }
						ha:Crosshair shows style/object clearance  = { a={<key>m; <key>c; <key>c}; checked=editor/show_drc; action=conf(toggle, editor/show_drc, design) }
					}
				}
				ha:Drawing {
					li:submenu {
						@indications
						ha:Show autorouter trials           = { a={<key>m; <key>d; <key>a}; checked=editor/live_routing; li:action={ conf(toggle, editor/live_routing, design); Display(Redraw); } }
						ha:Highlighting on line, arc points = { a={<key>m; <key>d; <key>h}; checked=editor/highlight_on_point; li:action={ conf(toggle, editor/highlight_on_point, design); Display(Redraw); } }
						ha:Wireframe draw                   = { li:a={{<key>m; <key>d; <key>w}; {<char>|};}; checked=editor/wireframe_draw; li:action={ conf(toggle, editor/wireframe_draw, design); Display(Redraw); } }
						ha:Thin draw                        = { a={<key>m; <key>d; <key>t}; checked=editor/thin_draw;  li:action={ conf(toggle, editor/thin_draw, design); Display(Redraw); } }
						ha:Thin draw poly                   = { a={<key>m; <key>d; <key>p}; checked=editor/thin_draw_poly; li:action={ conf(toggle, editor/thin_draw_poly, design); Display(Redraw); }; update_on={editor/thin_draw_poly} }
						ha:poly as-drawn frame annotation   = { a={<key>m; <key>d; <key>d}; checked=editor/as_drawn_poly; li:action={ conf(toggle, editor/as_drawn_poly, design); Display(Redraw); }; update_on={editor/as_drawn_poly} }
						ha:Check polygons                   = { a={<key>m; <key>d; <key>c}; checked=editor/check_planes; li:action={ conf(toggle, editor/check_planes, design); Display(Redraw); } }
						ha:Object list popup                = { a={<key>m; <key>d; <key>o}; checked=editor/click_objlist; action=conf(toggle, editor/click_objlist, design); tip={If there are multiple objects under the cursor when executing an action, present a popup dialog to select which object to operate on} }
						-
						ha:Lock floaters                    = { a={<key>m; <key>f; <key>l}; checked=editor/lock_names; action=display(togglelocknames) }
						ha:Only floaters                    = { a={<key>m; <key>f; <key>o}; checked=editor/only_names; action=display(toggleonlynames) }
						ha:Hide floaters                    = { a={<key>m; <key>f; <key>h}; checked=editor/hide_names; action=conf(toggle, editor/hide_names, design) }
						-
						ha:Line Tool size +5 mil            = { a={<key>m; <key>l; <char>+}; action=SetValue(LineSize,+5,mil) }
						ha:Line Tool size -5 mil            = { a={<key>m; <key>l; <char>-}; action=SetValue(LineSize,-5,mil) }
						ha:Text Tool scale +10 mil          = { a={<key>m; <key>t; <char>+}; action=SetValue(TextScale,+10,mil) }
						ha:Text Tool scale -10 mil          = { a={<key>m; <key>t; <char>-}; action=SetValue(TextScale,-10,mil) }
						-
						ha:Render color override {
							li:submenu {
								ha:Invisible-color on other groups  = { a={<key>m; <key>o; <key>i}; checked=appearance/invis_other_groups; action=conf(toggle, appearance/invis_other_groups, design) }
								ha:black current group              = { a={<key>m; <key>o; <key>b}; checked=appearance/black_current_group; action=conf(toggle, appearance/black_current_group, design) }
							}
						}
						-
						ha:Reset                           = { a={<key>m; <key>d; <key>r}; sy:action={/scripts/mode_reset}; tip={Reset all the above drawing modes to make sure objects are visible} }
					}
				}
				ha:Mincut on shorts                 = { checked=plugins/mincut/enable; action=conf(toggle, plugins/mincut/enable, design) }
				ha:Auto-zero delta measurements     = { checked=editor/local_ref; action=conf(toggle, editor/local_ref, design) }
				ha:Brave mode                       = { action=brave() }
				ha:Loose subcircuits (no subc lock) = { a={<key>m; <key>k; <key>s}; checked=subc(loose, check); action=subc(loose, toggle); update_on={} }
				ha:Tool {
					li:submenu {
						ha:Via            = { checked=ChkMode(via);         li:a={{<key>t;<key>v};{<Key>F1};}; action=Tool(via); update_on={editor/mode} }
						ha:Line           = { checked=ChkMode(line);        li:a={{<key>t;<key>l};{<Key>F2};}; action=Tool(line); update_on={editor/mode} }
						ha:Arc            = { checked=ChkMode(arc);         li:a={{<key>t;<key>a};{<Key>F3};}; action=Tool(arc); 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(rectangle);   li:a={{<key>t;<key>r};{<Key>F5};}; action=Tool(rectangle); update_on={editor/mode} }
						ha:Polygon        = { checked=ChkMode(poly);        li:a={{<key>t;<key>p};{<Key>F6};}; action=Tool(poly); update_on={editor/mode} }
						ha:Polygon Hole   = { checked=ChkMode(polyhole);    a={<key>t;<key>h}; action=Tool(polyhole); 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:Rotate         = { checked=ChkMode(rotate);      li:a={{<key>t;<key>o};{<Key>F9};}; action=Tool(rotate); update_on={editor/mode} }
						ha:Thermal        = { checked=ChkMode(thermal);     li:a={{<key>t;<key>e};{<Key>F10};}; action=Tool(thermal); update_on={editor/mode} }
						ha:Arrow          = { checked=ChkMode(arrow);       li:a={{<key>t;<key>n};{<Key>F11};{<Key>space};}; action=Tool(arrow); update_on={editor/mode} }
						ha:Insert Point   = { checked=ChkMode(insert);      li:a={{<key>t;<key>i};{<Key>Insert};}; action=Tool(insert); update_on={editor/mode} }
						ha:Move           = { checked=ChkMode(move);        a={<key>t;<key>m}; action=Tool(move); update_on={editor/mode} }
						ha:Copy           = { checked=ChkMode(copy);        a={<key>t;<key>c}; action=Tool(copy); 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:Cancel         = {                               a={<Key>Escape}; action=Tool(Escape) }
					}
				} # Tool
			}
		} #Mode

		ha:Select {
			li:submenu {
				ha:Select all visible objects      = { a={<key>s; <key>a; <key>a;}; action=Select(All) }
				ha:Select all found objects        = { a={<key>s; <key>a; <key>c;}; action=Select(Connection); tip={Select all objects that have the 'found' flag set} }
				ha:Unselect all objects            = { a={<key>s; <key>u; <key>a;}; action=Unselect(All) }
				ha:Unselect all found objects      = { a={<key>s; <key>u; <key>c;}; action=Unselect(Connection); tip={Unselect all objects that have the 'found' flag set} }
				ha:Invert selection                = { 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>k;} action={query(view, "@.p.flag.lock == 1 && isvoid(@.subc)")} }
				-
				ha:Move selected subcircuits to other side= { a={<key>s; <key>f;} action=Flip(SelectedElements) }
				ha:Move selected objects to current layer = { a={<key>s; <key>l;} action=MoveToCurrentLayer(Selected) }
				ha:Remove selected objects                = { a={<key>s; <key>r;} action=RemoveSelected() }
				ha:Convert selection to subcircuit        = { a={<key>s; <key>c; <key>s;} action=Select(ConvertSubc) }
				ha:Convert selection to padstack          = { a={<key>s; <key>c; <key>p;} li:action={PadstackConvert(selected); Tool(buffer);} }
				ha:Convert selection to extended object...= { a={<key>s; <key>c; <key>e;} action=ExtobjConvFrom(Selected, @gui); }
				ha:Break selection subcircuits to pieces  = { a={<key>s; <key>b; <key>s}; li:action={PasteBuffer(Push); PasteBuffer(5); PasteBuffer(Clear); PasteBuffer(AddSelected); RemoveSelected(); PasteBuffer(Restore); PasteBuffer(ToLayout, crosshair); PasteBuffer(Clear); PasteBuffer(Pop);} }
				ha:Break selection padstack to pieces     = { a={<key>s; <key>b; <key>p}; action=PadstackBreakup(selected) }
				ha:Change selected objects {
					li:submenu {
						ha:Lines -10 mil     = { li:action={ChangeSize(SelectedLines,-10,mil); ChangeSize(SelectedArcs,-10,mil)} }
						ha:Lines +10 mil     = { li:action={ChangeSize(SelectedLines,+10,mil); ChangeSize(SelectedArcs,+10,mil)} }
						ha:Texts -10 mil     = { action=ChangeSize(SelectedTexts,-10,mil) }
						ha:Texts +10 mil     = { action=ChangeSize(SelectedTexts,+10,mil) }
						-
						ha:Clearance +2 mil  = { action=ChangeClearSize(SelectedObjects,+2,mil) }
						ha:Clearance -2 mil  = { action=ChangeClearSize(SelectedObjects,-2,mil) }
						-
						ha:Hole -10 mil      = { action=ChangeDrillSize(SelectedPadstacks,-10,mil) }
						ha:Hole +10 mil      = { action=ChangeDrillSize(SelectedPadstacks,+10,mil) }
						-
						ha:Toggle join       = { action=ChangeJoin(SelectedObjects) }
						-
						ha:Apply Pen         = { a={<key>s; <key>a; <key>p}; action=ApplyPen(selected) }
						ha:Replace selected padstacks {
							li:submenu {
								ha:with via tool's padstack      = { action=PadstackReplace(selected, tool) }
								ha:with first padstack in buffer = { action=PadstackReplace(selected, buffer) }
							}
						}
						-
						ha:Edit properties   = { a={<key>s; <key>p}; action=propedit(selection) }
					}
				}
			}
		} # Select

		ha:Buffer {
			li:submenu {
				ha:Rotate buffer 90 deg CCW (left)  = { li:a={{<key>b;<key>r;<key>l}; {Shift<Key>F7};}; li:action={Tool(buffer); PasteBuffer(Rotate,1)} }
				ha:Rotate buffer 90 deg CW (right)  = { a={<key>b;<key>r;<key>r}; li:action={Tool(buffer); PasteBuffer(Rotate,3)} }
				ha:Arbitrarily Rotate Buffer  = { a={<key>b;<key>r;<key>a}; li:action={Tool(buffer); FreeRotateBuffer()} }
				ha:Mirror buffer (up/down)    = { a={<key>b;<key>m;<key>u}; li:action={Tool(buffer); PasteBuffer(Mirror)} }
				ha:Mirror buffer (left/right) = { a={<key>b;<key>m;<key>l}; li:action={Tool(buffer); PasteBuffer(Rotate,1); PasteBuffer(Mirror); PasteBuffer(Rotate,3)} }
				ha:Scale                      = { action=ScaleBuffer(); }
				ha:Normalize                  = { a={<key>b;<key>n}; li:action={Tool(buffer); PasteBuffer(Rotate,1); PasteBuffer(Normalize);} }
				-
				ha:Clear buffer                    = { a={<key>b;<key>c;<key>c;}; action=PasteBuffer(Clear) }
				ha:Save buffer content to file     = { a={<key>b;<key>f;<key>s;}; action=PasteBuffer(SaveAll) }
				ha:Load buffer content from file   = { a={<key>b;<key>f;<key>l;}; li:action={PasteBuffer(Clear); PasteBuffer(LoadAll)} }
				-
				ha:Convert buffer to subcircuit    = { a={<key>b;<key>c;<key>s}; action=PasteBuffer(ConvertSubc) }
				ha:Convert buffer to padstack      = { a={<key>b;<key>c;<key>p}; li:action={PadstackConvert(buffer); Tool(buffer);} }
				ha:Convert buffer to extended object... = { a={<key>b;<key>c;<key>e}; li:action={ExtobjConvFrom(buffer, @gui); Tool(buffer);} }
				ha:Break buffer subcircuits to pieces = { a={<key>b;<key>s;<key>b};  action=PasteBuffer(Restore) }
				ha:Break buffer padstacks to pieces = { a={<key>b;<key>s;<key>p};  action=PadstackBreakup(buffer) }
				ha:Save buffer subcircuit to file   = { a={<key>b;<key>s;<key>s}; action=Save(PasteBuffer); tip={save one subcircuits from the buffer as a footprint file} }
				ha:Save buffer subcircuits as lib... {
					li:submenu {
						ha:in a single lib file          = { a={<key>b;<key>s;<key>l;<key>f}; action=SaveLib(file, buffer); tip={save all subcircuits from the buffer as a footprint lib in a library file} }
						ha:in multiple footprint files   = { a={<key>b;<key>s;<key>l;<key>d}; action=SaveLib(dir, buffer); tip={save all subcircuits from the buffer in individual, numbered files} }
					}
				}
				ha:Save buffer padstack to file      = { a={<key>b;<key>s;Shift<key>p}; action=PadstackSave(Buffer); tip={save one padstack from the buffer as a padstack file} }
				-
				ha:Layer bindings...               = { a={<key>b;<key>b;}; action=LayerBinding(buffer) }
				ha:Buffer selection {
					li:submenu {
						ha:Select Buffer \#1 = { checked=ChkBuffer(1); a={<key>b;<Key>1;} action=PasteBuffer(1); update_on={editor/buffer_number} }
						ha:Select Buffer \#2 = { checked=ChkBuffer(2); a={<key>b;<Key>2;} action=PasteBuffer(2); update_on={editor/buffer_number} }
						ha:Select Buffer \#3 = { checked=ChkBuffer(3); a={<key>b;<Key>3;} action=PasteBuffer(3); update_on={editor/buffer_number} }
						ha:Select Buffer \#4 = { checked=ChkBuffer(4); a={<key>b;<Key>4;} action=PasteBuffer(4); update_on={editor/buffer_number} }
						ha:Select scratchpad = { checked=ChkBuffer(5); a={<key>b;<Key>5;} action=PasteBuffer(5); update_on={editor/buffer_number} }
					}
				}
			}
		} # Buffer

		ha:Connects = {
			li:submenu {
				ha:Rats nest {
					li:submenu {
						ha:Optimize rats nest                    = { a={<key>c;<key>r;}; li:action={Atomic(Save); DeleteRats(AllRats); Atomic(Restore); AddRats(AllRats); Atomic(Close)} }
						ha:Optimize rats nest - autorouter       = { a={<key>c;Shift<key>r;}; li:action={Atomic(Save); DeleteRats(AllRats); Atomic(Restore); AddRats(AllRats, manhattan); Atomic(Close)} }
						ha:Erase rats nest                       = { a={<key>c;<key>e;}; action=DeleteRats(AllRats) }
						-
						ha:Select shortest rat                   = { a={<key>c;<key>s;}; action=AddRats(Close) }
						ha:AddRats to selected pins              = { li:action={Atomic(Save); DeleteRats(AllRats); Atomic(Restore); AddRats(SelectedRats); Atomic(Close)} }
						ha:AddRats Selected                      = { action=AddRats(SelectedRats) }
						ha:Add All Rats                          = { action=AddRats(AllRats) }
					}
				}
				ha:Network lengths {
					li:submenu {
						ha:Visual length, from object             = { a={<key>n;<key>l;<key>o;}; action=NetLength(object) }
						ha:Visual length, clear                   = { a={<key>n;<key>l;<key>k;}; action=NetLength(clear) }
						ha:Netlist dialog, refresh lengths        = { a={<key>n;<key>l;<key>l;}; li:action={NetlistDialog(); NetlistDialog(RefreshNetLens);}}
					}
				}
				-
				ha:Find Connections                          = { a={<key>c;<key>f;}; li:action={Connection(Reset); Connection(Find)} }
				ha:Clear/reset lookup                        = { a={<key>c;<key>c;}; li:action={Connection(Reset); Display(Redraw)} }
				-
				ha:Del/Remove Connected                      = { a={<key>c;<key>d;}; li:action={Atomic(Save); Connection(Reset); Atomic(Restore); Unselect(All); Atomic(Restore); Connection(Find); Atomic(Restore); Select(Connection); Atomic(Restore); RemoveSelected(); Atomic(Restore); Connection(Reset); Atomic(Restore); Unselect(All); Atomic(Block)} }
				-
				ha:Subcircuit Placement {
					li:submenu {
						ha:Auto-place selected subcircuits       = { a={<key>a;<key>p;<key>s;}; action=AutoPlaceSelected() }
						ha:Disperse all subcircuits              = { a={<key>a;<key>d;<key>a;}; action=DisperseElements(All) }
						ha:Disperse selected subcircuits         = { a={<key>a;<key>d;<key>s;}; action=DisperseElements(Selected) }
					}
				}
				ha:Automatic Routing {
					li:submenu {
						ha:Auto-route selected rats              = { a={<key>a;<key>r;<key>s;}; action=AutoRoute(SelectedRats) }
						ha:Auto-route all rats                   = { a={<key>a;<key>r;<key>a;}; action=AutoRoute(AllRats) }
						@autoroute
						ha:Rip up selected auto-routed tracks    = { a={<key>a;<key>r;<key>t;}; action=RipUp(Selected) }
						ha:Rip up all auto-routed tracks         = { a={<key>a;<key>r;<key>r;}; action=RipUp(All) }
					}
				}
				ha:Optimize routed tracks {
					li:submenu {
					}
				}
				-
				ha:Design Rule Checker = { a={<key>a;<key>x;}; action=DRC() }
				-
				ha:Design changes (back annotation) {
					li:submenu {
						ha:Swap nets on two selected pins  = { a={<key>a;<key>b;<key>s;}; action=net(swap) }
						ha:Replace footprint               = { a={<key>a;<key>b;<key>f;}; action=ReplaceFootprint() }
						-
						ha:claim net by object             = { a={<key>n;<key>c;<key>o;}; action=ClaimNet(object) }
						ha:claim net on found              = { a={<key>n;<key>c;<key>f;}; action=ClaimNet(found) }
						ha:claim net on selected           = { a={<key>n;<key>c;<key>s;}; action=ClaimNet(selected) }
					}
				}
			}
		} # Connects
	
		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:Library        = { a={<Key>w;<Key>l}; action=LibraryDialog() }
				ha:Message Log    = { a={<Key>w;<Key>m}; action=LogDialog() }
				ha:DRC Check      = { a={<Key>w;<Key>d}; action=DRC() }
				ha:Netlist        = { a={<Key>w;<Key>n}; action=NetlistDialog() }
				ha:Command Entry  = { li:a={a={<Key>w;<Key>c}; {<char>:};}  action=Command() }
				ha:Pinout         = { a={<Key>w;<Key>p}; action=Display(Pinout) }
				ha:Font selector  = { a={<Key>w;<Key>f};  action=FontSel() }
				-
				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>w;<Key>a}; {<key>i;<key>a};}; action=About() }
			}
		} # Window
	} # main menu

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

		ha:popup-obj-line {
			li:submenu {
				ha:Edit properties        { action=propedit(object) }
				ha:Edit flags...          { action=FlagEdit() }
				ha:Set Same Style         { action=SetSame() }
				ha:Convert to extended object... = { action=ExtobjConvFrom(Object, @gui) }
				-
				ha:Remove line            { li:action={Tool(Save); Tool(remove); Tool(Press); Tool(Restore)} }
				ha:Copy to buffer         { li:action={Unselect(All); Select(object); PasteBuffer(Clear); PasteBuffer(AddSelected); Unselect(All); Tool(buffer) } }
				ha:Move to current layer  { action=MoveToCurrentLayer(object) }
			}
		}

		ha:popup-obj-arc {
			li:submenu {
				ha:Edit properties        { action=propedit(object) }
				ha:Edit flags...          { action=FlagEdit() }
				ha:Set Same Style         { action=SetSame() }
				ha:Convert to extended object... = { action=ExtobjConvFrom(Object, @gui) }
				-
				ha:Remove arc             { li:action={Tool(Save); Tool(remove); Tool(Press); Tool(Restore)} }
				ha:Copy to buffer         { li:action={Unselect(All); Select(object); PasteBuffer(Clear); PasteBuffer(AddSelected); Unselect(All); Tool(buffer) } }
				ha:Move to current layer  { action=MoveToCurrentLayer(object) }
			}
		}

		ha:popup-obj-polygon {
			li:submenu {
				ha:Edit properties        { action=propedit(object) }
				ha:Edit flags...          { action=FlagEdit() }
				ha:Convert to extended object... = { action=ExtobjConvFrom(Object, @gui) }
				-
				ha:Remove polygon         { li:action={Tool(Save); Tool(remove); Tool(Press); Tool(Restore)} }
				ha:Copy to buffer         { li:action={Unselect(All); Select(object); PasteBuffer(Clear); PasteBuffer(AddSelected); Unselect(All); Tool(buffer) } }
				ha:Move to current layer  { action=MoveToCurrentLayer(object) }
			}
		}

		ha:popup-obj-text {
			li:submenu {
				ha:Edit properties        { action=propedit(object) }
				ha:Edit flags...          { action=FlagEdit() }
				ha:Edit text...           { action=ChangeName(Object) }
				ha:Set Same Style         { action=SetSame() }
				ha:Convert to extended object... = { action=ExtobjConvFrom(Object, @gui) }
				ha:Change font...         { li:a={{<key>e;<key>o};}   action=FontSel(Object) }
				ha:Toggle tight clearance { action=PropToggle(object, a/tight_clearance, true); }
				-
				ha:Remove text            { li:action={Tool(Save); Tool(remove); Tool(Press); Tool(Restore)} }
				ha:Copy to buffer         { li:action={Unselect(All); Select(object); PasteBuffer(Clear); PasteBuffer(AddSelected); Unselect(All); Tool(buffer) } }
				ha:Move to current layer  { action=MoveToCurrentLayer(object) }
			}
		}

		ha:popup-obj-padstack {
			li:submenu {
				ha:Edit properties        { action=propedit(object) }
				ha:Edit geometry/prototype {action=padstackedit }
				ha:Edit flags...          { action=FlagEdit() }
				ha:Set Same Style         { action=SetSame() }
				ha:Replace padstack {
					li:submenu {
						ha:with via tool's padstack      = { action=PadstackReplace(object, tool) }
						ha:with first padstack in buffer = { action=PadstackReplace(object, buffer) }
					}
				}
				-
				ha:Remove padstack        { li:action={Tool(Save); Tool(remove); Tool(Press); Tool(Restore)} }
				ha:Break up padstack      { action=PadstackBreakup(object) }
				ha:Copy to buffer         { li:action={Unselect(All); Select(object); PasteBuffer(Clear); PasteBuffer(AddSelected); Unselect(All); Tool(buffer) } }
			}
		}

		ha:popup-obj-padstack-in-subc {
			li:submenu {
				ha:Edit properties        { action=propedit(object) }
				ha:Edit geometry/prototype {action=padstackedit }
				ha:Set Same Style         { action=SetSame() }
				ha:Replace padstack {
					li:submenu {
						ha:with via tool's padstack      = { action=PadstackReplace(object, tool) }
						ha:with first padstack in buffer = { action=PadstackReplace(object, buffer) }
					}
				}
			}
		}

		ha:popup-obj-subcircuit {
			li:submenu {
				ha:Edit properties        { action=propedit(object) }
				ha:External editor...     { action=extedit(object) }
				ha:Edit flags...          { action=FlagEdit() }
				ha:Edit layer bindings... { action=LayerBinding() }
				ha:Change refdes          { li:a={{<key>e;<key>r};};  action=ChangeName(Refdes) }
				ha:Edit padstack prototypes... = { action=pstklib(object) }
				ha:Convert back to extended object { action=ExtobjToggle(object) }

#TODO: replace from lib
				-
				ha:Remove subcircuit      { li:action={Tool(Save); Tool(remove); Tool(Press); Tool(Restore)} }
				ha:Copy to buffer         { li:action={Unselect(All); Select(object); PasteBuffer(Clear); PasteBuffer(AddSelected); Unselect(All); Tool(buffer) } }
				ha:Move to other side     { action=Flip(object) }
			}
		}

		ha:popup-obj-extobj-subcircuit {
			li:submenu {
				ha:Edit extobj properties (generic)   { action=propedit(subc) }
				ha:Edit extobj properties (specific)  { action=ExtobjGUIPropEdit(object) }
				ha:Edit extobj layer bindings...      { action=LayerBinding() }
				ha:Edit extobjpadstack prototypes...  { action=pstklib(object) }
				ha:Convert to plain subcircuit        { action=ExtobjToggle(object) }
			}
		}

		ha:popup-obj-gfx {
			li:submenu {
				ha:Edit properties        { action=propedit(object) }
				ha:Edit flags...          { action=FlagEdit() }
				-
				{ha:Render level: under}       { action=propset(object, "a/render_level", "under") }
				{ha:Render level: above}       { action=propset(object, "a/render_level", "above") }
				{ha:Set transparent pixel...}  { action=GfxMod(transparent) }
				{ha:Resize to measured...}     { action=GfxMod(resize) }
				-
				ha:Remove gfx             { li:action={Tool(Save); Tool(remove); Tool(Press); Tool(Restore)} }
				ha:Copy to buffer         { li:action={Unselect(All); Select(object); PasteBuffer(Clear); PasteBuffer(AddSelected); Unselect(All); Tool(buffer) } }
				ha:Move to current layer  { action=MoveToCurrentLayer(object) }
			}
		}


		ha:popup-obj-misc {
			li:submenu {
				ha:Operations on selections {
					li:submenu {
						ha:Unselect all objects               = { action=Unselect(All) }
						ha:Remove selected objects            = { action=RemoveSelected() }
						ha:Copy selection to buffer           = { li:action={GetXY(Click to set the snap point for this buffer); PasteBuffer(Clear); PasteBuffer(AddSelected); Tool(buffer)} }
						ha:Cut selection to buffer            = { li:action={GetXY(Click to set the snap point for this buffer); PasteBuffer(Clear); PasteBuffer(AddSelected); RemoveSelected(); Tool(buffer)} }
						ha:Convert selection to subcircuit    = { action=Select(ConvertSubc) }
						ha:Convert selection to extended object... = { action=ExtobjConvFrom(selected, @gui) }
						ha:Auto place selected subcircuits    = { action=AutoPlaceSelected() }
						ha:Autoroute selected subcircuits     = { action=AutoRoute(SelectedRats) }
						ha:Rip up selected auto-routed tracks = { action=RipUp(Selected) }
						ha:Rotate selected                    = { action={GetXY(Click to set the snap point for this buffer); PasteBuffer(Clear); PasteBuffer(AddSelected); RemoveSelected(); Tool(buffer) FreeRotateBuffer(); Tool(buffer); PasteBuffer(Tolayout, crosshair); } }
					}
				}
				ha:Operations on this location {
					li:submenu {
						ha:Generate object report = { li:action={GetXY(Click on the object); Report(Object)} }
					}
				}
				-
				ha:Undo last operation          = { action=Undo() }
				ha:Redo last undone operation   = { action=Redo() }
			}
		} # popup-obj-misc

		ha:layer {
			li:submenu {
				ha:Layer name and flags...          = { action=EditLayer() }
				ha:Layer properties...              = { action=Propedit(layer) }
				ha:Grouping... (layer preferences)  = { action=Preferences("layers") }
				ha:Hotkey {
					li:submenu {
						ha:Selection...                 = { action=LayerHotkey("&current", select) }
						ha:Visibility...                = { action=LayerHotkey("&current", vis) }
					}
				}
				ha:transformations {
					li:submenu {
						ha:Toggle wireframe             = { action={LayerXform(&current, toggle, wireframe)} }
						ha:Toggle thindraw              = { action={LayerXform(&current, toggle, thindraw)} }
					}
				}
				-
				ha:Move up (within group)           = { action=MoveLayer(c, step-) }
				ha:Move down (within group)         = { action=MoveLayer(c, step+) }
				-
				ha:Remove layer                     = { action=MoveLayer(c, -1) }
				ha:Insert new, before this layer    = { action={ MoveLayer(-1, c); EditLayer() } }
				ha:Insert new, after this layer     = { action={ Undo(FreezeSerial); MoveLayer(-1, c); MoveLayer(c, step+); Undo(UnFreezeSerial); Undo(IncSerial); EditLayer() } }
				-
				ha:all layers on                    = { a={<key>l;<key>v;}; action=ToggleView(all, vis, set) }
				ha:all layers off                   = { a={<key>l;<key>h;}; action=ToggleView(all, vis, clear) }
			}
		} # layer

		ha:group {
			li:submenu {
				ha:Group name & type...             = { action=EditGroup(@) }
				ha:Group properties...              = { action={Propedit(layergrp:editgroup)} }
				ha:Grouping... (layer preferences)  = { action=Preferences("layers") }
				-
				ha:Duplicate group                  = { action={ DupGroup(@) } }
				ha:Create new group {
					li:submenu {
						ha:Boundary (board outline) {
							li:submenu {
								ha:Boundary, unplated, routed   = { action={ NewGroup(boundary, global, uroute) } }
								ha:Boundary, plated, routed     = { action={ NewGroup(boundary, global, proute) } }
								ha:Boundary, unplated, cut      = { action={ NewGroup(boundary, global, ucut) } }
								ha:Boundary, unplated, vcut     = { action={ NewGroup(boundary, global, uvcut) } }
							}
						}
						ha:Slots, cutouts, adhesive, finish {
							li:submenu {
								ha:Slot, unplated, routed       = { action={ NewGroup(mech, global, uroute, auto) } }
								ha:Slot, plated, routed         = { action={ NewGroup(mech, global, proute, auto) } }
								ha:Adhesive, top side           = { action={ NewGroup(mech, top, adhesive, -, top-adhesive) } }
								ha:Adhesive, bottom side        = { action={ NewGroup(mech, bot, adhesive, -, bot-adhesive) } }
								ha:Gold finish, top side        = { action={ NewGroup(mech, top, finish.gold, -, top-gold) } }
								ha:Gold finish, bottom side     = { action={ NewGroup(mech, bot, finish.gold, -, bot-gold) } }
								ha:Carbon finish, top side      = { action={ NewGroup(mech, top, finish.carbon, -, top-carbon) } }
								ha:Carbon finish, bottom side   = { action={ NewGroup(mech, bot, finish.carbon, -, bot-carbon) } }
							}
						}
						ha:Keepouts {
							li:submenu {
								ha:Courtyard (comp. body), top    = { action={ NewGroup(doc, top, ko.courtyard, -, top-courtyard, "init-invis=true") } }
								ha:Courtyard (comp. body), bottom = { action={ NewGroup(doc, bottom, ko.courtyard, -, bot-courtyard, "init-invis=true") } }
								ha:Copper, top side               = { action={ NewGroup(doc, top, ko@top-copper, -, top-copper-ko, "init-invis=true") } }
								ha:Copper, bottom side            = { action={ NewGroup(doc, bottom, ko@bottom-copper, -, bot-copper-ko, "init-invis=true") } }
								ha:Silk, top side                 = { action={ NewGroup(doc, top, ko@top-silk, -, top-silk-ko, "init-invis=true") } }
								ha:Silk, bottom side              = { action={ NewGroup(doc, bottom, ko@bottom-silk, -, bot-silk-ko, "init-invis=true") } }
								ha:Mask, top side                 = { action={ NewGroup(doc, top, ko@top-mask, -, top-mask-ko, "init-invis=true") } }
								ha:Mask, bottom side              = { action={ NewGroup(doc, bottom, ko@bottom-mask, -, bot-mask-ko, "init-invis=true") } }
								ha:Paste, top side                = { action={ NewGroup(doc, top, ko@top-paste, -, top-paste-ko, "init-invis=true") } }
								ha:Paste, bottom side             = { action={ NewGroup(doc, bottom, ko@bottom-paste, -, bot-paste-ko, "init-invis=true") } }
							}
						}
						ha:Fab & assy {
							li:submenu {
								ha:assy, top side               = { action={ NewGroup(doc, top, assy, -, top-assy, "init-invis=true") } }
								ha:assy, bottom side            = { action={ NewGroup(doc, bottom, assy, -, bot-assy, "init-invis=true") } }
								ha:fab, top side                = { action={ NewGroup(doc, top, fab, auto, fab, "init-invis=true") } }
							}
						}
						ha:Doc, misc {
							li:submenu {
								ha:Doc, top side                = { action={ NewGroup(doc, top) } }
								ha:Doc, bottom side             = { action={ NewGroup(doc, bottom) } }
								ha:Doc, global                  = { action={ NewGroup(doc, global) } }
								ha:placement, top side          = { action={ NewGroup(doc, top, placement, -, top-place, "init-invis=true") } }
								ha:placement, bottom side       = { action={ NewGroup(doc, bottom, placement, -, bot-place, "init-invis=true") } }
								ha:placement, global            = { action={ NewGroup(doc, global, placement, -, place, "init-invis=true") } }
							}
						}
						ha:Physical (silk, mask, paste) {
							li:submenu {
								ha:Top paste                    = { action={ NewGroup(paste, top, "", auto, "top_paste", "", unique_first) } }
								ha:Top silk                     = { action={ NewGroup(silk, top, "", auto, "top_silk", "", unique_first) } }
								ha:Top mask                     = { action={ NewGroup(mask, top, "", auto, "top_mask", "", unique_first) } }
								ha:Bottom mask                  = { action={ NewGroup(mask, bottom, "", auto, "bottom_mask", "", unique_last) } }
								ha:Bottom silk                  = { action={ NewGroup(silk, bottom, "", auto, "bottom_silk", "", unique_last) } }
								ha:Bottom paste                 = { action={ NewGroup(paste, bottom, "", auto, "bottom_paste", "", unique_last) } }
							}
						}

					}
				}
				ha:Remove group                     = { action={ DelGroup(@) } }
				-
				ha:Insert new layer                 = { action={ MoveLayer(-1, gi); EditLayer() } }
				ha:Append new layer                 = { action={ MoveLayer(-1, ga); EditLayer() } }
				-
				ha:expand groups                    = { action=ToggleView(all, open, set) }
				ha:collapse groups                  = { action=ToggleView(all, open, clear) }
				ha:all layers on                    = { action=ToggleView(all, vis, set) }
				ha:all layers off                   = { action=ToggleView(all, vis, clear) }
			}
		} # group

	} # 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/live_routing, 0, design);
			conf(set, editor/wireframe_draw, 0, design);
			conf(set, editor/wireframe_draw, 0, design);
			conf(set, editor/thin_draw, 0, design);
			conf(set, editor/thin_draw_poly, 0, design);
			conf(set, editor/as_drawn_poly, 0, design);
			conf(set, editor/check_planes, 0, design);
			conf(set, editor/lock_names, 0, design);
			conf(set, editor/only_names, 0, design);
			conf(set, editor/hide_names, 0, design);
			conf(set, appearance/invis_other_groups, 0, design);
			conf(set, appearance/black_current_group, 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}
			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);
			Display(SubcID, "%a.refdes%");
			Display(TermID, "%a.term%");
			conf(set, editor/all_direction_lines, 0, design);
			conf(set, editor/auto_drc, 0, design);
			conf(set, editor/rubber_band_mode, 0, design);
			conf(set, editor/orthogonal_moves, 0, design);
			conf(set, editor/snap_pin, 1, design);
			conf(set, editor/snap_offgrid_line, 1, design);
			conf(set, editor/show_drc, 0, design);
			conf(set, editor/highlight_on_point, 0, design);
			subc(loose, off);
			Tool(arrow);
			Display(Redraw);
		}
	}
} # root
