Search in sources :

Example 11 with CodeMirror

use of net.codemirror.lib.CodeMirror in project gerrit by GerritCodeReview.

the class DiffScreen method onGutterClick.

private GutterClickHandler onGutterClick(final CodeMirror cm) {
    return new GutterClickHandler() {

        @Override
        public void handle(CodeMirror instance, final int line, final String gutterClass, NativeEvent clickEvent) {
            if (Element.as(clickEvent.getEventTarget()).hasClassName(getLineNumberClassName()) && clickEvent.getButton() == NativeEvent.BUTTON_LEFT && !clickEvent.getMetaKey() && !clickEvent.getAltKey() && !clickEvent.getCtrlKey() && !clickEvent.getShiftKey()) {
                cm.setCursor(Pos.create(line));
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                    @Override
                    public void execute() {
                        getCommentManager().newDraftOnGutterClick(cm, gutterClass, line + 1);
                    }
                });
            }
        }
    };
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) GutterClickHandler(net.codemirror.lib.CodeMirror.GutterClickHandler) CodeMirror(net.codemirror.lib.CodeMirror) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 12 with CodeMirror

use of net.codemirror.lib.CodeMirror in project gerrit by GerritCodeReview.

the class SideBySide method moveCursorToSide.

private Runnable moveCursorToSide(CodeMirror cmSrc, DisplaySide sideDst) {
    CodeMirror cmDst = getCmFromSide(sideDst);
    if (cmDst == cmSrc) {
        return () -> {
        };
    }
    DisplaySide sideSrc = cmSrc.side();
    return () -> {
        if (cmSrc.extras().hasActiveLine()) {
            cmDst.setCursor(Pos.create(lineOnOther(sideSrc, cmSrc.getLineNumber(cmSrc.extras().activeLine())).getLine()));
        }
        cmDst.focus();
    };
}
Also used : CodeMirror(net.codemirror.lib.CodeMirror)

Aggregations

CodeMirror (net.codemirror.lib.CodeMirror)12 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)2 LocalComments (com.google.gerrit.client.change.LocalComments)1 CommentInfo (com.google.gerrit.client.changes.CommentInfo)1 LineOnOtherInfo (com.google.gerrit.client.diff.LineMapper.LineOnOtherInfo)1 SkippedLine (com.google.gerrit.client.patches.SkippedLine)1 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)1 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)1 NativeString (com.google.gerrit.client.rpc.NativeString)1 NativeEvent (com.google.gwt.dom.client.NativeEvent)1 ResizeEvent (com.google.gwt.event.logical.shared.ResizeEvent)1 ResizeHandler (com.google.gwt.event.logical.shared.ResizeHandler)1 ClosingEvent (com.google.gwt.user.client.Window.ClosingEvent)1 ClosingHandler (com.google.gwt.user.client.Window.ClosingHandler)1 ChangesHandler (net.codemirror.lib.CodeMirror.ChangesHandler)1 CommandRunner (net.codemirror.lib.CodeMirror.CommandRunner)1 GutterClickHandler (net.codemirror.lib.CodeMirror.GutterClickHandler)1 LineHandle (net.codemirror.lib.CodeMirror.LineHandle)1 ModeInfo (net.codemirror.mode.ModeInfo)1