void KEdit::posToRowCol(unsigned int pos, unsigned int &line, unsigned int &col) { for (line = 0; line < static_cast<uint>(numLines()) && col <= pos; line++) { col += lineLength(line)+1; } line--; col = pos - col + lineLength(line) + 1; }
/** Writes the current content line to the stream after conversion to UTF-8. Performs any necessary folding. @internalTechnology */ void CICalContentLineWriter::WriteContentLineL() { TRACE_ENTRY_POINT; // Convert to UTF-8 for writing HBufC8* tmpLine = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*iCurrentLine); CleanupStack::PushL(tmpLine); TInt pos(0); TInt remaining(tmpLine->Length()); // Fold the line if longer than 75 octets TInt lineLength(KICalMaxLineLength); while (remaining > lineLength) { iWriteStream.WriteL(tmpLine->Mid(pos), lineLength); iWriteStream.WriteL(KICalFoldLine); pos += lineLength; remaining -= lineLength; lineLength = KICalMaxFoldedLineLength; } // Complete the line iWriteStream.WriteL(tmpLine->Mid(pos)); iWriteStream.WriteL(KICalCRLF); CleanupStack::PopAndDestroy(tmpLine); iCurrentLine->Des().SetLength(0); TRACE_EXIT_POINT; }
bool getRowPtr(_UByteCV*& _rowPtr, ImageDim _rowIndex, bool _checkRange) const { assert(m_ptr != NULL); if (_checkRange && _rowIndex >= m_accessableRows) return false; _rowPtr = m_ptr + _rowIndex*lineLength(); return true; }
// // length of the sector lineout // static double calcLineoutLength(sector_t *sector) { linechain_t *chain; double length; length = 0.0; chain = sector->sectorLines; while(NULL != chain) // sum up lengths of all lines { length += lineLength(chain->line); chain = chain->next; } return length; }
void MailMessage::appendRecipient(const MailRecipient& recipient, std::string& str) { if (!str.empty()) str.append(", "); const std::string& realName = recipient.getRealName(); const std::string& address = recipient.getAddress(); std::string rec; if (!realName.empty()) { quote(realName, rec, true); rec.append(" "); } rec.append("<"); rec.append(address); rec.append(">"); if (lineLength(str) + rec.length() > 70) str.append("\r\n\t"); str.append(rec); }
/** Set cursor position in one dimension manner. */ void TextFieldBody::setCursorPosition(int position) { if (position < 0) { home(FALSE); } else if (position > length()) { end(FALSE); } else { /* Iterate each line's length */ for (int line = 0; line < numLines(); line++) { int numChars = lineLength(line); if (position <= numChars) { QMultiLineEdit::setCursorPosition(line, position); return; } position -= numChars + 1; /* EOL is counted as one char */ } } /* Should not reach here */ }
/** Get cursor position in one dimension manner. */ int TextFieldBody::getCursorPosition() { int position; if (atBeginning()) { position = 0; } else if (atEnd()) { position = length(); } else { int line, col; QMultiLineEdit::getCursorPosition(&line, &col); /* Iterate each line's length */ for (position = col, line--; line >= 0; line--) { position += lineLength(line) + 1; /* EOL is counted as one char */ } } return position; }
double Scanner::projectLineAgainstPElem (const PhantomElement& pelem, double x1, double y1, double x2, double y2) { if (! pelem.clipLineWorldCoords (x1, y1, x2, y2)) { if (m_trace == Trace::TRACE_CLIPPING) cio_tone (1000., 0.05); return (0.0); } #ifdef HAVE_SGP if (m_pSGP && m_trace == Trace::TRACE_CLIPPING) { m_pSGP->setRasterOp (RO_XOR); m_pSGP->moveAbs (x1, y1); m_pSGP->lineAbs (x2, y2); cio_tone (8000., 0.05); m_pSGP->moveAbs (x1, y1); m_pSGP->lineAbs (x2, y2); m_pSGP->setRasterOp (RO_SET); } #endif double len = lineLength (x1, y1, x2, y2); return (len * pelem.atten()); }
int KileScriptDocument::lineLength() { return lineLength( m_view->cursorPosition().line() ); }
void StaffmodeWnd::DrawMaze(ColorBuf *destCBuf) { D3DXVECTOR3 inVec[4]; float rad,leng,ratio; int i,j,bSetDiff; dest.buf = (RGB24 *)destCBuf->pBuf; dest.sx = destCBuf->width; dest.sy = destCBuf->height; for(j=0;j<4;j++){ int ddeg = (deg +90*j) % 360; if(ddeg>110 && ddeg<250)continue; bSetDiff = 0; for(i=0;i<4;i++){ rad = (float)ddeg-45+90*(i&1); leng = 7.07107f; inVec[i].x = leng *sinf(DEGtoRAD(rad)); inVec[i].y = 5.0f -(i/2)*10.0f; inVec[i].z = leng *cosf(DEGtoRAD(rad)); } for(i=0;i<4;i++){ if(inVec[i].z >= 0)continue; if(i==1 || i==3){ inVec[i].x = (inVec[i].x -inVec[i-1].x)/(inVec[i].z -inVec[i-1].z) *(-inVec[i-1].z) + inVec[i-1].x; inVec[i].z = 0; leng = lineLength(inVec[i-1].x,inVec[i-1].z,inVec[i].x,inVec[i].z); bSetDiff = 1; }else{ inVec[i].x = (inVec[i].x -inVec[i+1].x)/(inVec[i].z -inVec[i+1].z) *(-inVec[i+1].z) + inVec[i+1].x; inVec[i].z = 0; leng = lineLength(inVec[i+1].x,inVec[i+1].z,inVec[i].x,inVec[i].z); bSetDiff = 2; } ratio = (7.07107f*1.142f) /leng ; } for(i=0;i<4;i++){ GetMazeVec(&inVec[i],0); } if(bSetDiff==1)for(i=1;i<4;i+=2){ leng = lineLength(inVec[i-1].x,inVec[i-1].y,inVec[i].x,inVec[i].y); leng = leng *ratio; rad = atan2f(inVec[i].x-inVec[i-1].x,-(inVec[i].y-inVec[i-1].y)); float rtd = RADtoDEG(rad); inVec[i].x = inVec[i-1].x +leng *sinf(rad); inVec[i].y = inVec[i-1].y -leng *cosf(rad); } if(bSetDiff==2)for(i=0;i<4;i+=2){ leng = lineLength(inVec[i+1].x,inVec[i+1].y,inVec[i].x,inVec[i].y); leng = leng *ratio; rad = atan2f(inVec[i].x-inVec[i+1].x,-(inVec[i].y-inVec[i+1].y)); float rtd = RADtoDEG(rad); inVec[i].x = inVec[i+1].x +leng *sinf(rad); inVec[i].y = inVec[i+1].y -leng *cosf(rad); } int light; if(ddeg < 180){ light = 128 -100*ddeg/180; }else{ light = 128 -100*(360-ddeg)/180; } if(3!=bTurn){ DRW_DrawPOLY4_FB_Simple(&dest, &src[j], (int)inVec[0].x, (int)inVec[0].y, (int)inVec[1].x, (int)inVec[1].y, (int)inVec[2].x, (int)inVec[2].y, (int)inVec[3].x, (int)inVec[3].y, light,light,light); }else{ D3DXVECTOR2 pt[4]; if(ddeg == 0){ pt[0].x = inVec[0].x -177*moveStep/18; pt[1].x = inVec[1].x +177*moveStep/18; pt[2].x = inVec[2].x -177*moveStep/18; pt[3].x = inVec[3].x +177*moveStep/18; }else if(ddeg == 90){ for(i=0;i<4;i++){ pt[i].x = inVec[i].x +177*moveStep/18; } }else if(ddeg == 270){ for(i=0;i<4;i++){ pt[i].x = inVec[i].x -177*moveStep/18; } } for(i=0;i<4;i++){ if(i/2==0){ pt[i].y = inVec[i].y -133*moveStep/18; }else{ pt[i].y = inVec[i].y +133*moveStep/18; } } DRW_DrawPOLY4_FB_Simple(&dest, &src[j], (int)pt[0].x, (int)pt[0].y, (int)pt[1].x, (int)pt[1].y, (int)pt[2].x, (int)pt[2].y, (int)pt[3].x, (int)pt[3].y, light,light,light); } } } //StaffmodeWnd::DrawMaze
/** * load * This function takes a command line argument containing * the name of a file and loads the contents of the file * into memory byte by byte until there is an error * @param: argc: the number of args * args: the name of the file * @return: goodLine: returns false if an error was found */ bool load(int argc, char *args) { bool goodLine = TRUE; int lineNumber = 1; if(validFileName(args)){ FILE * fi; fi = fopen(args,"r"); char record[80]; int prevAdr = -1,startAdr,lineSize; int firstLine = 0; int loop; int dataLoc,byteLoc; int dataLength; bool lastLineData; bool memError; while(fgets(record,80,fi)!=NULL && goodLine){ dataLoc = 9; //Where data starts byteLoc = 0; //Which byte of data to get if (isAddress(record)){ startAdr=setLastAddress(record); //Address in a record } int lineSize = lineLength(record); //Length of record if(record[lineSize]!='\n') { discardRest(record,fi); } //Calls the checkLine if(checkLine(record)) { dataLength = lengthOfData(record); //Length of data in a record //If the record isn't the first line of the file if(firstLine==1) { if(!(lastLineData&&startAdr>prevAdr)) { //If there was data on the last line make sure the address is bigger goodLine = FALSE; //printf("Error on line %d\n",lineNumber); } } //If the record is the first line else{ if(isAddress(record)) { firstLine = 1; } } } //checkLine returns false else{ //printf("Error on line %d\n",lineNumber); goodLine = FALSE; } //If all checks have passed if(goodLine){ //Goes through the data for(loop = 0; loop < dataLength;loop+=2){ //Adds the byte to memory putByte(startAdr,grabDataByte(record,byteLoc),&memError); //printf("%x\n",grabDataByte(record,byteLoc)); startAdr++; byteLoc+=2; } //puts(record); //Output record prevAdr = startAdr - 1; lineNumber++; lastLineData = isData(record); } else if(goodLine == FALSE){ printf("Error on line %d\n", lineNumber); puts(record); } } fclose(fi); } //If the file didn't open else{ goodLine = FALSE; printf("Error opening file"); } return goodLine; }