| 2366 | } |
| 2367 | |
| 2368 | void RcxEditor::validateEditLive() { |
| 2369 | QString lineText = getLineText(m_sci, m_editState.line); |
| 2370 | int delta = lineText.size() - m_editState.linelenAfterReplace; |
| 2371 | int editedLen = m_editState.original.size() + delta; |
| 2372 | QString text = (editedLen > 0) |
| 2373 | ? lineText.mid(m_editState.spanStart, editedLen).trimmed() : QString(); |
| 2374 | QString errorMsg = (m_editState.target == EditTarget::BaseAddress) |
| 2375 | ? fmt::validateBaseAddress(text) |
| 2376 | : fmt::validateValue(m_editState.editKind, text); |
| 2377 | |
| 2378 | const LineMeta* lm = metaForLine(m_editState.line); |
| 2379 | const bool isSelected = lm && m_currentSelIds.contains(lm->nodeId); |
| 2380 | const bool isValid = errorMsg.isEmpty(); |
| 2381 | |
| 2382 | // Only update comment when validation state changes (avoid lag) |
| 2383 | const bool stateChanged = (isValid != m_editState.lastValidationOk); |
| 2384 | m_editState.lastValidationOk = isValid; |
| 2385 | |
| 2386 | // Show/hide error marker (red background) |
| 2387 | // M_SELECTED has higher priority than M_ERR, so temporarily remove it when error |
| 2388 | if (isValid) { |
| 2389 | m_sci->markerDelete(m_editState.line, M_ERR); |
| 2390 | if (isSelected) m_sci->markerAdd(m_editState.line, M_SELECTED); |
| 2391 | if (stateChanged) setEditComment("Enter=Save Esc=Cancel"); |
| 2392 | } else { |
| 2393 | if (isSelected) m_sci->markerDelete(m_editState.line, M_SELECTED); |
| 2394 | m_sci->markerAdd(m_editState.line, M_ERR); |
| 2395 | if (stateChanged) setEditComment("! " + errorMsg); |
| 2396 | } |
| 2397 | } |
| 2398 | |
| 2399 | void RcxEditor::setCommandRowText(const QString& line) { |
| 2400 | if (m_sci->lines() <= 0) return; |
nothing calls this directly
no test coverage detected