void ScrollWindow::upArrow() { if (_topVisibleLine == 0) { return; } _topVisibleLine--; _bottomVisibleLine--; if (_bottomVisibleLine - _topVisibleLine + 1 < _numVisibleLines) { _bottomVisibleLine = _numLines - 1; } _firstVisibleChar = _startsOfLines[_topVisibleLine]; _lastVisibleChar = _startsOfLines[_bottomVisibleLine + 1] - 1; _visibleText = Common::String(_text.c_str() + _firstVisibleChar, _text.c_str() + _lastVisibleChar + 1); Common::String lineText(_text.c_str() + _startsOfLines[_topVisibleLine], _text.c_str() + _startsOfLines[_topVisibleLine + 1] - 1); debugC(3, kDebugLevelGraphics, "ScrollWindow::upArrow: top: %d, bottom: %d, num: %d, numvis: %d, lineText: %s", _topVisibleLine, _bottomVisibleLine, _numLines, _numVisibleLines, lineText.c_str()); _gfxText32.scrollLine(lineText, _numVisibleLines, _foreColor, _alignment, _fontId, kScrollUp); if (_visible) { assert(_screenItem); _screenItem->update(); g_sci->_gfxFrameout->frameOut(true); } }
/************************************************************************* Return the text code point index that is rendered closest to screen position 'pt'. *************************************************************************/ size_t MultiLineEditbox::getTextIndexFromPosition(const Point& pt) const { // // calculate final window position to be checked // Point wndPt = screenToWindow(pt); if (getMetricsMode() == Relative) { wndPt = relativeToAbsolute(wndPt); } Rect textArea(getTextRenderArea()); wndPt.d_x -= textArea.d_left; wndPt.d_y -= textArea.d_top; // factor in scroll bar values if( d_horzScrollbar ) wndPt.d_x += d_horzScrollbar->getScrollPosition(); if( d_vertScrollbar ) wndPt.d_y += d_vertScrollbar->getScrollPosition(); size_t lineNumber = static_cast<size_t>(wndPt.d_y / getFont()->getLineSpacing()); if (lineNumber >= d_lines.size()) { lineNumber = d_lines.size() - 1; } String lineText(d_text.substr(d_lines[lineNumber].d_startIdx, d_lines[lineNumber].d_length)); size_t lineIdx = getFont()->getCharAtPixel(lineText, wndPt.d_x); if (lineIdx >= lineText.length() - 1) { lineIdx = lineText.length() - 1; } return d_lines[lineNumber].d_startIdx + lineIdx; }
//++ ------------------------------------------------------------------------------------ // Details: Call this function puts *this driver to work. // This function is used by the application's main thread. // Type: Overridden. // Args: None. // Return: MIstatus::success - Functional succeeded. // MIstatus::failure - Functional failed. // Throws: None. //-- bool CMIDriver::DoMainLoop(void) { if (!InitClientIDEToMIDriver()) // Init Eclipse IDE { SetErrorDescriptionn(MIRSRC(IDS_MI_INIT_ERR_CLIENT_USING_DRIVER)); return MIstatus::failure; } if (!StartWorkerThreads()) return MIstatus::failure; bool bOk = MIstatus::success; if (HaveExecutableFileNamePathOnCmdLine()) { if (!LocalDebugSessionStartupExecuteCommands()) { SetErrorDescription(MIRSRC(IDS_MI_INIT_ERR_LOCAL_DEBUG_SESSION)); bOk = MIstatus::failure; } } // App is not quitting currently m_bExitApp = false; // Handle source file if (m_bHaveCommandFileNamePathOnCmdLine) { const bool bAsyncMode = false; ExecuteCommandFile(bAsyncMode); } // While the app is active while (bOk && !m_bExitApp) { CMIUtilString errorText; const char *pCmd = m_rStdin.ReadLine (errorText); if (pCmd != nullptr) { CMIUtilString lineText(pCmd); if (!lineText.empty ()) { // Check that the handler thread is alive (otherwise we stuck here) assert(CMICmnLLDBDebugger::Instance().ThreadIsActive()); { // Lock Mutex before processing commands so that we don't disturb an event // being processed CMIUtilThreadLock lock(CMICmnLLDBDebugSessionInfo::Instance().GetSessionMutex()); bOk = InterpretCommand(lineText); } // Draw prompt if desired bOk = bOk && CMICmnStreamStdout::WritePrompt(); // Wait while the handler thread handles incoming events CMICmnLLDBDebugger::Instance().WaitForHandleEvent(); } } } // Signal that the application is shutting down DoAppQuit(); // Close and wait for the workers to stop StopWorkerThreads(); // Ensure that a new line is sent as the last act of the dying driver m_rStdOut.WriteMIResponse("\n", false); return MIstatus::success; }
/************************************************************************* Render text lines. *************************************************************************/ void MultiLineEditbox::cacheTextLines(const Rect& dest_area) { // text is already formatted, we just grab the lines and render them with the required alignment. Rect drawArea(dest_area); drawArea.offset(Point(-d_horzScrollbar->getScrollPosition(), -d_vertScrollbar->getScrollPosition())); Renderer* renderer = System::getSingleton().getRenderer(); const Font* fnt = getFont(); if (fnt) { // get layers to use for rendering float textZ = renderer->getZLayer(4) - renderer->getCurrentZ(); float selZ = renderer->getZLayer(3) - renderer->getCurrentZ(); // calculate final colours to use. ColourRect colours; float alpha = getEffectiveAlpha(); colour normalTextCol = d_normalTextColour; normalTextCol.setAlpha(normalTextCol.getAlpha() * alpha); colour selectTextCol = d_selectTextColour; selectTextCol.setAlpha(selectTextCol.getAlpha() * alpha); colour selectBrushCol = hasInputFocus() ? d_selectBrushColour : d_inactiveSelectBrushColour; selectBrushCol.setAlpha(selectBrushCol.getAlpha() * alpha); // Cache font info const float fLineSpacing = fnt->getLineSpacing (); // for each formatted line. for (size_t i = 0; i < d_lines.size(); ++i) { Rect lineRect(drawArea); // Check line is within the dest_area if ( lineRect.d_top < dest_area.d_bottom && lineRect.d_top + fLineSpacing > dest_area.d_top ) { const LineInfo& currLine = d_lines[i]; String lineText(d_text.substr(currLine.d_startIdx, currLine.d_length)); // if it is a simple 'no selection area' case if ((currLine.d_startIdx >= d_selectionEnd) || ((currLine.d_startIdx + currLine.d_length) <= d_selectionStart) || (d_selectionBrush == NULL)) { colours.setColours(normalTextCol); // render the complete line. d_renderCache.cacheText(lineText, fnt, LeftAligned, lineRect, textZ, colours, &dest_area); } // we have at least some selection highlighting to do else { // Start of actual rendering section. String sect; size_t sectIdx = 0, sectLen; float selStartOffset = 0.0f, selAreaWidth = 0.0f; // render any text prior to selected region of line. if (currLine.d_startIdx < d_selectionStart) { // calculate length of text section sectLen = d_selectionStart - currLine.d_startIdx; // get text for this section sect = lineText.substr(sectIdx, sectLen); sectIdx += sectLen; // get the pixel offset to the beginning of the selection area highlight. selStartOffset = fnt->getTextExtent(sect); // draw this portion of the text colours.setColours(normalTextCol); d_renderCache.cacheText(sect, fnt, LeftAligned, lineRect, textZ, colours, &dest_area); // set position ready for next portion of text lineRect.d_left += selStartOffset; } // calculate the length of the selected section sectLen = ceguimin(d_selectionEnd - currLine.d_startIdx, currLine.d_length) - sectIdx; // get the text for this section sect = lineText.substr(sectIdx, sectLen); sectIdx += sectLen; // get the extent to use as the width of the selection area highlight selAreaWidth = fnt->getTextExtent(sect); // draw the text for this section colours.setColours(selectTextCol); d_renderCache.cacheText(sect, fnt, LeftAligned, lineRect, textZ, colours, &dest_area); // render any text beyond selected region of line if (sectIdx < currLine.d_length) { // update render position to the end of the selected area. lineRect.d_left += selAreaWidth; // calculate length of this section sectLen = currLine.d_length - sectIdx; // get the text for this section sect = lineText.substr(sectIdx, sectLen); // render the text for this section. colours.setColours(normalTextCol); d_renderCache.cacheText(sect, fnt, LeftAligned, lineRect, textZ, colours, &dest_area); } // calculate area for the selection brush on this line lineRect.d_left = drawArea.d_left + selStartOffset; lineRect.d_right = lineRect.d_left + selAreaWidth; lineRect.d_bottom = lineRect.d_top + fLineSpacing; // render the selection area brush for this line colours.setColours(selectBrushCol); d_renderCache.cacheImage(*d_selectionBrush, lineRect, selZ, colours, &dest_area); } } // update master position for next line in paragraph. drawArea.d_top += fLineSpacing; } } }
//++ ------------------------------------------------------------------------------------ // Details: Call this function puts *this driver to work. // This function is used by the application's main thread. // Type: Overridden. // Args: None. // Return: MIstatus::success - Functional succeeded. // MIstatus::failure - Functional failed. // Throws: None. //-- bool CMIDriver::DoMainLoop(void) { if (!InitClientIDEToMIDriver()) // Init Eclipse IDE { SetErrorDescriptionn(MIRSRC(IDS_MI_INIT_ERR_CLIENT_USING_DRIVER)); return MIstatus::failure; } if (!StartWorkerThreads()) return MIstatus::failure; bool bOk = MIstatus::success; if (HaveExecutableFileNamePathOnCmdLine()) { if (!LocalDebugSessionStartupExecuteCommands()) { SetErrorDescription(MIRSRC(IDS_MI_INIT_ERR_LOCAL_DEBUG_SESSION)); bOk = MIstatus::failure; } } // App is not quitting currently m_bExitApp = false; // While the app is active while (bOk && !m_bExitApp) { CMIUtilString errorText; const MIchar *pCmd = m_rStdin.ReadLine (errorText); if (pCmd != nullptr) { CMIUtilString lineText(pCmd); if (!lineText.empty ()) { if (lineText == "quit") { // We want to be exiting when receiving a quit command m_bExitApp = true; break; } { // Lock Mutex before processing commands so that we don't disturb an event // being processed CMIUtilThreadLock lock(CMICmnLLDBDebugSessionInfo::Instance().GetSessionMutex()); bOk = InterpretCommand(lineText); } // Draw prompt if desired if (bOk && m_rStdin.GetEnablePrompt()) bOk = m_rStdOut.WriteMIResponse(m_rStdin.GetPrompt()); } } } // Signal that the application is shutting down DoAppQuit(); // Close and wait for the workers to stop StopWorkerThreads(); // Ensure that a new line is sent as the last act of the dying driver m_rStdOut.WriteMIResponse("\n", false); return MIstatus::success; }
void FalagardMultiLineEditbox::cacheTextLines(const Rectf& dest_area) { MultiLineEditbox* w = (MultiLineEditbox*)d_window; // text is already formatted, we just grab the lines and render them with the required alignment. Rectf drawArea(dest_area); float vertScrollPos = w->getVertScrollbar()->getScrollPosition(); drawArea.offset(Vector2f(-w->getHorzScrollbar()->getScrollPosition(), -vertScrollPos)); const Font* fnt = w->getFont(); if (fnt) { // calculate final colours to use. ColourRect colours; const float alpha = w->getEffectiveAlpha(); ColourRect normalTextCol; setColourRectToUnselectedTextColour(normalTextCol); normalTextCol.modulateAlpha(alpha); ColourRect selectTextCol; setColourRectToSelectedTextColour(selectTextCol); selectTextCol.modulateAlpha(alpha); ColourRect selectBrushCol; w->hasInputFocus() ? setColourRectToActiveSelectionColour(selectBrushCol) : setColourRectToInactiveSelectionColour(selectBrushCol); selectBrushCol.modulateAlpha(alpha); const MultiLineEditbox::LineList& d_lines = w->getFormattedLines(); const size_t numLines = d_lines.size(); // calculate the range of visible lines size_t sidx,eidx; sidx = static_cast<size_t>(vertScrollPos / fnt->getLineSpacing()); eidx = 1 + sidx + static_cast<size_t>(dest_area.getHeight() / fnt->getLineSpacing()); eidx = ceguimin(eidx, numLines); drawArea.d_min.d_y += fnt->getLineSpacing()*static_cast<float>(sidx); // for each formatted line. for (size_t i = sidx; i < eidx; ++i) { Rectf lineRect(drawArea); const MultiLineEditbox::LineInfo& currLine = d_lines[i]; String lineText(w->getTextVisual().substr(currLine.d_startIdx, currLine.d_length)); // offset the font little down so that it's centered within its own spacing const float old_top = lineRect.top(); lineRect.d_min.d_y += (fnt->getLineSpacing() - fnt->getFontHeight()) * 0.5f; // if it is a simple 'no selection area' case if ((currLine.d_startIdx >= w->getSelectionEndIndex()) || ((currLine.d_startIdx + currLine.d_length) <= w->getSelectionStartIndex()) || (w->getSelectionBrushImage() == 0)) { colours = normalTextCol; // render the complete line. fnt->drawText(w->getGeometryBuffer(), lineText, lineRect.getPosition(), &dest_area, colours); } // we have at least some selection highlighting to do else { // Start of actual rendering section. String sect; size_t sectIdx = 0, sectLen; float selStartOffset = 0.0f, selAreaWidth = 0.0f; // render any text prior to selected region of line. if (currLine.d_startIdx < w->getSelectionStartIndex()) { // calculate length of text section sectLen = w->getSelectionStartIndex() - currLine.d_startIdx; // get text for this section sect = lineText.substr(sectIdx, sectLen); sectIdx += sectLen; // get the pixel offset to the beginning of the selection area highlight. selStartOffset = fnt->getTextAdvance(sect); // draw this portion of the text colours = normalTextCol; fnt->drawText(w->getGeometryBuffer(), sect, lineRect.getPosition(), &dest_area, colours); // set position ready for next portion of text lineRect.d_min.d_x += selStartOffset; } // calculate the length of the selected section sectLen = ceguimin(w->getSelectionEndIndex() - currLine.d_startIdx, currLine.d_length) - sectIdx; // get the text for this section sect = lineText.substr(sectIdx, sectLen); sectIdx += sectLen; // get the extent to use as the width of the selection area highlight selAreaWidth = fnt->getTextAdvance(sect); const float text_top = lineRect.top(); lineRect.top(old_top); // calculate area for the selection brush on this line lineRect.left(drawArea.left() + selStartOffset); lineRect.right(lineRect.left() + selAreaWidth); lineRect.bottom(lineRect.top() + fnt->getLineSpacing()); // render the selection area brush for this line colours = selectBrushCol; w->getSelectionBrushImage()->render(w->getGeometryBuffer(), lineRect, &dest_area, colours); // draw the text for this section colours = selectTextCol; fnt->drawText(w->getGeometryBuffer(), sect, lineRect.getPosition(), &dest_area, colours); lineRect.top(text_top); // render any text beyond selected region of line if (sectIdx < currLine.d_length) { // update render position to the end of the selected area. lineRect.d_min.d_x += selAreaWidth; // calculate length of this section sectLen = currLine.d_length - sectIdx; // get the text for this section sect = lineText.substr(sectIdx, sectLen); // render the text for this section. colours = normalTextCol; fnt->drawText(w->getGeometryBuffer(), sect, lineRect.getPosition(), &dest_area, colours); } } // update master position for next line in paragraph. drawArea.d_min.d_y += fnt->getLineSpacing(); } } }
bool ObjParser::parse( std::istream& input ) { reset(); // Read each line of the .obj file while ( readNextLine( input ) && !hasErrors() ) { // Skip lines that are empty if ( isCurrentLineEmpty() ) { continue; } // Split the input line into "words' that are separated by // spaces. The first word is the next obj file command, the others // that follow are arguments to that command std::vector<std::string> tokens; tokenizeCommandString( lineText(), tokens ); assert( tokens.size() > 0 ); // What kind of command is this? if ( tokens[0] == "v" ) { processVertexPosition( tokens ); } else if ( tokens[0] == "vt" ) { processVertexTexCoord( tokens ); } else if ( tokens[0] == "vn" ) { processVertexNormal( tokens ); } else if ( tokens[0] == "g" ) { processGroup( tokens ); } else if ( tokens[0] == "f" ) { processFace( tokens ); } else if ( tokens[0] == "usemtl" ) { processMaterial( tokens ); } else if ( tokens[0] == "mtllib" ) { processMaterialLib( tokens ); } else if ( tokens[0] == "s" ) { // ignore smoothing groups } else { raiseError("Unknown .obj command encountered"); continue; } } // Make sure the last group has at least one face in it if ( m_objdata->currentGroup.empty() == false ) { if ( m_objdata->groups[ m_objdata->currentGroupIndex ].count == 0 ) { raiseError("The last active group didn't have any faces"); } } // Now we're done, make sure to return if the parsing was successful or // not return !hasErrors(); }