com.intellij.openapi.editor.impl.softwrap.SoftWrapAppliancePlaces Java Examples

The following examples show how to use com.intellij.openapi.editor.impl.softwrap.SoftWrapAppliancePlaces. 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: AbstractToggleUseSoftWrapsAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void toggleSoftWraps(@Nonnull Editor editor, @Nullable SoftWrapAppliancePlaces places, boolean state) {
  Point point = editor.getScrollingModel().getVisibleArea().getLocation();
  LogicalPosition anchorPosition = editor.xyToLogicalPosition(point);
  int intraLineShift = point.y - editor.logicalPositionToXY(anchorPosition).y;

  if (places != null) {
    EditorSettingsExternalizable.getInstance().setUseSoftWraps(state, places);
    EditorFactory.getInstance().refreshAllEditors();
  }
  if (editor.getSettings().isUseSoftWraps() != state) {
    editor.getSettings().setUseSoftWraps(state);
  }

  editor.getScrollingModel().disableAnimation();
  editor.getScrollingModel().scrollVertically(editor.logicalPositionToXY(anchorPosition).y + intraLineShift);
  editor.getScrollingModel().enableAnimation();
}
 
Example #2
Source File: DetailViewImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
protected Editor createEditor(@Nullable Project project, Document document, VirtualFile file) {
  EditorEx editor = (EditorEx)EditorFactory.getInstance().createViewer(document, project);

  final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
  EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project);

  editor.setFile(file);
  editor.setHighlighter(highlighter);

  EditorSettings settings = editor.getSettings();
  settings.setAnimatedScrolling(false);
  settings.setRefrainFromScrolling(false);
  settings.setLineNumbersShown(true);
  settings.setFoldingOutlineShown(false);
  if (settings instanceof SettingsImpl) {
    ((SettingsImpl)settings).setSoftWrapAppliancePlace(SoftWrapAppliancePlaces.PREVIEW);
  }
  editor.getFoldingModel().setFoldingEnabled(false);

  return editor;
}
 
Example #3
Source File: EditorSettingsExternalizable.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void parseRawSoftWraps() {
  if (StringUtil.isEmpty(myOptions.USE_SOFT_WRAPS)) {
    return;
  }

  String[] placeNames = myOptions.USE_SOFT_WRAPS.split(COMPOSITE_PROPERTY_SEPARATOR);
  for (String placeName : placeNames) {
    try {
      SoftWrapAppliancePlaces place = SoftWrapAppliancePlaces.valueOf(placeName);
      myPlacesToUseSoftWraps.add(place);
    }
    catch (IllegalArgumentException e) {
      // Ignore bad value
    }
  }

  // There is a possible case that there were invalid/old format values. We want to replace them by up-to-date data.
  storeRawSoftWraps();
}
 
Example #4
Source File: EditorSettingsExternalizable.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void storeRawSoftWraps() {
  StringBuilder buffer = new StringBuilder();
  for (SoftWrapAppliancePlaces placeToStore : myPlacesToUseSoftWraps) {
    buffer.append(placeToStore).append(COMPOSITE_PROPERTY_SEPARATOR);
  }
  if (buffer.length() > 0) {
    buffer.setLength(buffer.length() - 1);
  }
  myOptions.USE_SOFT_WRAPS = buffer.toString();
}
 
Example #5
Source File: FlutterConsoleLogManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Set our preferred settings for the run console.
 */
public static void initConsolePreferences() {
  final PropertiesComponent properties = PropertiesComponent.getInstance();
  if (!properties.getBoolean(consolePreferencesSetKey)) {
    properties.setValue(consolePreferencesSetKey, true);

    // Set our preferred default settings for console text wrapping.
    final EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
    editorSettings.setUseSoftWraps(true, SoftWrapAppliancePlaces.CONSOLE);
  }
}
 
Example #6
Source File: ConsoleViewImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public AnAction[] createConsoleActions() {
  //Initializing prev and next occurrences actions
  final CommonActionsManager actionsManager = CommonActionsManager.getInstance();
  final AnAction prevAction = actionsManager.createPrevOccurenceAction(this);
  prevAction.getTemplatePresentation().setText(getPreviousOccurenceActionName());
  final AnAction nextAction = actionsManager.createNextOccurenceAction(this);
  nextAction.getTemplatePresentation().setText(getNextOccurenceActionName());

  final AnAction switchSoftWrapsAction = new ToggleUseSoftWrapsToolbarAction(SoftWrapAppliancePlaces.CONSOLE) {
    @Override
    protected Editor getEditor(@Nonnull AnActionEvent e) {
      return myEditor;
    }
  };
  final AnAction autoScrollToTheEndAction = new ScrollToTheEndToolbarAction(myEditor);

  List<AnAction> consoleActions = new ArrayList<>();
  consoleActions.add(prevAction);
  consoleActions.add(nextAction);
  consoleActions.add(switchSoftWrapsAction);
  consoleActions.add(autoScrollToTheEndAction);
  consoleActions.add(ActionManager.getInstance().getAction("Print"));
  consoleActions.add(new ClearThisConsoleAction(this));
  consoleActions.addAll(customActions);
  List<ConsoleActionsPostProcessor> postProcessors = ConsoleActionsPostProcessor.EP_NAME.getExtensionList();
  AnAction[] result = consoleActions.toArray(AnAction.EMPTY_ARRAY);
  for (ConsoleActionsPostProcessor postProcessor : postProcessors) {
    result = postProcessor.postProcess(this, result);
  }
  return result;
}
 
Example #7
Source File: SettingsImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public SettingsImpl(@Nullable EditorEx editor, @Nullable Project project, @Nonnull EditorKind kind) {
  myEditor = editor;
  myLanguage = editor != null && project != null ? getDocumentLanguage(project, editor.getDocument()) : null;
  if (EditorKind.CONSOLE.equals(kind)) {
    mySoftWrapAppliancePlace = SoftWrapAppliancePlaces.CONSOLE;
  }
  else if (EditorKind.PREVIEW.equals(kind)) {
    mySoftWrapAppliancePlace = SoftWrapAppliancePlaces.PREVIEW;
  }
  else {
    mySoftWrapAppliancePlace = SoftWrapAppliancePlaces.MAIN_EDITOR;
  }
}
 
Example #8
Source File: ToggleUseSoftWrapsInPreviewAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isSelected(AnActionEvent e) {
  Editor editor = getEditor(e);
  return editor == null
         ? EditorSettingsExternalizable.getInstance().isUseSoftWraps(SoftWrapAppliancePlaces.PREVIEW)
         : editor.getSettings().isUseSoftWraps();
}
 
Example #9
Source File: FlutterConsoleLogManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Set our preferred settings for the run console.
 */
public static void initConsolePreferences() {
  final PropertiesComponent properties = PropertiesComponent.getInstance();
  if (!properties.getBoolean(consolePreferencesSetKey)) {
    properties.setValue(consolePreferencesSetKey, true);

    // Set our preferred default settings for console text wrapping.
    final EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
    editorSettings.setUseSoftWraps(true, SoftWrapAppliancePlaces.CONSOLE);
  }
}
 
Example #10
Source File: EditorSettingsExternalizable.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void setUseSoftWraps(boolean use, @Nonnull SoftWrapAppliancePlaces place) {
  boolean update = use ^ myPlacesToUseSoftWraps.contains(place);
  if (!update) {
    return;
  }

  if (use) {
    myPlacesToUseSoftWraps.add(place);
  }
  else {
    myPlacesToUseSoftWraps.remove(place);
  }
  storeRawSoftWraps();
}
 
Example #11
Source File: ToggleUseSoftWrapsMenuAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ToggleUseSoftWrapsMenuAction() {
  super(SoftWrapAppliancePlaces.MAIN_EDITOR, false);
}
 
Example #12
Source File: ToggleUseSoftWrapsInPreviewAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ToggleUseSoftWrapsInPreviewAction() {
  super(SoftWrapAppliancePlaces.PREVIEW, true);
}
 
Example #13
Source File: EditorSettingsExternalizable.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setUseSoftWraps(boolean use) {
  setUseSoftWraps(use, SoftWrapAppliancePlaces.MAIN_EDITOR);
}
 
Example #14
Source File: ToggleUseSoftWrapsToolbarAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ToggleUseSoftWrapsToolbarAction(@Nonnull SoftWrapAppliancePlaces place) {
  super(place, true);
  copyFrom(ActionManager.getInstance().getAction(IdeActions.ACTION_EDITOR_USE_SOFT_WRAPS));
}
 
Example #15
Source File: EditorSettingsExternalizable.java    From consulo with Apache License 2.0 4 votes vote down vote up
public boolean isUseSoftWraps(@Nonnull SoftWrapAppliancePlaces place) {
  return myPlacesToUseSoftWraps.contains(place);
}
 
Example #16
Source File: SettingsImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setSoftWrapAppliancePlace(SoftWrapAppliancePlaces softWrapAppliancePlace) {
  if (softWrapAppliancePlace != mySoftWrapAppliancePlace) {
    mySoftWrapAppliancePlace = softWrapAppliancePlace;
    fireEditorRefresh();
  }
}
 
Example #17
Source File: SettingsImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public SoftWrapAppliancePlaces getSoftWrapAppliancePlace() {
  return mySoftWrapAppliancePlace;
}
 
Example #18
Source File: EventLogToolWindowFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ToggleSoftWraps(Editor editor) {
  super(SoftWrapAppliancePlaces.CONSOLE);
  myEditor = editor;
}
 
Example #19
Source File: EditorSettingsExternalizable.java    From consulo with Apache License 2.0 4 votes vote down vote up
public boolean isUseSoftWraps() {
  return isUseSoftWraps(SoftWrapAppliancePlaces.MAIN_EDITOR);
}
 
Example #20
Source File: ConsoleLogToolWindowFactory.java    From aem-ide-tooling-4-intellij with Apache License 2.0 4 votes vote down vote up
public ToggleSoftWraps(Editor editor) {
    super(SoftWrapAppliancePlaces.CONSOLE);
    myEditor = editor;
}
 
Example #21
Source File: AbstractToggleUseSoftWrapsAction.java    From consulo with Apache License 2.0 2 votes vote down vote up
/**
 * Creates new <code>AbstractToggleUseSoftWrapsAction</code> object.
 *
 * @param appliancePlace    defines type of the place where soft wraps are applied
 * @param global            indicates if soft wraps should be changed for the current editor only or for the all editors
 *                          used at the target appliance place
 */
public AbstractToggleUseSoftWrapsAction(@Nonnull SoftWrapAppliancePlaces appliancePlace, boolean global) {
  myAppliancePlace = appliancePlace;
  myGlobal = global;
}