void EditorScreen::moveUp() { // Re-init insert mode _insertMode = false; _cursorMode = getCursorMode(); if (!_lines.count()) { restartBlink(); return; } const TextLine &textLine = _lines[_cursorLineIndex]; if (_cursorOffset < 16) { // Previous line? if (_cursorLineIndex > _editZoneTopLineIndex) { TextLine &previousLine = _lines[_cursorLineIndex - 1]; int previousOffset = (previousLine.rowCount() - 1) * 16 + _cursorOffset; if (!previousLine.cursorCanMoveRight(previousOffset)) moveCursor(_cursorLineIndex - 1, previousLine.maximumCursorPosition()); else moveCursor(_cursorLineIndex - 1, previousLine.offsetAt(previousLine.entityAt(previousOffset))); } else moveCursor(_cursorLineIndex, 0); } else { int upIndex = textLine.entityAt(_cursorOffset - 16); moveCursor(_cursorLineIndex, textLine.offsetAt(upIndex)); } }
void EditorScreen::moveRight() { // Re-init insert mode _insertMode = false; _cursorMode = getCursorMode(); if (!_lines.count()) { restartBlink(); return; } const TextLine &textLine = _lines[_cursorLineIndex]; if (_cursorLineIndex >= _lines.count() - 1 && !textLine.cursorCanMoveRight(_cursorOffset)) { restartBlink(); return; } int newCursorLineIndex = _cursorLineIndex; int newCursorOffset; if (!textLine.cursorCanMoveRight(_cursorOffset)) { newCursorLineIndex++; newCursorOffset = 0; } else newCursorOffset = textLine.offsetAt(textLine.entityAt(_cursorOffset) + 1); moveCursor(newCursorLineIndex, newCursorOffset); }
void EditorScreen::moveLeft() { // Re-init insert mode _insertMode = false; _cursorMode = getCursorMode(); if (_cursorLineIndex == _editZoneTopLineIndex && !_cursorOffset) { restartBlink(); return; } const TextLine &textLine = _lines[_cursorLineIndex]; int newCursorLineIndex = _cursorLineIndex; int newCursorOffset; if (!_cursorOffset) { newCursorLineIndex--; newCursorOffset = _lines[newCursorLineIndex].charLength(); if (_lines[newCursorLineIndex].isBreakerEndedLine()) newCursorOffset--; } else if (textLine.charLength() && _cursorOffset >= textLine.charLength()) newCursorOffset = textLine.offsetAt(textLine.count() - 1); else newCursorOffset = textLine.offsetAt(textLine.entityAt(_cursorOffset) - 1); moveCursor(newCursorLineIndex, newCursorOffset); }
void EditorScreen::insertClicked() { if (_insertMode) // We deactivate insert mode { _insertMode = false; _cursorMode = getCursorMode(); } else { // No insert mode when we are at the end of the text if (_lines.count() && (_cursorLineIndex < _lines.count() - 1 || _cursorOffset < _lines[_cursorLineIndex].charLength())) { _insertMode = true; _cursorMode = getCursorMode(); } } // Annihilate all key mode BUT ShiftAlpha if (CalculatorState::instance().keyMode() != KeyMode_ShiftAlpha) CalculatorState::instance().setKeyMode(KeyMode_Normal); restartBlink(); }
void EditorScreen::moveDown() { // Re-init insert mode _insertMode = false; _cursorMode = getCursorMode(); if (!_lines.count()) { restartBlink(); return; } const TextLine &textLine = _lines[_cursorLineIndex]; if (_cursorOffset + 16 < textLine.charLength()) { int downIndex = textLine.entityAt(_cursorOffset + 16); int downOffset = textLine.offsetAt(downIndex); if (downOffset == _cursorOffset + 16) moveCursor(_cursorLineIndex, _cursorOffset + 16); else moveCursor(_cursorLineIndex, textLine.offsetAt(downIndex + 1)); } else if (_cursorOffset + 16 == textLine.charLength()) moveCursor(_cursorLineIndex, textLine.maximumCursorPosition()); else { if (_cursorLineIndex == _lines.count() - 1 || _cursorOffset / 16 < textLine.rowCount() - 1) moveCursor(_cursorLineIndex, textLine.maximumCursorPosition()); else { // To the next line TextLine &nextLine = _lines[_cursorLineIndex + 1]; int nextOffset = _cursorOffset % 16; int downIndex = nextLine.entityAt(nextOffset); int downOffset = nextLine.offsetAt(downIndex); if (downOffset == nextOffset) moveCursor(_cursorLineIndex + 1, nextLine.maximumCursorPositionIfTooHigh(nextOffset)); else moveCursor(_cursorLineIndex + 1, nextLine.maximumCursorPositionIfTooHigh(nextLine.offsetAt(downIndex + 1))); } } }
void AspFrame::deleteRoi() { double c1,c2; double reffrq = getDefaultDataInfo()->haxis.scale; if(getCursorMode() == 2) { P_getreal(CURRENT, "cr", &c1, 1); P_getreal(CURRENT, "delta", &c2, 1); c2 = c1 -c2; if (reffrq>0) { c1 /= reffrq; c2 /= reffrq; } roiList->deleteRoi(c1,c2); } else { P_getreal(CURRENT, "cr", &c1, 1); if (reffrq>0) { c1 /= reffrq; } roiList->deleteRoi(c1); } displayTop(); }
void AspFrame::addRoiFromCursors() { if(getCursorMode() != 2) { Winfoprintf("Try again after selecting second cursor with right mouse button."); return; } spAspDataInfo_t dataInfo = getDefaultDataInfo(); if(dataInfo->vaxis.rev) { // 1D band double c1,c2; P_getreal(CURRENT, "cr", &c1, 1); P_getreal(CURRENT, "delta", &c2, 1); c2 = c1 - c2; double reffrq = dataInfo->haxis.scale; if (reffrq>0) { c1 /= reffrq; c2 /= reffrq; } addRoiFromCursors(c1,c2); } else { // 2D box double c11,c12,c21,c22; P_getreal(CURRENT, "cr", &c11, 1); P_getreal(CURRENT, "delta", &c12, 1); c12 = c11 - c12; double reffrq = dataInfo->haxis.scale; if (reffrq>0) { c11 /= reffrq; c12 /= reffrq; } P_getreal(CURRENT, "cr1", &c21, 1); P_getreal(CURRENT, "delta1", &c22, 1); c22 = c21 - c22; double reffrq1 = dataInfo->vaxis.scale; if (reffrq1>0) { c21 /= reffrq1; c22 /= reffrq1; } addRoiFromCursors(c11,c12,c21,c22); } }
void EditorScreen::keyModeChanged(KeyMode) { setCursorMode(getCursorMode()); restartBlink(); }