<commit_before>/*
 * Copyright 2016 Crown Copyright
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package stroom.editor.client.view;

import com.google.gwt.core.client.Scheduler;
import com.google.gwt.user.client.ui.Composite;
import edu.ycp.cs.dh.acegwt.client.ace.AceEditor;
import edu.ycp.cs.dh.acegwt.client.ace.AceEditorMode;
import edu.ycp.cs.dh.acegwt.client.ace.AceEditorTheme;

import java.util.List;

public class Editor extends Composite {
    private String text = "";
    private boolean textDirty;

    private int firstLineNumber = 1;
    private boolean firstLineNumberDirty;

    private List<Annotation> annotations;
    private boolean annotationsDirty;

    private List<Marker> markers;
    private boolean markersDirty;

    private boolean readOnly;
    private boolean readOnlyDirty;

    private AceEditorMode mode = AceEditorMode.XML;
    private boolean modeDirty = true;

    private AceEditorTheme theme = AceEditorTheme.CHROME;
    private boolean themeDirty = true;

    private boolean showGutter = true;
    private boolean showGutterDirty;

    private int gotoLine;
    private boolean gotoLineDirty;

    private Rect scrollMargin;
    private boolean scrollMarginDirty;

    private boolean useWrapMode;
    private boolean useWrapModeDirty;

    private boolean started;

    private final AceEditor editor;

    public Editor() {
        editor = new AceEditor();
        editor.addAttachHandler(event -> {
            if (event.isAttached()) {
                if (!started) {
                    editor.startEditor();
                    editor.setUseSoftTabs(true);
                    editor.setTabSize(2);
                    started = true;
                }
                updateText();
                updateFirstLineNumber();
                updateAnnotations();
                updateMarkers();
                updateReadOnly();
                updateMode();
                updateTheme();
                updateShowGutter();
                updateGotoLine();
                updateScrollMargin();
                updateUseWrapMode();
            }
        });

        editor.getElement().setClassName("editor");
        initWidget(editor);
    }

    public String getText() {<commit_msg>Issue #211 : Turned off print margins in all editors.<commit_after>/*
 * Copyright 2016 Crown Copyright
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package stroom.editor.client.view;

import com.google.gwt.core.client.Scheduler;
import com.google.gwt.user.client.ui.Composite;
import edu.ycp.cs.dh.acegwt.client.ace.AceEditor;
import edu.ycp.cs.dh.acegwt.client.ace.AceEditorMode;
import edu.ycp.cs.dh.acegwt.client.ace.AceEditorTheme;

import java.util.List;

public class Editor extends Composite {
    private String text = "";
    private boolean textDirty;

    private int firstLineNumber = 1;
    private boolean firstLineNumberDirty;

    private List<Annotation> annotations;
    private boolean annotationsDirty;

    private List<Marker> markers;
    private boolean markersDirty;

    private boolean readOnly;
    private boolean readOnlyDirty;

    private AceEditorMode mode = AceEditorMode.XML;
    private boolean modeDirty = true;

    private AceEditorTheme theme = AceEditorTheme.CHROME;
    private boolean themeDirty = true;

    private boolean showGutter = true;
    private boolean showGutterDirty;

    private int gotoLine;
    private boolean gotoLineDirty;

    private Rect scrollMargin;
    private boolean scrollMarginDirty;

    private boolean useWrapMode;
    private boolean useWrapModeDirty;

    private boolean started;

    private final AceEditor editor;

    public Editor() {
        editor = new AceEditor();
        editor.addAttachHandler(event -> {
            if (event.isAttached()) {
                if (!started) {
                    editor.startEditor();
                    editor.setShowPrintMargin(false);
                    editor.setUseSoftTabs(true);
                    editor.setTabSize(2);
                    started = true;
                }
                updateText();
                updateFirstLineNumber();
                updateAnnotations();
                updateMarkers();
                updateReadOnly();
                updateMode();
                updateTheme();
                updateShowGutter();
                updateGotoLine();
                updateScrollMargin();
                updateUseWrapMode();
            }
        });

        editor.getElement().setClassName("editor");
        initWidget(editor);
    }

    public String getText() {
{'fraction_non_alphanumeric': 0.07902247591865857, 'fraction_numerical': 0.004102747056724938, 'mean_word_length': 2.416819012797075, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '19825', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1409, 'n_words': 433}