Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.togethersoft.openapi.ide.editor
Interface IdeEditorPositionConverter

public interface IdeEditorPositionConverter

Provides the forward and reverse conversion from the file offset to `TextPosition` object.

The methods of this interfaces are very useful when you are working with text editor - its position-related methods operate with the `TextPosition` objects, while RWI properties like START_POSITION or DEFINITION_START_POSITION contain the offset values.

For example:

     import com.togethersoft.openapi.rwi.RwiProperty;
     import com.togethersoft.openapi.ide.editor.IdeEditor;
     import com.togethersoft.openapi.ide.editor.IdeEditorManager;
     import com.togethersoft.openapi.ide.editor.IdeEditorManagerAccess;
     import com.togethersoft.openapi.ide.editor.IdeEditorVisibleArea;
       ...
     IdeEditorManager editorManager = IdeEditorManagerAccess.getEditorManager();
     int startOffset = Integer.parseInt(someRwiElement.getProperty(RwiProperty.START_POSITION));
     TextPosition textPos = editor.getPositionConverter().offsetToCell(startOffset);
     IdeEditorVisibleArea viewArea = editor.getVisibleArea();
     viewArea.setFirstColumn(textPos.getColumn());
     viewArea.setFirstLine(textPos.getLine());

Author:
  TogetherSoft
See Also: IdeEditor.getPositionConverter()

Method Summary
`int` | `cellToOffset(TextPosition position)` Converts `TextPosition` to offset
`TextPosition` | `offsetToCell(int offset)` Converts offset to `TextPosition`.

Method Detail

### cellToOffset

    public int cellToOffset(TextPosition position)

  Converts `TextPosition` to offset
  Parameters:
    position - the `TextPosition`
  Returns: `int` offset value
  See Also:
    TextPosition

### offsetToCell

    public TextPosition offsetToCell(int offset)

  Converts offset to `TextPosition`.
  Parameters:
    offset - `int` offset
  Returns: `TextPosition`
  See Also:
    TextPosition

Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD