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(); }
@Override public void reset() { EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance(); UISettings uiSettings = UISettings.getInstance(); myCbUseSoftWrapsAtConsole.setSelected(editorSettings.isUseSoftWraps(SoftWrapAppliancePlaces.CONSOLE)); myCommandsHistoryLimitField.setText(Integer.toString(uiSettings.CONSOLE_COMMAND_HISTORY_LIMIT)); myCbOverrideConsoleCycleBufferSize.setEnabled(ConsoleBuffer.useCycleBuffer()); myCbOverrideConsoleCycleBufferSize.setSelected(uiSettings.OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE); myConsoleCycleBufferSizeField.setEnabled(ConsoleBuffer.useCycleBuffer() && uiSettings.OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE); myConsoleCycleBufferSizeField.setText(Integer.toString(uiSettings.CONSOLE_CYCLE_BUFFER_SIZE_KB)); myNegativePanel.resetFrom(mySettings.getNegativePatterns()); myPositivePanel.resetFrom(mySettings.getPositivePatterns()); }
private void parseRawSoftWraps() { if (myOptions.USE_SOFT_WRAPS == null || myOptions.USE_SOFT_WRAPS.isEmpty()) { return; } String[] placeNames = myOptions.USE_SOFT_WRAPS.split(COMPOSITE_PROPERTY_SEPARATOR); for (String placeName : placeNames) { try { SoftWrapAppliancePlaces place = SoftWrapAppliancePlaces.valueOf(placeName); if (place == SoftWrapAppliancePlaces.VCS_DIFF) { // Don't keep separate setting for vcs diff window for now and let it share the value for main editor. continue; } 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(); }
public static void setupConsoleEditor(final EditorEx editor, final boolean foldingOutlineShown, final boolean lineMarkerAreaShown) { ApplicationManager.getApplication().runReadAction(new Runnable() { public void run() { editor.setSoftWrapAppliancePlace(SoftWrapAppliancePlaces.CONSOLE); final EditorSettings editorSettings = editor.getSettings(); editorSettings.setLineMarkerAreaShown(lineMarkerAreaShown); editorSettings.setIndentGuidesShown(false); editorSettings.setLineNumbersShown(false); editorSettings.setFoldingOutlineShown(foldingOutlineShown); editorSettings.setAdditionalPageAtBottom(false); editorSettings.setAdditionalColumnsCount(0); editorSettings.setAdditionalLinesCount(0); editor.putUserData(EDITOR_IS_CONSOLE_VIEW, true); final DelegateColorScheme scheme = updateConsoleColorScheme(editor.getColorsScheme()); editor.setColorsScheme(scheme); scheme.setColor(EditorColors.CARET_ROW_COLOR, null); scheme.setColor(EditorColors.RIGHT_MARGIN_COLOR, null); } }); }
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(); }
public static void setupConsoleEditor(@Nonnull final EditorEx editor, final boolean foldingOutlineShown, final boolean lineMarkerAreaShown) { ApplicationManager.getApplication().runReadAction(() -> { editor.setSoftWrapAppliancePlace(SoftWrapAppliancePlaces.CONSOLE); final EditorSettings editorSettings = editor.getSettings(); editorSettings.setLineMarkerAreaShown(lineMarkerAreaShown); editorSettings.setIndentGuidesShown(false); editorSettings.setLineNumbersShown(false); editorSettings.setFoldingOutlineShown(foldingOutlineShown); editorSettings.setAdditionalPageAtBottom(false); editorSettings.setAdditionalColumnsCount(0); editorSettings.setAdditionalLinesCount(0); editorSettings.setRightMarginShown(false); editorSettings.setCaretRowShown(false); editor.getGutterComponentEx().setPaintBackground(false); editor.putUserData(EDITOR_IS_CONSOLE_VIEW, true); final DelegateColorScheme scheme = updateConsoleColorScheme(editor.getColorsScheme()); if (UISettings.getInstance().PRESENTATION_MODE) { scheme.setEditorFontSize(UISettings.getInstance().PRESENTATION_MODE_FONT_SIZE); } editor.setColorsScheme(scheme); }); }
@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; }
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(); }
public void setUseSoftWraps(boolean use, @NotNull SoftWrapAppliancePlaces place) { boolean update = use ^ myPlacesToUseSoftWraps.contains(place); if (!update) { return; } if (use) { myPlacesToUseSoftWraps.add(place); } else { myPlacesToUseSoftWraps.remove(place); } storeRawSoftWraps(); }
public static void setupConsoleEditor(@NotNull final EditorEx editor, final boolean foldingOutlineShown, final boolean lineMarkerAreaShown) { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { editor.setSoftWrapAppliancePlace(SoftWrapAppliancePlaces.CONSOLE); final EditorSettings editorSettings = editor.getSettings(); editorSettings.setLineMarkerAreaShown(lineMarkerAreaShown); editorSettings.setIndentGuidesShown(false); editorSettings.setLineNumbersShown(false); editorSettings.setFoldingOutlineShown(foldingOutlineShown); editorSettings.setAdditionalPageAtBottom(false); editorSettings.setAdditionalColumnsCount(0); editorSettings.setAdditionalLinesCount(0); editorSettings.setRightMarginShown(false); editorSettings.setCaretRowShown(false); editor.getGutterComponentEx().setPaintBackground(false); editor.putUserData(EDITOR_IS_CONSOLE_VIEW, true); final DelegateColorScheme scheme = updateConsoleColorScheme(editor.getColorsScheme()); if (UISettings.getInstance().PRESENTATION_MODE) { scheme.setEditorFontSize(UISettings.getInstance().PRESENTATION_MODE_FONT_SIZE); } editor.setColorsScheme(scheme); } }); }
@Override public void apply() throws ConfigurationException { EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance(); UISettings uiSettings = UISettings.getInstance(); editorSettings.setUseSoftWraps(myCbUseSoftWrapsAtConsole.isSelected(), SoftWrapAppliancePlaces.CONSOLE); boolean uiSettingsChanged = false; if (isModified(myCommandsHistoryLimitField, uiSettings.CONSOLE_COMMAND_HISTORY_LIMIT)) { uiSettings.CONSOLE_COMMAND_HISTORY_LIMIT = Math.max(0, Math.min(1000, Integer.parseInt(myCommandsHistoryLimitField.getText().trim()))); uiSettingsChanged = true; } if (ConsoleBuffer.useCycleBuffer()) { if (isModified(myCbOverrideConsoleCycleBufferSize, uiSettings.OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE)) { uiSettings.OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE = myCbOverrideConsoleCycleBufferSize.isSelected(); uiSettingsChanged = true; } if (isModified(myConsoleCycleBufferSizeField, uiSettings.CONSOLE_CYCLE_BUFFER_SIZE_KB)) { uiSettings.CONSOLE_CYCLE_BUFFER_SIZE_KB = Math.max(0, Math.min(1024*100, Integer.parseInt(myConsoleCycleBufferSizeField.getText().trim()))); uiSettingsChanged = true; } } if (uiSettingsChanged) { uiSettings.fireUISettingsChanged(); } myNegativePanel.applyTo(mySettings.getNegativePatterns()); myPositivePanel.applyTo(mySettings.getPositivePatterns()); }
public static EditorEx createEditor(Document document, Project project, boolean isViewer) { EditorFactory factory = EditorFactory.getInstance(); EditorEx editor = (EditorEx)(isViewer ? factory.createViewer(document, project) : factory.createEditor(document, project)); editor.putUserData(DiffManagerImpl.EDITOR_IS_DIFF_KEY, Boolean.TRUE); editor.setSoftWrapAppliancePlace(SoftWrapAppliancePlaces.VCS_DIFF); editor.getGutterComponentEx().revalidateMarkup(); return editor; }
public boolean isUseSoftWraps(@NotNull SoftWrapAppliancePlaces place) { if (myPlacesToUseSoftWraps.contains(place)) { return true; } // For now use soft wraps at vcs diff if they are enabled for the main editors. if (place == SoftWrapAppliancePlaces.VCS_DIFF) { return myPlacesToUseSoftWraps.contains(SoftWrapAppliancePlaces.MAIN_EDITOR); } return false; }
protected void customizeEditorSettings(EditorSettings settings) { settings.setLineMarkerAreaShown(myIsEditor); settings.setFoldingOutlineShown(false); settings.setAdditionalColumnsCount(0); settings.setAdditionalLinesCount(0); settings.setAnimatedScrolling(false); if (settings instanceof SettingsImpl) { ((SettingsImpl)settings).setSoftWrapAppliancePlace(SoftWrapAppliancePlaces.PREVIEW); } }
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(); }
@Override public boolean isSelected(AnActionEvent e) { Editor editor = getEditor(e); return editor == null ? EditorSettingsExternalizable.getInstance().isUseSoftWraps(SoftWrapAppliancePlaces.PREVIEW) : editor.getSettings().isUseSoftWraps(); }
@Override public void setSoftWrapAppliancePlace(@NotNull SoftWrapAppliancePlaces place) { mySettings.setSoftWrapAppliancePlace(place); }
public boolean isUseSoftWraps() { return isUseSoftWraps(SoftWrapAppliancePlaces.MAIN_EDITOR); }
public boolean isUseSoftWraps(@NotNull SoftWrapAppliancePlaces place) { return myPlacesToUseSoftWraps.contains(place); }
public void setUseSoftWraps(boolean use) { setUseSoftWraps(use, SoftWrapAppliancePlaces.MAIN_EDITOR); }
public ToggleUseSoftWrapsMenuAction() { super(SoftWrapAppliancePlaces.MAIN_EDITOR, false); }
public ToggleUseSoftWrapsToolbarAction(@NotNull SoftWrapAppliancePlaces place) { super(place, true); copyFrom(ActionManager.getInstance().getAction(IdeActions.ACTION_EDITOR_USE_SOFT_WRAPS)); }
public void setSoftWrapAppliancePlace(SoftWrapAppliancePlaces softWrapAppliancePlace) { mySoftWrapAppliancePlace = softWrapAppliancePlace; }
public ToggleSoftWraps(Editor editor) { super(SoftWrapAppliancePlaces.CONSOLE); myEditor = editor; }
@NotNull @Override public Set<UsageDescriptor> getUsages() throws CollectUsagesException { Set<UsageDescriptor> set = new HashSet<UsageDescriptor>(); EditorSettingsExternalizable es = EditorSettingsExternalizable.getInstance(); addIfDiffers(set, es.isVirtualSpace(), false, "caretAfterLineEnd"); addIfDiffers(set, es.isCaretInsideTabs(), false, "caretInsideTabs"); addIfDiffers(set, es.isAdditionalPageAtBottom(), false, "virtualSpaceAtFileBottom"); addIfDiffers(set, es.isUseSoftWraps(SoftWrapAppliancePlaces.MAIN_EDITOR), false, "softWraps"); addIfDiffers(set, es.isUseSoftWraps(SoftWrapAppliancePlaces.CONSOLE), false, "softWraps.console"); addIfDiffers(set, es.isUseCustomSoftWrapIndent(), false, "softWraps.relativeIndent"); addIfDiffers(set, es.isAllSoftWrapsShown(), false, "softWraps.showAll"); addIfDiffers(set, es.getStripTrailingSpaces(), EditorSettingsExternalizable.STRIP_TRAILING_SPACES_CHANGED, "stripTrailingSpaces"); addIfDiffers(set, es.isEnsureNewLineAtEOF(), false, "ensureNewlineAtEOF"); addIfDiffers(set, es.isShowQuickDocOnMouseOverElement(), false, "quickDocOnMouseHover"); addIfDiffers(set, es.isBlinkCaret(), true, "nonBlinkingCaret"); addIfDiffers(set, es.isBlockCursor(), false, "blockCaret"); addIfDiffers(set, es.isRightMarginShown(), true, "noRightMargin"); addIfDiffers(set, es.isLineNumbersShown(), false, "lineNumbers"); addIfDiffers(set, es.isFoldingOutlineShown(), true, "noFoldingOutline"); addIfDiffers(set, es.isWhitespacesShown() && es.isLeadingWhitespacesShown(), false, "showLeadingWhitespace"); addIfDiffers(set, es.isWhitespacesShown() && es.isInnerWhitespacesShown(), false, "showInnerWhitespace"); addIfDiffers(set, es.isWhitespacesShown() && es.isTrailingWhitespacesShown(), false, "showTrailingWhitespace"); addIfDiffers(set, es.isIndentGuidesShown(), true, "noIndentGuides"); addIfDiffers(set, es.isSmoothScrolling(), true, "noAnimatedScroll"); addIfDiffers(set, es.isDndEnabled(), true, "noDragNDrop"); addIfDiffers(set, es.isWheelFontChangeEnabled(), false, "wheelZoom"); addIfDiffers(set, es.isMouseClickSelectionHonorsCamelWords(), true, "mouseNoCamel"); addIfDiffers(set, es.isVariableInplaceRenameEnabled(), true, "noInplaceRename"); addIfDiffers(set, es.isPreselectRename(), true, "noPreselectOnRename"); addIfDiffers(set, es.isShowInlineLocalDialog(), true, "noInlineDialog"); addIfDiffers(set, es.isRefrainFromScrolling(), false, "minimizeScrolling"); addIfDiffers(set, es.getOptions().SHOW_NOTIFICATION_AFTER_REFORMAT_CODE_ACTION, true, "afterReformatNotification"); addIfDiffers(set, es.getOptions().SHOW_NOTIFICATION_AFTER_OPTIMIZE_IMPORTS_ACTION, true, "afterOptimizeNotification"); addIfDiffers(set, es.isSmartHome(), true, "noSmartHome"); addIfDiffers(set, es.isCamelWords(), false, "camelWords"); RichCopySettings rcs = RichCopySettings.getInstance(); addIfDiffers(set, rcs.isEnabled(), true, "noRichCopy"); CodeInsightSettings cis = CodeInsightSettings.getInstance(); addIfDiffers(set, cis.AUTO_POPUP_PARAMETER_INFO, true, "noParameterAutoPopup"); addIfDiffers(set, cis.AUTO_POPUP_JAVADOC_INFO, false, "javadocAutoPopup"); addIfDiffers(set, cis.AUTO_POPUP_COMPLETION_LOOKUP, true, "noCompletionAutoPopup"); addIfDiffers(set, cis.COMPLETION_CASE_SENSITIVE, CodeInsightSettings.FIRST_LETTER, "completionCaseSensitivity"); addIfDiffers(set, cis.SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS, false, "autoPopupCharComplete"); addIfDiffers(set, cis.AUTOCOMPLETE_ON_CODE_COMPLETION, true, "noAutoCompleteBasic"); addIfDiffers(set, cis.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION, true, "noAutoCompleteSmart"); addIfDiffers(set, cis.SHOW_FULL_SIGNATURES_IN_PARAMETER_INFO, false, "parameterInfoFullSignature"); addIfDiffers(set, cis.getBackspaceMode(), SmartBackspaceMode.AUTOINDENT, "smartBackspace"); addIfDiffers(set, cis.SMART_INDENT_ON_ENTER, true, "noIndentOnEnter"); addIfDiffers(set, cis.INSERT_BRACE_ON_ENTER, true, "noBraceOnEnter"); addIfDiffers(set, cis.JAVADOC_STUB_ON_ENTER, true, "noJavadocOnEnter"); addIfDiffers(set, cis.SMART_END_ACTION, true, "noSmartEnd"); addIfDiffers(set, cis.JAVADOC_GENERATE_CLOSING_TAG, true, "noAutoCloseJavadocTags"); addIfDiffers(set, cis.SURROUND_SELECTION_ON_QUOTE_TYPED, false, "surroundByQuoteOrBrace"); addIfDiffers(set, cis.AUTOINSERT_PAIR_BRACKET, true, "noPairBracketAutoInsert"); addIfDiffers(set, cis.AUTOINSERT_PAIR_QUOTE, true, "noPairQuoteAutoInsert"); addIfDiffers(set, cis.REFORMAT_BLOCK_ON_RBRACE, true, "noReformatOnRBrace"); addIfDiffers(set, cis.REFORMAT_ON_PASTE, CodeInsightSettings.INDENT_EACH_LINE, "reformatOnPaste"); addIfDiffers(set, cis.ADD_IMPORTS_ON_PASTE, CodeInsightSettings.ASK, "importsOnPaste"); addIfDiffers(set, cis.HIGHLIGHT_BRACES, true, "noBracesHighlight"); addIfDiffers(set, cis.HIGHLIGHT_SCOPE, false, "scopeHighlight"); addIfDiffers(set, cis.HIGHLIGHT_IDENTIFIER_UNDER_CARET, true, "noIdentifierUnderCaretHighlight"); addIfDiffers(set, cis.OPTIMIZE_IMPORTS_ON_THE_FLY, false, "autoOptimizeImports"); addIfDiffers(set, cis.ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY, false, "autoAddImports"); return set; }
@Override public void setSoftWrapAppliancePlace(@NotNull SoftWrapAppliancePlaces place) { myDelegate.setSoftWrapAppliancePlace(place); }
public MvnSoftWrapsAction(MvnCommandFolding commandFolding) { super(SoftWrapAppliancePlaces.CONSOLE); this.commandFolding = commandFolding; }
@Override public void setSoftWrapAppliancePlace(@NotNull SoftWrapAppliancePlaces place) { getSoftWrapModel().setPlace(place); mySettings.setSoftWrapAppliancePlace(place); }