Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion src/components/Controls/Fields/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ const Input = ({
disabled,
prec,
shortkey,
...rest
multiline = false,
rows = 8,
...rest
}) => {
const { interfaceSettings, connectionSettings } = useSettingsContext()
const dependIds = generateDependIds(
Expand Down Expand Up @@ -327,7 +329,34 @@ const Input = ({
//but this is a quick fix
let classAddition = ""
if (rest.class) classAddition = rest.class.replace("form-input", "")

if (multiline) {
return (
<div
class={`input-group ${inline ? "column" : ""} ${
button ? "has-button-submit" : "no-button-submit"
} ${help ? "tooltip" : ""}`}
data-tooltip={T(help)}
>
<textarea
id={id}
name={id}
value={value}
disabled={disabled}
rows={rows}
spellcheck="false"
autocorrect="off"
autocomplete="off"
class={`form-input ${classAddition}`}
{...rest}
onInput={onInput}
/>
{button}
</div>
)
}

return (
<div
class={`input-group ${inline ? "column" : ""} ${
button ? "has-button-submit" : "no-button-submit"
Expand Down
22 changes: 15 additions & 7 deletions src/components/Panels/Macros.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,21 @@ const MacrosPanel = () => {
window.open(action)
}
break
case "CMD":
//split by ; and show in terminal
const commandsList = action.trim().split(";")
commandsList.forEach((command) => {
sendCommand(command)
})
break
case "CMD": {
// Newline-delimited macros preserve semicolon G-code comments. Existing
// one-line macros keep their legacy semicolon-separated behavior.
const macroText = String(action || "").replace(/\r\n?/g, "\n").trim()
const commandsList = (macroText.includes("\n")
? macroText.split("\n")
: macroText.split(";"))
.map((command) => command.trim())
.filter((command) => command.length > 0)

commandsList.forEach((command) => {
sendCommand(command)
})
break
}
default:
console.log("type:", type, " action:", action)
break
Expand Down
6 changes: 6 additions & 0 deletions src/tabs/interface/importHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ function formatItem(itemData, index = -1, origineId = "extrapanels") {
newItem.type = "text"
newItem.label = "S159"
newItem.min = "1"
// The action field is G-code for CMD macros; keep all macro actions editable
// as a textarea so switching the macro type does not require a reload.
if (origineId == "macros") {
newItem.multiline = true
newItem.rows = 8
}
break
case "value":
newItem.type = "text"
Expand Down
Loading