MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / LocationFromPosition

Method LocationFromPosition

scintilla/src/Editor.cxx:454–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

452}
453
454Point Editor::LocationFromPosition ( SelectionPosition pos )
455{
456 Point pt;
457 RefreshStyleData();
458 if ( pos.Position() == INVALID_POSITION ) {
459 return pt;
460 }
461 int line = pdoc->LineFromPosition ( pos.Position() );
462 int lineVisible = cs.DisplayFromDoc ( line );
463 //Platform::DebugPrintf("line=%d\n", line);
464 AutoSurface surface ( this );
465 AutoLineLayout ll ( llc, RetrieveLineLayout ( line ) );
466 if ( surface && ll ) {
467 // -1 because of adding in for visible lines in following loop.
468 pt.y = ( lineVisible - topLine - 1 ) * vs.lineHeight;
469 pt.x = 0;
470 unsigned int posLineStart = pdoc->LineStart ( line );
471 LayoutLine ( line, surface, vs, ll, wrapWidth );
472 int posInLine = pos.Position() - posLineStart;
473 // In case of very long line put x at arbitrary large position
474 if ( posInLine > ll->maxLineLength ) {
475 pt.x = ll->positions[ll->maxLineLength] - ll->positions[ll->LineStart ( ll->lines )];
476 }
477 for ( int subLine = 0; subLine < ll->lines; subLine++ ) {
478 if ( ( posInLine >= ll->LineStart ( subLine ) ) && ( posInLine <= ll->LineStart ( subLine + 1 ) ) ) {
479 pt.x = ll->positions[posInLine] - ll->positions[ll->LineStart ( subLine )];
480 if ( ll->wrapIndent != 0 ) {
481 int lineStart = ll->LineStart ( subLine );
482 if ( lineStart != 0 ) { // Wrapped
483 pt.x += ll->wrapIndent;
484 }
485 }
486 }
487 if ( posInLine >= ll->LineStart ( subLine ) ) {
488 pt.y += vs.lineHeight;
489 }
490 }
491 pt.x += vs.textStart - xOffset;
492 }
493 pt.x += pos.VirtualSpace() * vs.styles[ll->EndLineStyle()].spaceWidth;
494 return pt;
495}
496
497Point Editor::LocationFromPosition ( int pos )
498{

Callers

nothing calls this directly

Calls 7

SelectionPositionClass · 0.85
PositionMethod · 0.80
DisplayFromDocMethod · 0.80
VirtualSpaceMethod · 0.80
EndLineStyleMethod · 0.80
LineFromPositionMethod · 0.45
LineStartMethod · 0.45

Tested by

no test coverage detected