From 04480ffe78cc10e204b3feafae3d38a5646faa82 Mon Sep 17 00:00:00 2001 From: MituuZ <55958056+MituuZ@users.noreply.github.com> Date: Sun, 16 Jun 2024 15:34:22 +0300 Subject: [PATCH] Add preview font size setting (#68) * Add preview font size setting and tests * Add change notes, increment version and update dependencies * Add settings changes to change log * Clear up changelog commetn * Increase font ranges --- build.gradle.kts | 8 +++---- changelog.md | 5 +++++ .../kotlin/com/mituuz/fuzzier/FuzzyAction.kt | 2 +- .../components/FuzzierSettingsComponent.kt | 22 ++++++++++++++++--- .../fuzzier/components/PreviewEditor.kt | 9 ++++++++ .../settings/FuzzierSettingsConfigurable.kt | 9 +++++--- .../settings/FuzzierSettingsService.kt | 3 ++- src/main/resources/META-INF/plugin.xml | 8 +++---- .../FuzzierSettingsConfigurableTest.kt | 8 ++++--- 9 files changed, 55 insertions(+), 19 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index c94f8822..c2e0a6c6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,10 +1,10 @@ plugins { - id("org.jetbrains.kotlin.jvm") version "1.9.23" - id("org.jetbrains.intellij") version "1.17.3" + id("org.jetbrains.kotlin.jvm") version "2.0.0" + id("org.jetbrains.intellij") version "1.17.4" } group = "com.mituuz" -version = "0.23.0" +version = "0.24.0" repositories { mavenCentral() @@ -12,7 +12,7 @@ repositories { dependencies { testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.2") - testImplementation("org.mockito:mockito-core:5.11.0") + testImplementation("org.mockito:mockito-core:5.12.0") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.2") } diff --git a/changelog.md b/changelog.md index ded4f2c7..c81e4932 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,9 @@ # Changelog +## Version 0.24.0 +- Add an option to change the font size for the preview window +- Some dependency updates +- Separate settings sections + ## Version 0.23.0 - Add an option to show recently used files when opening the popup - Fix mover not working correctly diff --git a/src/main/kotlin/com/mituuz/fuzzier/FuzzyAction.kt b/src/main/kotlin/com/mituuz/fuzzier/FuzzyAction.kt index a57f543b..6c7f6753 100644 --- a/src/main/kotlin/com/mituuz/fuzzier/FuzzyAction.kt +++ b/src/main/kotlin/com/mituuz/fuzzier/FuzzyAction.kt @@ -187,7 +187,7 @@ abstract class FuzzyAction : AnAction() { fuzzierSettingsService.state.fileListSpacing.let { renderer.border = BorderFactory.createEmptyBorder(it, 0, it, 0) } - fuzzierSettingsService.state.fontSize.let { + fuzzierSettingsService.state.fileListFontSize.let { renderer.font = renderer.font.deriveFont(it.toFloat()) } return renderer diff --git a/src/main/kotlin/com/mituuz/fuzzier/components/FuzzierSettingsComponent.kt b/src/main/kotlin/com/mituuz/fuzzier/components/FuzzierSettingsComponent.kt index 02ce9919..4f3a44b7 100644 --- a/src/main/kotlin/com/mituuz/fuzzier/components/FuzzierSettingsComponent.kt +++ b/src/main/kotlin/com/mituuz/fuzzier/components/FuzzierSettingsComponent.kt @@ -34,7 +34,6 @@ import com.intellij.util.ui.FormBuilder import com.intellij.openapi.ui.ComboBox import com.mituuz.fuzzier.components.FuzzierSettingsComponent.SettingsComponent import com.mituuz.fuzzier.entities.FuzzyMatchContainer.FilenameType -import com.mituuz.fuzzier.entities.FuzzyMatchContainer.FilenameType.* import com.mituuz.fuzzier.settings.FuzzierSettingsService import com.mituuz.fuzzier.settings.FuzzierSettingsService.RecentFilesMode import java.awt.Component @@ -107,12 +106,20 @@ class FuzzierSettingsComponent { """.trimIndent(), false) - val fontSize = SettingsComponent(JBIntSpinner(14, 4, 20), "File list font size", + val fileListFontSize = SettingsComponent(JBIntSpinner(14, 4, 30), "File list font size", """ Controls the font size of the file list in the search and selector popups. """.trimIndent(), false) + val previewFontSize = SettingsComponent(JBIntSpinner(0, 0, 30), "Preview font size", + """ + Controls the font size of the preview in the search and selector popups. +
+ When value is zero, use the current font size of the editor. + """.trimIndent(), + false) + val fileListSpacing = SettingsComponent(JBIntSpinner(0, 0, 10), "File list vertical spacing", """ Controls the vertical spacing between the file list items in the search and selector popups. @@ -179,7 +186,9 @@ class FuzzierSettingsComponent { init { setupComponents() jPanel = FormBuilder.createFormBuilder() + .addComponent(JBLabel("General settings")) .addComponent(exclusionSet) + .addSeparator() .addComponent(newTabSelect) .addComponent(recentFileModeSelector) @@ -187,7 +196,11 @@ class FuzzierSettingsComponent { .addComponent(debounceTimerValue) .addComponent(filenameTypeSelector) .addComponent(fileListLimit) - .addComponent(fontSize) + + .addSeparator() + .addComponent(JBLabel("Popup styling")) + .addComponent(fileListFontSize) + .addComponent(previewFontSize) .addComponent(fileListSpacing) .addSeparator() @@ -199,9 +212,12 @@ class FuzzierSettingsComponent { .addComponent(matchWeightStreakModifier) .addComponent(matchWeightFilename) + .addSeparator() .addComponent(startTestBench) .addComponent(testBench) .addComponentFillVertically(JPanel(), 0) + + .addSeparator() .addComponent(resetWindowDimension) .panel } diff --git a/src/main/kotlin/com/mituuz/fuzzier/components/PreviewEditor.kt b/src/main/kotlin/com/mituuz/fuzzier/components/PreviewEditor.kt index ab72c16f..85a496a4 100644 --- a/src/main/kotlin/com/mituuz/fuzzier/components/PreviewEditor.kt +++ b/src/main/kotlin/com/mituuz/fuzzier/components/PreviewEditor.kt @@ -25,6 +25,7 @@ package com.mituuz.fuzzier.components import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.command.WriteCommandAction +import com.intellij.openapi.components.service import com.intellij.openapi.editor.Document import com.intellij.openapi.editor.EditorFactory import com.intellij.openapi.editor.colors.EditorColorsManager @@ -37,6 +38,7 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.util.TextRange import com.intellij.openapi.vfs.VirtualFile import com.intellij.ui.EditorTextField +import com.mituuz.fuzzier.settings.FuzzierSettingsService import kotlin.math.min class PreviewEditor(project: Project?) : EditorTextField( @@ -45,6 +47,7 @@ class PreviewEditor(project: Project?) : EditorTextField( ) { private val toBeContinued: String = "\n\n\n--- End of Fuzzier Preview ---\n--- Open file to see full content ---\n\n\n" private val fileCutOff: Int = 70000 + private val settingsState = service().state companion object { fun getDefaultFileType(): FileType { @@ -62,6 +65,12 @@ class PreviewEditor(project: Project?) : EditorTextField( val globalScheme = EditorColorsManager.getInstance().globalScheme this.font = globalScheme.getFont(null) + + val previewFontSize = settingsState.previewFontSize + if (previewFontSize != 0) { + this.font = this.font.deriveFont(previewFontSize.toFloat()) + } + return editor } diff --git a/src/main/kotlin/com/mituuz/fuzzier/settings/FuzzierSettingsConfigurable.kt b/src/main/kotlin/com/mituuz/fuzzier/settings/FuzzierSettingsConfigurable.kt index 14d9dc66..8f806ae2 100644 --- a/src/main/kotlin/com/mituuz/fuzzier/settings/FuzzierSettingsConfigurable.kt +++ b/src/main/kotlin/com/mituuz/fuzzier/settings/FuzzierSettingsConfigurable.kt @@ -48,7 +48,8 @@ class FuzzierSettingsConfigurable : Configurable { component.debounceTimerValue.getIntSpinner().value = state.debouncePeriod component.filenameTypeSelector.getFilenameTypeComboBox().selectedIndex = state.filenameType.ordinal component.fileListLimit.getIntSpinner().value = state.fileListLimit - component.fontSize.getIntSpinner().value = state.fontSize + component.fileListFontSize.getIntSpinner().value = state.fileListFontSize + component.previewFontSize.getIntSpinner().value = state.previewFontSize component.fileListSpacing.getIntSpinner().value = state.fileListSpacing component.tolerance.getIntSpinner().value = state.tolerance @@ -74,7 +75,8 @@ class FuzzierSettingsConfigurable : Configurable { || state.debouncePeriod != component.debounceTimerValue.getIntSpinner().value || state.filenameType != component.filenameTypeSelector.getFilenameTypeComboBox().selectedItem || state.fileListLimit != component.fileListLimit.getIntSpinner().value - || state.fontSize != component.fontSize.getIntSpinner().value + || state.fileListFontSize != component.fileListFontSize.getIntSpinner().value + || state.previewFontSize != component.previewFontSize.getIntSpinner().value || state.fileListSpacing != component.fileListSpacing.getIntSpinner().value || state.tolerance != component.tolerance.getIntSpinner().value @@ -97,7 +99,8 @@ class FuzzierSettingsConfigurable : Configurable { state.debouncePeriod = component.debounceTimerValue.getIntSpinner().value as Int state.filenameType = FilenameType.entries.toTypedArray()[component.filenameTypeSelector.getFilenameTypeComboBox().selectedIndex] state.fileListLimit = component.fileListLimit.getIntSpinner().value as Int - state.fontSize = component.fontSize.getIntSpinner().value as Int + state.fileListFontSize = component.fileListFontSize.getIntSpinner().value as Int + state.previewFontSize = component.previewFontSize.getIntSpinner().value as Int state.fileListSpacing = component.fileListSpacing.getIntSpinner().value as Int state.tolerance = component.tolerance.getIntSpinner().value as Int diff --git a/src/main/kotlin/com/mituuz/fuzzier/settings/FuzzierSettingsService.kt b/src/main/kotlin/com/mituuz/fuzzier/settings/FuzzierSettingsService.kt index e339d4e3..aa2522f7 100644 --- a/src/main/kotlin/com/mituuz/fuzzier/settings/FuzzierSettingsService.kt +++ b/src/main/kotlin/com/mituuz/fuzzier/settings/FuzzierSettingsService.kt @@ -48,7 +48,8 @@ class FuzzierSettingsService : PersistentStateComponent Version 0.23.0 - - Add an option to show recently used files when opening the popup
- - Fix mover not working correctly
- - Refactor module handling
+

Version 0.24.0

+ - Add an option to change the font size for the preview window
+ - Some dependency updates
+ - Separate settings sections
]]>
diff --git a/src/test/kotlin/com/mituuz/fuzzier/settings/FuzzierSettingsConfigurableTest.kt b/src/test/kotlin/com/mituuz/fuzzier/settings/FuzzierSettingsConfigurableTest.kt index 555e1394..6569b35c 100644 --- a/src/test/kotlin/com/mituuz/fuzzier/settings/FuzzierSettingsConfigurableTest.kt +++ b/src/test/kotlin/com/mituuz/fuzzier/settings/FuzzierSettingsConfigurableTest.kt @@ -45,7 +45,8 @@ class FuzzierSettingsConfigurableTest { state.debouncePeriod = 140 state.filenameType = FILENAME_WITH_PATH_STYLED state.fileListLimit = 200 - state.fontSize = 15 + state.fileListFontSize = 15 + state.previewFontSize = 0 state.fileListSpacing = 2 state.tolerance = 4 @@ -68,7 +69,8 @@ class FuzzierSettingsConfigurableTest { state.debouncePeriod = 140 state.filenameType = FILENAME_WITH_PATH_STYLED state.fileListLimit = 200 - state.fontSize = 15 + state.fileListFontSize = 15 + state.previewFontSize = 0 state.fileListSpacing = 2 state.tolerance = 4 @@ -80,7 +82,7 @@ class FuzzierSettingsConfigurableTest { val settingsConfigurable = FuzzierSettingsConfigurable() settingsConfigurable.createComponent() - state.fontSize = 16 + state.fileListFontSize = 16 assertTrue(settingsConfigurable.isModified()) } } \ No newline at end of file