public SoftWrapModelImpl( @NotNull EditorEx editor, @NotNull SoftWrapsStorage storage, @NotNull SoftWrapPainter painter, @NotNull SoftWrapApplianceManager applianceManager, @NotNull CachingSoftWrapDataMapper dataMapper) { myEditor = editor; myStorage = storage; myPainter = painter; myApplianceManager = applianceManager; myDataMapper = dataMapper; myFoldBasedApplianceStrategy = new SoftWrapFoldBasedApplianceStrategy(editor); myVisualSizeManager = new SoftWrapAwareVisualSizeManager(painter); myDocumentListeners.add(myApplianceManager); myFoldListeners.add(myApplianceManager); applianceManager.addListener(myVisualSizeManager); EditorSettings settings = myEditor.getSettings(); myAdditionalColumnsCount = settings.getAdditionalColumnsCount(); myUseSoftWraps = settings.isUseSoftWraps(); editor.addPropertyChangeListener(this); }
/** * Called on editor settings change. Current model is expected to drop all cached information * about the settings if any. */ public void reinitSettings() { boolean softWrapsUsedBefore = myUseSoftWraps; EditorSettings settings = myEditor.getSettings(); myUseSoftWraps = settings.isUseSoftWraps(); if (myUseSoftWraps && (!softWrapsUsedBefore || settings.getAdditionalColumnsCount() > 0)) { myApplianceManager.reset(); myDeferredFoldRegions.clear(); myAdditionalColumnsCount = settings.getAdditionalColumnsCount(); settings.setAdditionalColumnsCount(0); myEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER); } else if (!myUseSoftWraps && softWrapsUsedBefore) { settings.setAdditionalColumnsCount(myAdditionalColumnsCount); myEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER); } }