Example #1
0
  private void init(
      final int visibleWidth,
      @NotNull String fileText,
      @NotNull TestFileType fileType,
      final int symbolWidth)
      throws IOException {
    init(fileText, fileType);
    myEditor.getSettings().setUseSoftWraps(true);
    SoftWrapModelImpl model = (SoftWrapModelImpl) myEditor.getSoftWrapModel();
    model.reinitSettings();

    SoftWrapApplianceManager applianceManager = model.getApplianceManager();
    applianceManager.setWidthProvider(
        new SoftWrapApplianceManager.VisibleAreaWidthProvider() {
          @Override
          public int getVisibleAreaWidth() {
            return visibleWidth;
          }
        });

    if (symbolWidth > 0) {
      model.setEditorTextRepresentationHelper(
          new DefaultEditorTextRepresentationHelper(myEditor) {
            @Override
            public int charWidth(char c, int fontType) {
              return symbolWidth;
            }
          });
    }

    applianceManager.registerSoftWrapIfNecessary();
  }