use of com.intellij.openapi.editor.richcopy.settings.RichCopySettings in project intellij-community by JetBrains.
the class EditorOptionsPanel method isModified.
@Override
public boolean isModified() {
EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();
UISettings uiSettings = UISettings.getInstance();
VcsApplicationSettings vcsSettings = VcsApplicationSettings.getInstance();
// Display
boolean isModified = isModified(myCbSmoothScrolling, editorSettings.isSmoothScrolling());
// Brace highlighting
isModified |= isModified(myCbHighlightBraces, codeInsightSettings.HIGHLIGHT_BRACES);
isModified |= isModified(myCbHighlightScope, codeInsightSettings.HIGHLIGHT_SCOPE);
isModified |= isModified(myCbHighlightIdentifierUnderCaret, codeInsightSettings.HIGHLIGHT_IDENTIFIER_UNDER_CARET);
// Virtual space
isModified |= isModified(myCbUseSoftWrapsAtEditor, editorSettings.isUseSoftWraps(SoftWrapAppliancePlaces.MAIN_EDITOR));
isModified |= isModified(myCbUseCustomSoftWrapIndent, editorSettings.isUseCustomSoftWrapIndent());
isModified |= editorSettings.getCustomSoftWrapIndent() != getCustomSoftWrapIndent();
isModified |= isModified(myCbShowSoftWrapsOnlyOnCaretLine, !editorSettings.isAllSoftWrapsShown());
isModified |= isModified(myCbVirtualSpace, editorSettings.isVirtualSpace());
isModified |= isModified(myCbCaretInsideTabs, editorSettings.isCaretInsideTabs());
isModified |= isModified(myCbVirtualPageAtBottom, editorSettings.isAdditionalPageAtBottom());
// Limits
isModified |= getMaxClipboardContents() != uiSettings.getMaxClipboardContents();
// Paste
// Strip trailing spaces, ensure EOL on EOF on save
isModified |= !getStripTrailingSpacesValue().equals(editorSettings.getStripTrailingSpaces());
isModified |= isModified(myCbKeepTrailingSpacesOnCaretLine, editorSettings.isKeepTrailingSpacesOnCaretLine());
isModified |= isModified(myCbEnsureBlankLineBeforeCheckBox, editorSettings.isEnsureNewLineAtEOF());
isModified |= isModified(myCbShowQuickDocOnMouseMove, editorSettings.isShowQuickDocOnMouseOverElement());
isModified |= isModified(myQuickDocDelayTextField, editorSettings.getQuickDocOnMouseOverElementDelayMillis(), EditorSettingsExternalizable.QUICK_DOC_DELAY_RANGE);
// advanced mouse
isModified |= isModified(myCbEnableDnD, editorSettings.isDndEnabled());
isModified |= isModified(myCbEnableWheelFontChange, editorSettings.isWheelFontChangeEnabled());
isModified |= isModified(myCbHonorCamelHumpsWhenSelectingByClicking, editorSettings.isMouseClickSelectionHonorsCamelWords());
isModified |= isModified(myRbPreferMovingCaret, editorSettings.isRefrainFromScrolling());
isModified |= isModified(myRecentFilesLimitField, UISettings.getInstance().getRecentFilesLimit(), RECENT_FILES_RANGE);
isModified |= isModified(myCbRenameLocalVariablesInplace, editorSettings.isVariableInplaceRenameEnabled());
isModified |= isModified(myPreselectCheckBox, editorSettings.isPreselectRename());
isModified |= isModified(myShowInlineDialogForCheckBox, editorSettings.isShowInlineLocalDialog());
isModified |= isModified(myShowNotificationAfterReformatCodeCheckBox, editorSettings.getOptions().SHOW_NOTIFICATION_AFTER_REFORMAT_CODE_ACTION);
isModified |= isModified(myShowNotificationAfterOptimizeImportsCheckBox, editorSettings.getOptions().SHOW_NOTIFICATION_AFTER_OPTIMIZE_IMPORTS_ACTION);
isModified |= isModified(myShowLSTInGutterCheckBox, vcsSettings.SHOW_LST_GUTTER_MARKERS);
isModified |= isModified(myShowWhitespacesModificationsInLSTGutterCheckBox, vcsSettings.SHOW_WHITESPACES_IN_LST);
isModified |= myErrorHighlightingPanel.isModified();
RichCopySettings settings = RichCopySettings.getInstance();
isModified |= isModified(myCbEnableRichCopyByDefault, settings.isEnabled());
isModified |= !Comparing.equal(settings.getSchemeName(), myRichCopyColorSchemeComboBox.getSelectedItem());
return isModified;
}
use of com.intellij.openapi.editor.richcopy.settings.RichCopySettings in project intellij-community by JetBrains.
the class EditorSettingsStatisticsCollector method getUsages.
@NotNull
@Override
public Set<UsageDescriptor> getUsages() throws CollectUsagesException {
Set<UsageDescriptor> set = new HashSet<>();
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.isUseSoftWraps(SoftWrapAppliancePlaces.PREVIEW), false, "softWraps.preview");
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, "blinkingCaret");
addIfDiffers(set, es.isBlockCursor(), false, "blockCaret");
addIfDiffers(set, es.isRightMarginShown(), true, "rightMargin");
addIfDiffers(set, es.isLineNumbersShown(), true, "lineNumbers");
addIfDiffers(set, es.areGutterIconsShown(), true, "gutterIcons");
addIfDiffers(set, es.isFoldingOutlineShown(), true, "foldingOutline");
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, "indentGuides");
addIfDiffers(set, es.isSmoothScrolling(), true, "animatedScroll");
addIfDiffers(set, es.isDndEnabled(), true, "dragNDrop");
addIfDiffers(set, es.isWheelFontChangeEnabled(), false, "wheelZoom");
addIfDiffers(set, es.isMouseClickSelectionHonorsCamelWords(), true, "mouseCamel");
addIfDiffers(set, es.isVariableInplaceRenameEnabled(), true, "inplaceRename");
addIfDiffers(set, es.isPreselectRename(), true, "preselectOnRename");
addIfDiffers(set, es.isShowInlineLocalDialog(), true, "inlineDialog");
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, "smartHome");
addIfDiffers(set, es.isCamelWords(), false, "camelWords");
addIfDiffers(set, es.isShowParameterNameHints(), true, "editor.inlay.parameter.hints");
RichCopySettings rcs = RichCopySettings.getInstance();
addIfDiffers(set, rcs.isEnabled(), true, "richCopy");
CodeInsightSettings cis = CodeInsightSettings.getInstance();
addIfDiffers(set, cis.AUTO_POPUP_PARAMETER_INFO, true, "parameterAutoPopup");
addIfDiffers(set, cis.AUTO_POPUP_JAVADOC_INFO, false, "javadocAutoPopup");
addIfDiffers(set, cis.AUTO_POPUP_COMPLETION_LOOKUP, true, "completionAutoPopup");
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, "autoCompleteBasic");
addIfDiffers(set, cis.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION, true, "autoCompleteSmart");
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, "indentOnEnter");
addIfDiffers(set, cis.INSERT_BRACE_ON_ENTER, true, "braceOnEnter");
addIfDiffers(set, cis.JAVADOC_STUB_ON_ENTER, true, "javadocOnEnter");
addIfDiffers(set, cis.SMART_END_ACTION, true, "smartEnd");
addIfDiffers(set, cis.JAVADOC_GENERATE_CLOSING_TAG, true, "autoCloseJavadocTags");
addIfDiffers(set, cis.SURROUND_SELECTION_ON_QUOTE_TYPED, false, "surroundByQuoteOrBrace");
addIfDiffers(set, cis.AUTOINSERT_PAIR_BRACKET, true, "pairBracketAutoInsert");
addIfDiffers(set, cis.AUTOINSERT_PAIR_QUOTE, true, "pairQuoteAutoInsert");
addIfDiffers(set, cis.REFORMAT_BLOCK_ON_RBRACE, true, "reformatOnRBrace");
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, "bracesHighlight");
addIfDiffers(set, cis.HIGHLIGHT_SCOPE, false, "scopeHighlight");
addIfDiffers(set, cis.HIGHLIGHT_IDENTIFIER_UNDER_CARET, true, "identifierUnderCaretHighlight");
addIfDiffers(set, cis.ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY, false, "autoAddImports");
return set;
}
use of com.intellij.openapi.editor.richcopy.settings.RichCopySettings in project intellij-community by JetBrains.
the class ForcedCopyModeAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
RichCopySettings settings = RichCopySettings.getInstance();
boolean savedValue = settings.isEnabled();
try {
settings.setEnabled(myRichCopyEnabled);
ActionManager.getInstance().getAction(IdeActions.ACTION_EDITOR_COPY).actionPerformed(e);
} finally {
settings.setEnabled(savedValue);
}
}
use of com.intellij.openapi.editor.richcopy.settings.RichCopySettings in project intellij-community by JetBrains.
the class TextWithMarkupProcessor method collectTransferableData.
@NotNull
@Override
public List<RawTextWithMarkup> collectTransferableData(PsiFile file, Editor editor, int[] startOffsets, int[] endOffsets) {
if (!RichCopySettings.getInstance().isEnabled()) {
return Collections.emptyList();
}
try {
RichCopySettings settings = RichCopySettings.getInstance();
List<Caret> carets = editor.getCaretModel().getAllCarets();
Caret firstCaret = carets.get(0);
final int indentSymbolsToStrip;
final int firstLineStartOffset;
if (Registry.is("editor.richcopy.strip.indents") && carets.size() == 1) {
Pair<Integer, Integer> p = calcIndentSymbolsToStrip(editor.getDocument(), firstCaret.getSelectionStart(), firstCaret.getSelectionEnd());
firstLineStartOffset = p.first;
indentSymbolsToStrip = p.second;
} else {
firstLineStartOffset = firstCaret.getSelectionStart();
indentSymbolsToStrip = 0;
}
logInitial(editor, startOffsets, endOffsets, indentSymbolsToStrip, firstLineStartOffset);
CharSequence text = editor.getDocument().getCharsSequence();
EditorColorsScheme schemeToUse = settings.getColorsScheme(editor.getColorsScheme());
EditorHighlighter highlighter = HighlighterFactory.createHighlighter(file.getViewProvider().getVirtualFile(), schemeToUse, file.getProject());
highlighter.setText(text);
MarkupModel markupModel = DocumentMarkupModel.forDocument(editor.getDocument(), file.getProject(), false);
Context context = new Context(text, schemeToUse, indentSymbolsToStrip);
int endOffset = 0;
Caret prevCaret = null;
for (Caret caret : carets) {
int caretSelectionStart = caret.getSelectionStart();
int caretSelectionEnd = caret.getSelectionEnd();
int startOffsetToUse;
int additionalShift = 0;
if (caret == firstCaret) {
startOffsetToUse = firstLineStartOffset;
} else {
startOffsetToUse = caretSelectionStart;
assert prevCaret != null;
String prevCaretSelectedText = prevCaret.getSelectedText();
// Block selection fills short lines by white spaces
int fillStringLength = prevCaretSelectedText == null ? 0 : prevCaretSelectedText.length() - (prevCaret.getSelectionEnd() - prevCaret.getSelectionStart());
context.addCharacter(endOffset + fillStringLength);
additionalShift = fillStringLength + 1;
}
context.reset(endOffset - caretSelectionStart + additionalShift);
endOffset = caretSelectionEnd;
prevCaret = caret;
if (endOffset <= startOffsetToUse) {
continue;
}
MyMarkupIterator markupIterator = new MyMarkupIterator(text, new CompositeRangeIterator(schemeToUse, new HighlighterRangeIterator(highlighter, startOffsetToUse, endOffset), new MarkupModelRangeIterator(markupModel, schemeToUse, startOffsetToUse, endOffset)), schemeToUse);
try {
context.iterate(markupIterator, endOffset);
} finally {
markupIterator.dispose();
}
}
SyntaxInfo syntaxInfo = context.finish();
logSyntaxInfo(syntaxInfo);
createResult(syntaxInfo, editor);
return ObjectUtils.notNull(myResult, Collections.<RawTextWithMarkup>emptyList());
} catch (Exception e) {
// catching the exception so that the rest of copy/paste functionality can still work fine
LOG.error(e);
}
return Collections.emptyList();
}
use of com.intellij.openapi.editor.richcopy.settings.RichCopySettings in project intellij-community by JetBrains.
the class EditorOptionsPanel method apply.
@Override
public void apply() throws ConfigurationException {
EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();
UISettings uiSettings = UISettings.getInstance();
VcsApplicationSettings vcsSettings = VcsApplicationSettings.getInstance();
// Display
editorSettings.setSmoothScrolling(myCbSmoothScrolling.isSelected());
ComponentSettings.getInstance().setSmoothScrollingEnabled(myCbSmoothScrolling.isSelected());
// Brace Highlighting
codeInsightSettings.HIGHLIGHT_BRACES = myCbHighlightBraces.isSelected();
codeInsightSettings.HIGHLIGHT_SCOPE = myCbHighlightScope.isSelected();
codeInsightSettings.HIGHLIGHT_IDENTIFIER_UNDER_CARET = myCbHighlightIdentifierUnderCaret.isSelected();
clearAllIdentifierHighlighters();
// Virtual space
editorSettings.setUseSoftWraps(myCbUseSoftWrapsAtEditor.isSelected(), SoftWrapAppliancePlaces.MAIN_EDITOR);
editorSettings.setUseCustomSoftWrapIndent(myCbUseCustomSoftWrapIndent.isSelected());
editorSettings.setCustomSoftWrapIndent(getCustomSoftWrapIndent());
editorSettings.setAllSoftwrapsShown(!myCbShowSoftWrapsOnlyOnCaretLine.isSelected());
editorSettings.setVirtualSpace(myCbVirtualSpace.isSelected());
editorSettings.setCaretInsideTabs(myCbCaretInsideTabs.isSelected());
editorSettings.setAdditionalPageAtBottom(myCbVirtualPageAtBottom.isSelected());
// Limits
boolean uiSettingsChanged = false;
int maxClipboardContents = getMaxClipboardContents();
if (uiSettings.getMaxClipboardContents() != maxClipboardContents) {
uiSettings.setMaxClipboardContents(maxClipboardContents);
uiSettingsChanged = true;
}
if (uiSettingsChanged) {
uiSettings.fireUISettingsChanged();
}
if (STRIP_NONE.equals(myStripTrailingSpacesCombo.getSelectedItem())) {
editorSettings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE);
} else if (STRIP_CHANGED.equals(myStripTrailingSpacesCombo.getSelectedItem())) {
editorSettings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_CHANGED);
} else {
editorSettings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_WHOLE);
}
editorSettings.setKeepTrailingSpacesOnCaretLine(myCbKeepTrailingSpacesOnCaretLine.isSelected());
editorSettings.setEnsureNewLineAtEOF(myCbEnsureBlankLineBeforeCheckBox.isSelected());
if (myCbShowQuickDocOnMouseMove.isSelected() ^ editorSettings.isShowQuickDocOnMouseOverElement()) {
boolean enabled = myCbShowQuickDocOnMouseMove.isSelected();
editorSettings.setShowQuickDocOnMouseOverElement(enabled);
ServiceManager.getService(QuickDocOnMouseOverManager.class).setEnabled(enabled);
}
int quickDocDelay = getQuickDocDelayFromGui();
if (quickDocDelay != -1) {
editorSettings.setQuickDocOnMouseOverElementDelayMillis(quickDocDelay);
}
editorSettings.setDndEnabled(myCbEnableDnD.isSelected());
editorSettings.setWheelFontChangeEnabled(myCbEnableWheelFontChange.isSelected());
editorSettings.setMouseClickSelectionHonorsCamelWords(myCbHonorCamelHumpsWhenSelectingByClicking.isSelected());
editorSettings.setRefrainFromScrolling(myRbPreferMovingCaret.isSelected());
editorSettings.setVariableInplaceRenameEnabled(myCbRenameLocalVariablesInplace.isSelected());
editorSettings.setPreselectRename(myPreselectCheckBox.isSelected());
editorSettings.setShowInlineLocalDialog(myShowInlineDialogForCheckBox.isSelected());
editorSettings.getOptions().SHOW_NOTIFICATION_AFTER_REFORMAT_CODE_ACTION = myShowNotificationAfterReformatCodeCheckBox.isSelected();
editorSettings.getOptions().SHOW_NOTIFICATION_AFTER_OPTIMIZE_IMPORTS_ACTION = myShowNotificationAfterOptimizeImportsCheckBox.isSelected();
boolean updateVcsSettings = false;
if (vcsSettings.SHOW_WHITESPACES_IN_LST != myShowWhitespacesModificationsInLSTGutterCheckBox.isSelected()) {
vcsSettings.SHOW_WHITESPACES_IN_LST = myShowWhitespacesModificationsInLSTGutterCheckBox.isSelected();
updateVcsSettings = true;
}
if (vcsSettings.SHOW_LST_GUTTER_MARKERS != myShowLSTInGutterCheckBox.isSelected()) {
vcsSettings.SHOW_LST_GUTTER_MARKERS = myShowLSTInGutterCheckBox.isSelected();
updateVcsSettings = true;
}
if (updateVcsSettings) {
ApplicationManager.getApplication().getMessageBus().syncPublisher(LineStatusTrackerSettingListener.TOPIC).settingsUpdated();
}
reinitAllEditors();
String temp = myRecentFilesLimitField.getText();
if (temp.trim().length() > 0) {
try {
int newRecentFilesLimit = Integer.parseInt(temp);
if (newRecentFilesLimit > 0 && uiSettings.getRecentFilesLimit() != newRecentFilesLimit) {
uiSettings.setRecentFilesLimit(newRecentFilesLimit);
uiSettingsChanged = true;
}
} catch (NumberFormatException ignored) {
}
}
if (uiSettingsChanged) {
uiSettings.fireUISettingsChanged();
}
myErrorHighlightingPanel.apply();
RichCopySettings settings = RichCopySettings.getInstance();
settings.setEnabled(myCbEnableRichCopyByDefault.isSelected());
Object item = myRichCopyColorSchemeComboBox.getSelectedItem();
if (item instanceof String) {
settings.setSchemeName(item.toString());
}
restartDaemons();
}
Aggregations