@@ -893,6 +893,55 @@ local function attachMacroLineBuilder(widget, menuOwner, opts)
893893 local NEEDS_CMD = L [" Start the line with a command first." ]
894894 local rowHasCmd = currentLineText ():match (" ^%s*/%S" ) ~= nil
895895
896+ -- Macros / GSE Variables live at the BOTTOM of the menu; they must
897+ -- be ALONE in the block, so they are emitted on both paths.
898+ local function addNameEntries ()
899+ if macroMode then
900+ -- These land as their OWN LINE rather than replacing the box.
901+ -- No Macros section: a managed-macro name is a block-only
902+ -- construct (a block may BE a macro name), meaningless as a
903+ -- line of WoW macro text.
904+ local function insertLine (content )
905+ local blankRow = currentLineText ():match (" ^%s*$" ) ~= nil
906+ splice (lineEndPos (), 0 , (blankRow and " " or " \n " ) .. content )
907+ editBox .gseTabSessionUntil = 0
908+ return MenuResponse .Close
909+ end
910+ if offerVariables then
911+ local vars = rootDescription :CreateButton (L [" GSE Variables" ])
912+ for k , _ in pairs (GSEVariables or {}) do
913+ vars :CreateButton (k , function () return insertLine ([[ =GSE.V["]] .. k .. [[ "]()]] ) end )
914+ end
915+ end
916+ if offerSequences then
917+ local seqs = rootDescription :CreateButton (L [" GSE Sequences" ])
918+ for _ , name in ipairs (getSequenceNames ()) do
919+ seqs :CreateButton (name , function () return insertLine (sequenceClickLine (name )) end )
920+ end
921+ end
922+ elseif liveHasText then
923+ greyed (rootDescription , L [" Macros" ], NAME_ONLY )
924+ greyed (rootDescription , L [" GSE Variables" ], NAME_ONLY )
925+ else
926+ local function setWhole (content )
927+ touchSession ()
928+ editBox :SetText (content )
929+ if editBox .SetCursorPosition then editBox :SetCursorPosition (# content ) end
930+ widget .gseRecolourToken = (widget .gseRecolourToken or 0 ) + 1
931+ editBox .gseTabSessionUntil = 0
932+ return MenuResponse .Close
933+ end
934+ local macros = rootDescription :CreateButton (L [" Macros" ])
935+ for _ , name in ipairs (getManagedMacroNames ()) do
936+ macros :CreateButton (name , function () return setWhole (name ) end )
937+ end
938+ local vars = rootDescription :CreateButton (L [" GSE Variables" ])
939+ for k , _ in pairs (GSEVariables or {}) do
940+ vars :CreateButton (k , function () return setWhole ([[ =GSE.V["]] .. k .. [[ "]()]] ) end )
941+ end
942+ end
943+ end
944+
896945 -- Undo sits at the top: a misclick is fixed without leaving the menu.
897946 if # history > 0 then
898947 rootDescription :CreateButton (L [" Undo Last" ], undoLast )
@@ -911,52 +960,6 @@ local function attachMacroLineBuilder(widget, menuOwner, opts)
911960 end
912961 end
913962
914- -- Macros / GSE Variables: must be ALONE in the block.
915- if macroMode then
916- -- These land as their OWN LINE rather than replacing the box.
917- -- No Macros section: a managed-macro name is a block-only
918- -- construct (a block may BE a macro name), meaningless as a
919- -- line of WoW macro text.
920- local function insertLine (content )
921- local blankRow = currentLineText ():match (" ^%s*$" ) ~= nil
922- splice (lineEndPos (), 0 , (blankRow and " " or " \n " ) .. content )
923- editBox .gseTabSessionUntil = 0
924- return MenuResponse .Close
925- end
926- if offerVariables then
927- local vars = rootDescription :CreateButton (L [" GSE Variables" ])
928- for k , _ in pairs (GSEVariables or {}) do
929- vars :CreateButton (k , function () return insertLine ([[ =GSE.V["]] .. k .. [[ "]()]] ) end )
930- end
931- end
932- if offerSequences then
933- local seqs = rootDescription :CreateButton (L [" GSE Sequences" ])
934- for _ , name in ipairs (getSequenceNames ()) do
935- seqs :CreateButton (name , function () return insertLine (sequenceClickLine (name )) end )
936- end
937- end
938- elseif liveHasText then
939- greyed (rootDescription , L [" Macros" ], NAME_ONLY )
940- greyed (rootDescription , L [" GSE Variables" ], NAME_ONLY )
941- else
942- local function setWhole (content )
943- touchSession ()
944- editBox :SetText (content )
945- if editBox .SetCursorPosition then editBox :SetCursorPosition (# content ) end
946- widget .gseRecolourToken = (widget .gseRecolourToken or 0 ) + 1
947- editBox .gseTabSessionUntil = 0
948- return MenuResponse .Close
949- end
950- local macros = rootDescription :CreateButton (L [" Macros" ])
951- for _ , name in ipairs (getManagedMacroNames ()) do
952- macros :CreateButton (name , function () return setWhole (name ) end )
953- end
954- local vars = rootDescription :CreateButton (L [" GSE Variables" ])
955- for k , _ in pairs (GSEVariables or {}) do
956- vars :CreateButton (k , function () return setWhole ([[ =GSE.V["]] .. k .. [[ "]()]] ) end )
957- end
958- end
959-
960963 if liveIsNameOrVar then
961964 -- the block holds a macro name / variable: nothing else may join it
962965 greyed (rootDescription , L [" Commands" ], TEXT_ONLY )
@@ -965,6 +968,7 @@ local function attachMacroLineBuilder(widget, menuOwner, opts)
965968 greyed (rootDescription , L [" Spells" ], TEXT_ONLY )
966969 greyed (rootDescription , " ;" , TEXT_ONLY )
967970 greyed (rootDescription , " , nil" , TEXT_ONLY )
971+ addNameEntries ()
968972 return
969973 end
970974
@@ -1028,6 +1032,8 @@ local function attachMacroLineBuilder(widget, menuOwner, opts)
10281032 else
10291033 greyed (rootDescription , " , nil" , L [" Only valid after a spell." ])
10301034 end
1035+
1036+ addNameEntries ()
10311037 end
10321038 openMenu ()
10331039 end )
0 commit comments