//@doc SECEdit //@mfunc Internal function. Cuts the column of text from pStartPos to pEndPos, // from column pStartPos->iOffset to pEndPos->iOffset. //@rdesc int //@parm PTEXTPOS pStartPos //@parm PTEXTPOS pEndPos //@parm BOOL bSaveUndoRecord int SECEdit::ColumnCut(PTEXTPOS pStartPos, PTEXTPOS pEndPos, BOOL bSaveUndoRecord) { int iRval; UNDORECORD UndoRecord; LPSTR lpText; PLINEDESC pLine; TEXTPOS TextPos; TEXTPOS StartPos,EndPos; if (m_bReadOnly) return IDS_OE_READONLY; // column blocks may not be in order... if (!InOrder(pStartPos,pEndPos)) { StartPos = *pEndPos; EndPos = *pStartPos; } else { StartPos = *pStartPos; EndPos = *pEndPos; } iRval = 0; UndoRecord.iCol = StartPos.iOffset; UndoRecord.iEndCol = EndPos.iOffset; if (bSaveUndoRecord) { UndoRecord.iRow = GetLineNo(StartPos.pLine); UndoRecord.iEndRow = GetLineNo(EndPos.pLine); UndoRecord.iUndoType = OE_UNDO_COLUMNCUT; lpText = ColumnCopy(&StartPos, &EndPos, FALSE); } int iTabbedOffset = GetTabbedOffset(StartPos.pLine,StartPos.iOffset); int iCount = UndoRecord.iEndCol - UndoRecord.iCol; pLine = StartPos.pLine; while (pLine) { TextPos.pLine = pLine; TextPos.iOffset = GetRealOffset(TextPos.pLine,iTabbedOffset); iRval = DeleteString(&TextPos, iCount, FALSE); if (pLine == EndPos.pLine) break; pLine = pLine->pNext; } if (!iRval && bSaveUndoRecord) { SaveUndoRecord(&UndoRecord, lpText); free(lpText); } return iRval; }
bool ppInclude::GetLine(std::string &line, int &lineno) { while (current) { if (current->GetLine(line)) { if (current && files.size() == 0) lineno = GetLineNo(); else lineno = INT_MIN; if (asmpp) StripAsmComment(line); return true; } current->CheckErrors(); if (inProc.size()) { Errors::Error(std::string("File ended with ") + inProc + " in progress"); inProc = ""; } popFile(); } return false; }
///////////////////////////////////////////////// // Simple JSON parser bool TJsonLoader::Next() { if (SIn.Empty() || SIn->Eof()) { TStr FNm; if (! SIn.Empty()) { printf(" %d items in file. %d items total. [%s]\n", LineNo, ItemCnt, ExeTm.GetTmStr()); } if (! FFile.Next(FNm)) { return false; } printf("JSON parse file %d: %s\n", ++FileCnt, FNm.CStr()); LineNo=0; if (TZipIn::IsZipExt(FNm.GetFExt())) { SIn=TZipIn::New(FNm); } else { SIn=TFIn::New(FNm); } ExeTm.Tick(); } try { SIn->GetNextLn(Line); LineNo++; ItemCnt++; Item.Parse(Line.CStr()); } catch (PExcept Except) { TStr FullMsgCStr = TStr::Fmt("%s while pasing '%s' in line %d\nBEGIN LINE\n", Except->GetStr().CStr(), GetCurFNm().CStr(), GetLineNo()); FullMsgCStr += Line; FullMsgCStr += "\nEND LINE\n"; SaveToErrLog(FullMsgCStr.CStr()); ErrNotify(FullMsgCStr.CStr()); return Next(); } return true; }
//@doc SECEdit //@mfunc Internal function. Deletes iCount characters from the text, starting at // pTextPos->iOffset. // //@rdesc int //@parm PTEXTPOS pTextPos //@parm int iCount //@parm BOOL bSaveUndoRecord int SECEdit::DeleteString(PTEXTPOS pTextPos, int iCount, BOOL bSaveUndoRecord) { int i; TEXTPOS TextPos; UNDORECORD UndoRecord; ASSERT(pTextPos); TextPos = *pTextPos; // it's confusing to SaveUndoRecord if the OE_UNDO_CUT is just one character... if (iCount == 1) return (DeleteChar(&TextPos, bSaveUndoRecord)); LPSTR lpString; if (bSaveUndoRecord) { lpString = (LPSTR)SECEditAlloc(iCount+1); memcpy(lpString,&pTextPos->pLine->pText[pTextPos->iOffset],iCount); } int iRval = 0; for (i=0;i<iCount;i++) { iRval = DeleteChar(&TextPos, FALSE); if (iRval && (iRval != IDS_OE_JOINLINE)) break; else iRval = 0; } if (bSaveUndoRecord) { if (!iRval) { UndoRecord.iRow = GetLineNo(pTextPos->pLine); UndoRecord.iCol = pTextPos->iOffset; UndoRecord.iEndRow = UndoRecord.iRow; UndoRecord.iEndCol = TextPos.iOffset+iCount; UndoRecord.iUndoType = OE_UNDO_CUT; SaveUndoRecord(&UndoRecord, lpString); } free(lpString); } return iRval; }
//@doc SECEdit //@mfunc Internal function. Deletes the character at pTextPos->iOffset //@rdesc int //@parm PTEXTPOS pTextPos //@parm BOOL bSaveUndoRecord int SECEdit::DeleteChar(PTEXTPOS pTextPos, BOOL bSaveUndoRecord) { PLINEDESC pLine; int iPos,iLength; LPSTR szText; UNDORECORD UndoRecord; ASSERT(pTextPos); if (m_bReadOnly) return IDS_OE_READONLY; pLine = pTextPos->pLine; if (!pLine->pText) return 0; // no error, just ignore it szText = pLine->pText; iLength = pLine->iTxtSize; /* (maybe) adjust for OE_CR/OE_LF */ if (szText[iLength-m_iLineEndLength] == m_szLineEnd[0]) iLength -= m_iLineEndLength; // if past the end of the line, there's nothing to delete if (pTextPos->iOffset >= iLength) return IDS_OE_JOINLINE; // but it's not an error iPos = pTextPos->iOffset; if (bSaveUndoRecord) { UndoRecord.iRow = GetLineNo(pTextPos->pLine); UndoRecord.iCol = iPos; UndoRecord.iUndoType = OE_UNDO_DELETE; UndoRecord.cInsertChar = szText[iPos]; SaveUndoRecord(&UndoRecord,NULL); } SetModified(TRUE); memmove(&szText[iPos], &szText[iPos+1], pLine->iTxtSize-iPos); pLine->iTxtSize--; szText[pLine->iTxtSize] = 0; return 0; }
//////////////////////////////////////////////////////////////////////////////// // OnDebugCommand(wxCommandEvent) // // This function handles the user clicks one of the debugger tools and menus // and take care of actions requires. These events are toggle break-point, // clear all break-points, debugging continue, step-in, step-over and stop // debugging. // // Parameters // - event object // void frmDebugger::OnDebugCommand(wxCommandEvent &_event) { switch(_event.GetId()) { case MENU_ID_TOGGLE_BREAK: { int lineNo = GetLineNo(); // This event should have not been called if (lineNo == -1) return; // The user wants to set or clear a breakpoint at the line that // contains the insertion point (the caret) if (IsBreakpoint(lineNo)) { m_controller->ClearBreakpoint(lineNo); } else { m_controller->SetBreakpoint(lineNo); } m_controller->UpdateBreakpoints(); } break; case MENU_ID_CLEAR_ALL_BREAK: // The user wants to clear all the breakpoint ClearAllBreakpoints(); break; case MENU_ID_CONTINUE: // The user wants to continue execution (as opposed to // single-stepping through the code). Unhilite all // variables and tell the debugger server to continue. if (m_controller) { if (m_controller->CanRestart()) { m_controller->Start(); } else { EnableToolsAndMenus(false); LaunchWaitingDialog(_("Waiting for target (continue)...")); m_controller->Countinue(); UnhilightCurrentLine(); } } break; case MENU_ID_STEP_OVER: // The user wants to step-over a function invocation (or // just single-step). Unhilite all variables and tell the // debugger server to step-over EnableToolsAndMenus(false); LaunchWaitingDialog(_("Waiting for target (step over)...")); m_controller->StepOver(); UnhilightCurrentLine(); break; case MENU_ID_STEP_INTO: // The user wants to step-into a function invocation (or // just single-step). Unhilite all variables and tell the // debugger server to step-into EnableToolsAndMenus(false); LaunchWaitingDialog(_("Waiting for target (step into)...")); m_controller->StepInto(); UnhilightCurrentLine(); break; case MENU_ID_STOP: EnableToolsAndMenus(false); LaunchWaitingDialog(_("Waiting for target to stop execution...")); m_controller->Stop(); UnhilightCurrentLine(); break; default: break; } }
//@doc SECEdit //@mfunc Internal function. Cuts the text from pStartPos to pEndPos. Never deletes // pStartPos->pLine. //@rdesc int //@parm PTEXTPOS pStartPos //@parm PTEXTPOS pEndPos //@parm BOOL bSaveUndoRecord int SECEdit::Cut(PTEXTPOS pStartPos, PTEXTPOS pEndPos, BOOL bSaveUndoRecord) { int iRval; UNDORECORD UndoRecord; LPSTR lpText; PLINEDESC pFirstDeadLine,pNextDeadLine,pLastDeadLine; TEXTPOS TempPos; ASSERT(pStartPos); ASSERT(pEndPos); iRval = 0; if (m_bReadOnly) return IDS_OE_READONLY; if ((pStartPos->pLine == pEndPos->pLine) && (pStartPos->iOffset == pEndPos->iOffset)) return IDS_OE_NOSELECTION; if ((pStartPos->pLine == NULL) || (pEndPos->pLine == NULL)) return IDS_OE_NOSELECTION; // save the undo record if (bSaveUndoRecord) { UndoRecord.iRow = GetLineNo(pStartPos->pLine); if (pStartPos->pLine == pEndPos->pLine) UndoRecord.iEndRow = UndoRecord.iRow; else UndoRecord.iEndRow = GetLineNo(pEndPos->pLine); UndoRecord.iCol = pStartPos->iOffset; UndoRecord.iEndCol = pEndPos->iOffset; UndoRecord.iUndoType = OE_UNDO_CUT; lpText = Copy(pStartPos, pEndPos, FALSE); } if (pStartPos->pLine == pEndPos->pLine) { iRval = DeleteString(pStartPos, pEndPos->iOffset-pStartPos->iOffset, FALSE); } else { // lop the starting line off at iOffset if (pStartPos->iOffset < (pStartPos->pLine->iTxtSize-m_iLineEndLength)) { pStartPos->pLine->pText[pStartPos->iOffset] = 0; pStartPos->pLine->iTxtSize = pStartPos->iOffset; } // delete the marked part of the last line if (pEndPos->iOffset > pEndPos->pLine->iTxtSize) { pEndPos->iOffset = pEndPos->pLine->iTxtSize; /* (maybe) adjust for OE_CR/OE_LF */ char cFirst,cSecond; cFirst = pEndPos->pLine->pText[pEndPos->pLine->iTxtSize-m_iLineEndLength]; cSecond = m_szLineEnd[0]; if (cFirst == cSecond) { pEndPos->iOffset -= m_iLineEndLength; UndoRecord.iEndCol -= m_iLineEndLength; } } TempPos.pLine = pEndPos->pLine; TempPos.iOffset = 0; iRval = DeleteString(&TempPos, pEndPos->iOffset, FALSE); // link the two together, and unlink the ones in between if ((!iRval) || (iRval == IDS_OE_JOINLINE)) { if (pStartPos->pLine->pNext != pEndPos->pLine) { pFirstDeadLine = pStartPos->pLine->pNext; if (pEndPos->pLine) { pLastDeadLine = pEndPos->pLine->pPrev; pEndPos->pLine->pPrev = pStartPos->pLine; } else pLastDeadLine = NULL; pStartPos->pLine->pNext = pEndPos->pLine; if (pLastDeadLine) pLastDeadLine->pNext = NULL; while (pFirstDeadLine) { pNextDeadLine = pFirstDeadLine->pNext; FreeTextLine(pFirstDeadLine); pFirstDeadLine = pNextDeadLine; } } // join the chopped start with the chopped end iRval = JoinLines(pStartPos, FALSE); if (iRval == IDS_OE_EOF) iRval = 0; } } if (!iRval) { if (bSaveUndoRecord) { SaveUndoRecord(&UndoRecord,lpText); free(lpText); } // set the changed flag SetModified(TRUE); } return iRval; }