mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-02-28 02:45:59 +01:00
Better addListener method
This commit is contained in:
parent
177aaebaf8
commit
810440abe7
src/main/java/com/maddyhome/idea/vim/vimscript/services
@ -1,6 +1,7 @@
|
||||
package com.maddyhome.idea.vim.vimscript.services
|
||||
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.option.OptionChangeListener
|
||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimDataType
|
||||
|
||||
interface OptionService {
|
||||
@ -43,6 +44,10 @@ interface OptionService {
|
||||
|
||||
fun showOptions(editor: Editor, nameAndToken: Collection<Pair<String, String>>, scope: Scope, showIntro: Boolean)
|
||||
|
||||
fun addListener(optionName: String, listener: OptionChangeListener<VimDataType>, executeOnAdd: Boolean = false)
|
||||
|
||||
fun removeListener(optionName: String, listener: OptionChangeListener<VimDataType>)
|
||||
|
||||
enum class Scope {
|
||||
LOCAL,
|
||||
GLOBAL
|
||||
|
@ -381,11 +381,15 @@ internal object OptionServiceImpl : OptionService {
|
||||
}
|
||||
}
|
||||
|
||||
internal fun addListener(optionName: String, listener: OptionChangeListener<VimDataType>) {
|
||||
override fun addListener(optionName: String, listener: OptionChangeListener<VimDataType>, executeOnAdd: Boolean) {
|
||||
options.get(optionName)!!.addOptionChangeListener(listener)
|
||||
if (executeOnAdd) {
|
||||
val value = getGlobalOptionValue(optionName)
|
||||
listener.valueChange(value, value)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun removeListener(optionName: String, listener: OptionChangeListener<VimDataType>) {
|
||||
override fun removeListener(optionName: String, listener: OptionChangeListener<VimDataType>) {
|
||||
options.get(optionName)!!.removeOptionChangeListener(listener)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user