// New current line bool DebuggerManager::setActiveLine (const QString& file, int line ) { //Get local filename QString filename = file; // Remove old active line mark setMark(m_currentFile, m_currentLine, false, KTextEditor::MarkInterface::markType05); // Update vars with active line m_currentFile = filename; m_currentLine = line; // No new current position if(filename.isEmpty() || quantaApp->previewVisible()) return true; // Find new position in editor if(ViewManager::ref()->isOpened(filename) || QExtFileInfo::exists(filename, true, 0L)) quantaApp->gotoFileAndLine(filename, line, 0); else { showStatus(i18n("Unable to open file %1, check your basedirs and mappings.").arg(filename), true); } // Add new active line mark setMark(filename, line, true, KTextEditor::MarkInterface::markType05); return true; }
void Solve::SegTree::pushMark(int i) { Node &x = node[i]; if(x.tag != -1) { setMark(i * 2, x.tag), setMark(i * 2 + 1, x.tag); x.tag = -1; } }
// A new file was opened, tell the debugger so it can tell us about breakpoints etc void DebuggerManager::fileOpened(const QString& file) { // Set breakpoint markers if we have a bp in the file m_breakpointList->rewind(); DebuggerBreakpoint* bp; while((bp = m_breakpointList->next())) { if(bp->filePath() == file) { setMark(bp->filePath(), bp->line(), true, KTextEditor::MarkInterface::markType02); } } //lets keep the eye on toggling bp's through the editor margin QuantaView *view = ViewManager::ref()->isOpened(KURL::fromPathOrURL(file)); if (view) { ::Document* qdoc = view->document(); if(qdoc) { connectBreakpointSignals(qdoc); } } // Also, if we have a debug-session, let the debugger know... if(m_client) m_client->fileOpened(file); }
void prepareVertex(Vertex *v) { v->sortEdges(); for(Edge *vw:v->getOutEdges()) { Vertex *w=vw->getEndVertex(); setMark(w, INPLAY); } }
// The debug server told us we DONT have a breakpoint, remove it void DebuggerManager::havenoBreakpoint (const QString& file, int line) { DebuggerBreakpoint* br = new DebuggerBreakpoint(file, line); m_breakpointList->remove(br); setMark(file, line, false, KTextEditor::MarkInterface::markType02); m_breakpointList->remove(br); }
void OutgoingDataQueue::putData(uint32 stamp, const unsigned char *data, size_t datalen) { if ( !data || !datalen ) return; size_t step = 0, offset = 0; while ( offset < datalen ) { // remainder and step take care of segmentation // according to getMaxSendSegmentSize() size_t remainder = datalen - offset; step = ( remainder > getMaxSendSegmentSize() ) ? getMaxSendSegmentSize() : remainder; CryptoContext* pcc = getOutQueueCryptoContext(getLocalSSRC()); if (pcc == NULL) { pcc = getOutQueueCryptoContext(0); if (pcc != NULL) { pcc = pcc->newCryptoContextForSSRC(getLocalSSRC(), 0, 0L); if (pcc != NULL) { pcc->deriveSrtpKeys(0); setOutQueueCryptoContext(pcc); } } } OutgoingRTPPkt* packet; if ( sendInfo.sendCC ) packet = new OutgoingRTPPkt(sendInfo.sendSources,15,data + offset,step, sendInfo.paddinglen, pcc); else packet = new OutgoingRTPPkt(data + offset,step,sendInfo.paddinglen, pcc); packet->setPayloadType(getCurrentPayloadType()); packet->setSeqNum(sendInfo.sendSeq++); packet->setTimestamp(stamp + getInitialTimestamp()); packet->setSSRCNetwork(getLocalSSRCNetwork()); if ( (0 == offset) && getMark() ) { packet->setMarker(true); setMark(false); } else { packet->setMarker(false); } if (pcc != NULL) { packet->protect(getLocalSSRC(), pcc); } // insert the packet into the "tail" of the sending queue sendLock.writeLock(); OutgoingRTPPktLink *link = new OutgoingRTPPktLink(packet,sendLast,NULL); if (sendLast) sendLast->setNext(link); else sendFirst = link; sendLast = link; sendLock.unlock(); offset += step; } }
void LiftDragPlot::mouseMoveEvent( QMouseEvent *event) { if (event->buttons() & Qt::LeftButton) { QPoint pos = event->pos(); QVector2D diff = QVector2D(pos - mBeginPos); if (diff.length() > selectionTolerance()) { mDragging = true; } if (mDragging) { const double cd = xAxis->pixelToCoord(pos.x()); const double cl = yAxis->pixelToCoord(pos.y()); const double c = cd / 2; const double a = c / cl / cl; mMainWindow->setMinDrag(c); mMainWindow->setMaxLD(1 / sqrt(4 * a * c)); } } else if (QCPCurve *graph = qobject_cast<QCPCurve *>(plottable(0))) { const QCPCurveDataMap *data = graph->data(); double resultTime; double resultDistance = std::numeric_limits<double>::max(); for (QCPCurveDataMap::const_iterator it = data->constBegin(); it != data->constEnd(); ++it) { QVector2D pt = QVector2D(xAxis->coordToPixel(it.value().key), yAxis->coordToPixel(it.value().value)); double dist = pt.distanceToPoint(QVector2D(event->pos())); if (dist < resultDistance) { resultTime = it.value().t; resultDistance = dist; } } if (resultDistance < selectionTolerance()) { setMark(resultTime); } else { mMainWindow->clearMark(); QToolTip::hideText(); } } }
static void markPhase() { #ifndef NVALGRIND // Have valgrind close its eyes while we do the conservative stack and data scanning, // since we'll be looking at potentially-uninitialized values: VALGRIND_DISABLE_ERROR_REPORTING; #endif TraceStack stack(roots); collectStackRoots(&stack); TraceStackGCVisitor visitor(&stack); for (auto h : *getRootHandles()) { visitor.visitPotential(h->value); } // if (VERBOSITY()) printf("Found %d roots\n", stack.size()); while (void* p = stack.pop()) { assert(((intptr_t)p) % 8 == 0); GCAllocation* al = GCAllocation::fromUserData(p); if (isMarked(al)) { continue; } // printf("Marking + scanning %p\n", p); setMark(al); GCKind kind_id = al->kind_id; if (kind_id == GCKind::UNTRACKED) { continue; } else if (kind_id == GCKind::CONSERVATIVE) { uint32_t bytes = al->kind_data; visitor.visitPotentialRange((void**)p, (void**)((char*)p + bytes)); } else if (kind_id == GCKind::PYTHON) { Box* b = reinterpret_cast<Box*>(p); BoxedClass* cls = b->cls; if (cls) { // The cls can be NULL since we use 'new' to construct them. // An arbitrary amount of stuff can happen between the 'new' and // the call to the constructor (ie the args get evaluated), which // can trigger a collection. ASSERT(cls->gc_visit, "%s", getTypeName(b)->c_str()); cls->gc_visit(&visitor, b); } } else { RELEASE_ASSERT(0, "Unhandled kind: %d", (int)kind_id); } } #ifndef NVALGRIND VALGRIND_ENABLE_ERROR_REPORTING; #endif }
void markEliminatedEdgesAndReset(Vertex *v) { for(Edge *vw :v->getOutEdges()) { Vertex *w=vw->getEndVertex(); if(getMark(w)==ELIMINATED) { edgeToReduce[vw]=true; //edgeToReduce.put(vw, true); } setMark(w,VACANT); } }
void SonicPiScintilla::downcaseWordOrSelection(){ if(hasSelectedText()) { SendScintilla(SCI_LOWERCASE); } else { setMark(); SendScintilla(SCI_WORDRIGHT); SendScintilla(SCI_LOWERCASE); deselect(); } }
/** * Constructor - Initializes the file name and line number where * this message occured. Sets the message to report, using an * optional list of arguments to parse into the message * @param file name where exception occurs * @param line number where the exception occurred. * @param message to report * @param list of primitives that are formatted into the message */ NoSuchElementException( const char* file, const int lineNumber, const std::string msg, ... ) { va_list vargs; va_start( vargs, msg ); buildMessage( msg, vargs ); // Set the first mark for this exception. setMark( file, lineNumber ); }
void push(void* p) { GCAllocation* al = GCAllocation::fromUserData(p); if (isMarked(al)) return; setMark(al); *cur++ = p; if (cur == end) { chunks.push_back(start); get_chunk(); } }
void Solve::SegTree::change(int i, int l, int r, int color) { Node &x = node[i]; if(l > x.r || r < x.l) return; if(l <= x.l && x.r <= r) { setMark(i, color); return; } pushMark(i); change(i * 2, l, r, color), change(i * 2 + 1, l, r, color); update(i); }
static void markPhase() { #ifndef NVALGRIND // Have valgrind close its eyes while we do the conservative stack and data scanning, // since we'll be looking at potentially-uninitialized values: VALGRIND_DISABLE_ERROR_REPORTING; #endif TraceStack stack(roots); collectStackRoots(&stack); TraceStackGCVisitor visitor(&stack); //if (VERBOSITY()) printf("Found %d roots\n", stack.size()); while (void* p = stack.pop()) { assert(((intptr_t)p) % 8 == 0); GCObjectHeader* header = headerFromObject(p); //printf("%p\n", p); if (isMarked(header)) { //printf("Already marked, skipping\n"); continue; } //printf("Marking + scanning %p\n", p); setMark(header); ASSERT(KIND_OFFSET <= header->kind_id && header->kind_id < KIND_OFFSET + num_kinds, "%p %d", header, header->kind_id); if (header->kind_id == untracked_kind.kind_id) continue; //ASSERT(kind->_cookie == AllocationKind::COOKIE, "%lx %lx", kind->_cookie, AllocationKind::COOKIE); //AllocationKind::GCHandler gcf = kind->gc_handler; AllocationKind::GCHandler gcf = handlers[header->kind_id - KIND_OFFSET]; assert(gcf); //if (!gcf) { //std::string name = g.func_addr_registry.getFuncNameAtAddress((void*)kind, true); //ASSERT(gcf, "%p %s", kind, name.c_str()); //} gcf(&visitor, p); } #ifndef NVALGRIND VALGRIND_ENABLE_ERROR_REPORTING; #endif }
void removeShortEdges(Vertex *v) { for(Edge *vw :v->getOutEdges()) { Vertex *w=vw->getEndVertex(); int numIter=0; for(Edge *wx : w->getOutEdges()) { Vertex *x=wx->getEndVertex(); numIter++; if(getMark(x)!=INPLAY) { continue; } if(numIter==1) { count2++; setMark(x,ELIMINATED); } else if(wx->length()<FUZZ) { count2++; setMark(x,ELIMINATED); } else if (wx->length()>=FUZZ) { break; } } } }
void OutgoingDataQueue::sendImmediate(uint32 stamp, const unsigned char *data, size_t datalen) { if ( !data || !datalen ) return; size_t step = 0, offset = 0; while ( offset < datalen ) { // remainder and step take care of segmentation // according to getMaxSendSegmentSize() size_t remainder = datalen - offset; step = ( remainder > getMaxSendSegmentSize() ) ? getMaxSendSegmentSize() : remainder; CryptoContext* pcc = getOutQueueCryptoContext(getLocalSSRC()); OutgoingRTPPkt* packet; if ( sendInfo.sendCC ) packet = new OutgoingRTPPkt(sendInfo.sendSources,15,data + offset,step,sendInfo.paddinglen, pcc); else packet = new OutgoingRTPPkt(data + offset,step,sendInfo.paddinglen, pcc); packet->setPayloadType(getCurrentPayloadType()); packet->setSeqNum(sendInfo.sendSeq++); packet->setTimestamp(stamp + getInitialTimestamp()); packet->setSSRCNetwork(getLocalSSRCNetwork()); if ( (0 == offset) && getMark() ) { packet->setMarker(true); setMark(false); } else { packet->setMarker(false); } if (pcc != NULL) { packet->protect(getLocalSSRC(), pcc); } dispatchImmediate(packet); delete packet; offset += step; } }
void removeTransitiveEdges(Vertex *v,int maxLen) { v->sortEdges(); for(Edge *vw:v->getOutEdges()) { Vertex *w=vw->getEndVertex(); w->sortEdges(); if(getMark(w)!=INPLAY) { continue; } for(Edge *wx:w->getOutEdges()) { if(vw->length()+wx->length()>maxLen) { break; } Vertex *x=wx->getEndVertex(); if(getMark(x)==INPLAY) { count1++; setMark(x,ELIMINATED); } } } }
static void markPhase() { TraceStack stack(roots); collectStackRoots(&stack); TraceStackGCVisitor visitor(&stack); //if (VERBOSITY()) printf("Found %d roots\n", stack.size()); while (void* p = stack.pop()) { assert(((intptr_t)p) % 8 == 0); GCObjectHeader* header = headerFromObject(p); //printf("%p\n", p); if (isMarked(header)) { //printf("Already marked, skipping\n"); continue; } //printf("Marking + scanning %p\n", p); setMark(header); ASSERT(KIND_OFFSET <= header->kind_id && header->kind_id < KIND_OFFSET + num_kinds, "%p %d", header, header->kind_id); if (header->kind_id == untracked_kind.kind_id) continue; //ASSERT(kind->_cookie == AllocationKind::COOKIE, "%lx %lx", kind->_cookie, AllocationKind::COOKIE); //AllocationKind::GCHandler gcf = kind->gc_handler; AllocationKind::GCHandler gcf = handlers[header->kind_id - KIND_OFFSET]; assert(gcf); //if (!gcf) { //std::string name = g.func_addr_registry.getFuncNameAtAddress((void*)kind, true); //ASSERT(gcf, "%p %s", kind, name.c_str()); //} gcf(&visitor, p); } }
Address Memory::allocatePhysical(Size sz, Address paddr) { Address start = paddr & PAGEMASK, end = memorySize; Address from = 0, count = 0; /* Loop the memoryMap for a free block. */ for (Address i = start; i < end; i += PAGESIZE) { if (!isMarked(i)) { /* Remember this page. */ if (!count) { from = i; count = 1; } else count++; /* Are there enough contigious pages? */ if (count * PAGESIZE >= sz) { for (Address j = from; j < from + (count * PAGESIZE); j += PAGESIZE) { setMark(j, true); } memoryAvail -= count * PAGESIZE; return from; } } else { from = count = 0; } } /* Out of memory! */ return (Address) ZERO; }
void Bar::traverse(osg::NodeVisitor& nv) { if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR) { float time = nv.getFrameStamp()->getReferenceTime(); float dt = time-_time; _time = time; if (_valueptr) setValue(*_valueptr); if (_markptr) setMark(*_markptr); if (_drawmark) { // Make mark follow bar if (_markmode != STATIC && _mark < _value) { _mark = _value; _marktime = _time; } // Make mark fall after delay has run out if (_time - _marktime > _markdelay) { if (_markmode == FALL) { if (_mark > _value) _mark -= _markrate*dt; update(); } } } if (_time - _bartime > _bardelay) { if (_barmode == FALL) { if (_value > 0) _value -= _barrate*dt; if (_value < 0) _value = 0; update(); } } } }
// The debug server told us we have a breakpoint, mark it in the file void DebuggerManager::haveBreakpoint (const QString& file, int line) { setMark(file, line, true, KTextEditor::MarkInterface::markType02); }
void Player::removeMark(const QString &mark){ int value = marks.value(mark, 0); value--; value = qMax(0, value); setMark(mark, value); }
void Player::addMark(const QString &mark){ int value = marks.value(mark, 0); value++; setMark(mark, value); }
void CodeEditor::doCommand(uint32 cmd) { switch (cmd) { case CmdPrintFoo: { std::cerr << "Foo\n"; } break; case CmdSave: { save(); } break; case CmdReloadOpenDocument: { reload(); } break; case CmdLoadTest: { loadTest(); } break; case CmdMoveUpToBlank: { moveCursorUpToBlank(); } break; case CmdMoveDownToBlank: { moveCursorDownToBlank(); } break; case CmdMoveToDocumentBegin: { moveCursorToDocumentBegin(); } break; case CmdMoveToDocumentEnd: { moveCursorToDocumentEnd(); } break; case CmdMoveToLineBegin: { moveCursorToLineBegin(); } break; case CmdMoveToLineEnd: { moveCursorToLineEnd(); } break; case CmdSetMark: { setMark(); } break; case CmdSwapCursorAndMark: { swapCursorAndMark(); } break; case CmdMoveCursorToMark: { moveCursorToMark(); } break; case CmdToggleMarkVisibility: { toggleMarkVisibility(); } break; case CmdBackspace: { doBackspace(); } break; case CmdDelete: { doDelete(); } break; case CmdClearLine: { clearLine(mCurrentLine); } break; case CmdClearDocument: { clear(); } break; case CmdTab: { doTab(); } break; case CmdNewline: { addLine(); } break; case CmdOpenConfig: { loadConfig(); } break; case CmdOpenTheme: { loadCurrentTheme(); } break; case CmdLoadHelp: { loadReadMe(); } break; } }
void CodeEditor::update(RenderWindow *window) { mTopbar.setSize(window->getWidth() - 8, mTopbar.getSize().y); if (mLineHighlightType != LineHighlightType::LineNumberArea) { mLineHighlightRect.setSize(window->getWidth() - 8, mLineHighlightRect.getSize().y); } else { mLineHighlightRect.setSize(mLineNumberAreaWidth, mLineHighlightRect.getSize().y); } //TODO: move the cursor when the text is scrolled. //TODO: make the above optional //TODO: make it so that when the cursor is moved outside the view, the view is back on the cursor. uint32 cursorY = mText[mCurrentLine].getPosition().y + 2; //Check to see if we scrolled to far in either direction. if (mText.size() > 1) { if (mText[0].getPosition().y > mPos.y) { uint32 deltaY = (mText[0].getPosition().y - mPos.y); for (uint32 i = 0; i < mText.size(); ++i) { mText[i].setPosition(mText[i].getPosition().x, mText[i].getPosition().y - deltaY); mLineNumbers[i].setPosition(mLineNumbers[i].getPosition().x, mLineNumbers[i].getPosition().y - deltaY); } } uint32 max = mText.size() - 1; if (mText[max].getPosition().y < mPos.y) { uint32 deltaY = (mPos.y - mText[max].getPosition().y); for (uint32 i = 0; i < mText.size(); ++i) { mText[i].setPosition(mText[i].getPosition().x, mText[i].getPosition().y + deltaY); mLineNumbers[i].setPosition(mLineNumbers[i].getPosition().x, mLineNumbers[i].getPosition().y + deltaY); } } cursorY = mText[mCurrentLine].getPosition().y + 2; if (mText[mCurrentLine].getPosition().y < mPos.y) { for (uint32 i = mCurrentLine; i < mText.size(); ++i) { if (mText[i].getPosition().y >(mPos.y - mFontSize)) { mCurrentLine = i; cursorY = mText[i].getPosition().y + 2; break; } } } else if (mText[mCurrentLine].getPosition().y > (mPos.y + mSize.y - (mFontSize * 2))) { for (int32 i = mCurrentLine; i >= 0; --i) { if (mText[i].getPosition().y < (mPos.y + mSize.y - (mFontSize * 2))) { mCurrentLine = i; cursorY = mText[i].getPosition().y + 2; break; } } } } if (mCursorType == CursorType::Underscore) { cursorY += Preferences::instance()->getFont()->getLineSpacing(mFontSize) - 2; } uint32 cursorX = 0; mUpperBound = 0; if (mLineIndex >= getLineLength(mCurrentLine)) { mUpperBound = getLineLength(mCurrentLine); } else { mUpperBound = mLineIndex; } for (int i = 0; i < mUpperBound; ++i) { uint32 c = getLine(mCurrentLine)[i]; if (c == '\t') { cursorX += (getCharWidth(L'') * mTabWidth); } else { cursorX += getCharWidth(c); } } uint32 markX = 0; for (int i = 0; i < mMarkIndex; ++i) { uint32 c = getLine(mMarkLine)[i]; if (c == '\t') { markX += (getCharWidth(L'') * mTabWidth); } else { markX += getCharWidth(c); } } uint32 markY = mText[mMarkLine].getPosition().y + 2; mCursorRect.setPosition(mPos.x + mLineNumberAreaWidth + cursorX /*offset*/, cursorY); mCurrentChar.setPosition(mCursorRect.getPosition().x, mCursorRect.getPosition().y - 2); mMarkRect.setPosition(mPos.x + mLineNumberAreaWidth + markX /*offset*/, markY); if (mLineHighlightType != LineHighlightType::CodeArea) { mLineHighlightRect.setPosition(mPos.x, cursorY); } else { mLineHighlightRect.setPosition(mPos.x + mLineNumberAreaWidth, cursorY); } if (mCursorType != CursorType::CursorLine) { mCursorRect.setWidth(getCharWidth(getCurrentChar())); } mMarkRect.setWidth(getCharWidth(getMarkChar())); if (!mFirstMarkSet) { setMark(); mFirstMarkSet = true; } mCurrentChar.setString(getCurrentChar()); bool useMilitaryTime = Preferences::instance()->useMilitaryTime(); Clock clock(useMilitaryTime); int32 hour = clock.getCurrentHour(); int32 minute = clock.getCurrentMinute(); int32 second = clock.getCurrentSecond(); String ampm = clock.isPm() ? "PM" : "AM"; ampm = useMilitaryTime ? "" : ampm; String hourStr = String::number(hour); String minuteStr = String::number(minute); String secondStr = String::number(second); if (minuteStr.getLength() == 1) { minuteStr.prepend("0"); } if (secondStr.getLength() == 1) { secondStr.prepend("0"); } Date date = Date::currentDate(); String time = Preferences::instance()->showClock() ? hourStr + ":" + minuteStr + ":" + secondStr + " " + ampm : ""; String dateStr = date.getDayName() + " " + date.getMonthName() + " " + String::number(date.dayOfMonth()) + " " + String::number(date.getYear()) + " week of the year: " + String::number(date.weekNumber()); if (mClock.getCurrentTimeInMilliseconds() >= (timeNow + 1000)) { timeNow = mClock.getCurrentTimeInMilliseconds(); frameRate = frames; frames = 0; } uint32 p = (staticCastf(mCurrentLine + 1) / staticCastf(getLineCount())) * 100; mTopBarText.setString(mFilename + "\t" + String::number(p) + "% " + String::number(mCurrentLine + 1) + ":u" + String::number(mUpperBound) + ", i" + String::number(mLineIndex) + "\t" + dateStr + " " + time + "\tfps: " + String::number(frameRate)); //Draw///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (mShowLineNumbers) { window->draw(mLineNumberArea); } if (mShowLineHighlight) { window->draw(mLineHighlightRect); } for (uint32 i = 0; i < mText.size(); ++i) { if ((mText[i].getPosition().y < (mPos.y - mFontSize)) || (mText[i].getPosition().y >= mPos.y + mSize.y)) { continue; } if (mShowLineHighlight && mLineHighlightType != LineHighlightType::LineNumberArea) { if (i == mCurrentLine) { mText[i].setColor(mLineHighlightTextColor); } if (i != mCurrentLine && mText[i].getColor() != mTextColor) { mText[i].setColor(mTextColor); } } if (mShowLineNumbers) { window->draw(mLineNumbers[i]); } window->draw(mText[i]); } if (mClock.getCurrentTimeInMilliseconds() >= (mLastBlinkTime + 500)) { mLastBlinkTime = mClock.getCurrentTimeInMilliseconds(); mShowCursor = !mShowCursor; } if (!mBlinkCursor) { mShowCursor = true; } if (mShowCursor) { window->draw(mCursorRect); } if (mShowMark) { window->draw(mMarkRect); } String str = mCurrentChar.getString(); if (mShowCursor && mCursorType == CursorType::Block && !str.isEmpty() && str != "\r") { window->draw(mCurrentChar); } mTopbar.setFillColor(Preferences::instance()->getTheme().barColor); window->draw(mTopbar); window->draw(mTopBarText); ++frames; }
void Memory::releasePhysical(Address addr) { setMark(addr & PAGEMASK, false); memoryAvail += PAGESIZE; }