org.eclipse.swt.custom.CaretEvent Java Examples

The following examples show how to use org.eclipse.swt.custom.CaretEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TmfRawEventViewer.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void caretMoved(CaretEvent event) {
    if (fHoldSelection == 0) {
        int line = fStyledText.getLineAtOffset(event.caretOffset);
        if (fTopLineIndex + line < fLines.size()) {
            LineData lineData = fLines.get(fTopLineIndex + line);
            if (!lineData.location.equals(fSelectedLocation)) {
                fSelectedLocation = lineData.location;
                refreshLineBackgrounds();
                sendSelectionEvent(lineData);
            }
        }
    }
    storeCaretPosition(event.time, event.caretOffset);
    if (fHoldSelection == 0) {
        Point caret = fStyledText.getLocationAtOffset(fStyledText.getCaretOffset());
        Point origin = fScrolledComposite.getOrigin();
        if (origin.x > caret.x) {
            origin.x = caret.x;
        } else if (caret.x - origin.x > fScrolledComposite.getSize().x) {
            origin.x = caret.x - fScrolledComposite.getSize().x + 1;
        }
        fScrolledComposite.setOrigin(origin);
    }
}
 
Example #2
Source File: ModulaOccurrencesMarker.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public void setViewer(ISourceViewer viewer, SourceCodeTextEditor sourceEditor) {
    if (this.viewer != null) {
        LogHelper.logError("ModulaOccurrencesMarker.setViewer() is called more than one time!"); // $//$NON-NLS-1$
    } else {
        this.viewer = viewer;
        this.sourceEditor = sourceEditor;
        viewer.getTextWidget().addCaretListener(new CaretListener() {
            @Override
            public void caretMoved(CaretEvent event) {
                caretOffset = event.caretOffset;
                reMark(false);
            }
        });
    }
}
 
Example #3
Source File: GotoMatchingParenHandler.java    From tlaplus with MIT License 5 votes vote down vote up
public void caretMoved(CaretEvent event) {
    // TODO Auto-generated method stub
    editor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(
            null);
    editor.getViewer().getTextWidget().removeCaretListener(this);
    try {
     resource.deleteMarkers(PAREN_ERROR_MARKER_TYPE, false, 99);
 } catch (CoreException e) {
     // TODO Auto-generated catch block
     System.out.println("caretMoved threw exception");
 }

}
 
Example #4
Source File: CustomCaretListener.java    From eclipse-wakatime with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void caretMoved(CaretEvent event) {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    if (window == null) return;
    if (window.getPartService() == null) return;
    if (window.getPartService().getActivePart() == null) return;
    if (window.getPartService().getActivePart().getSite() == null) return;
    if (window.getPartService().getActivePart().getSite().getPage() == null) return;
    if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor() == null) return;
    if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor().getEditorInput() == null) return;

    // log file if one is opened by default
    IEditorInput input = window.getPartService().getActivePart().getSite().getPage().getActiveEditor().getEditorInput();
    if (input instanceof IURIEditorInput) {
        URI uri = ((IURIEditorInput)input).getURI();
        if (uri != null && uri.getPath() != null) {
            String currentFile = uri.getPath();
            long currentTime = System.currentTimeMillis() / 1000;
            if (!currentFile.equals(WakaTime.getDefault().lastFile) || WakaTime.getDefault().lastTime + WakaTime.FREQUENCY * 60 < currentTime) {
                WakaTime.sendHeartbeat(currentFile, WakaTime.getActiveProject(), false);
                WakaTime.getDefault().lastFile = currentFile;
                WakaTime.getDefault().lastTime = currentTime;
            }
        }
    }
}
 
Example #5
Source File: ProofFoldAction.java    From tlaplus with MIT License 4 votes vote down vote up
public void caretMoved(CaretEvent event)
{
    update();
}