1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-02-25 02:46:01 +01:00

Update package structure

This commit is contained in:
Alex Plate 2022-02-17 18:27:17 +03:00
parent 54927d0af7
commit d4a1ffa9a9
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
12 changed files with 124 additions and 61 deletions

View File

@ -33,6 +33,9 @@ import com.maddyhome.idea.vim.command.CurrentCommandState
import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.command.MappingState
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.diagnostic.VimLogger
import com.maddyhome.idea.vim.diagnostic.debug
import com.maddyhome.idea.vim.diagnostic.trace
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase
import com.maddyhome.idea.vim.helper.DigraphResult
import com.maddyhome.idea.vim.helper.MessageHelper.message
@ -50,11 +53,8 @@ import com.maddyhome.idea.vim.key.Node
import com.maddyhome.idea.vim.newapi.ExecutionContext
import com.maddyhome.idea.vim.newapi.VimActionsInitiator
import com.maddyhome.idea.vim.newapi.VimEditor
import com.maddyhome.idea.vim.newapi.VimLogger
import com.maddyhome.idea.vim.newapi.debug
import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.newapi.injector
import com.maddyhome.idea.vim.newapi.trace
import com.maddyhome.idea.vim.newapi.vimLogger
import com.maddyhome.idea.vim.ui.ShowCmd.update
import com.maddyhome.idea.vim.ui.ex.ExEntryPanel

View File

@ -22,12 +22,12 @@ import com.maddyhome.idea.vim.action.DuplicableOperatorAction
import com.maddyhome.idea.vim.action.ResetModeAction
import com.maddyhome.idea.vim.action.change.insert.InsertCompletedDigraphAction
import com.maddyhome.idea.vim.action.change.insert.InsertCompletedLiteralAction
import com.maddyhome.idea.vim.diagnostic.debug
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase
import com.maddyhome.idea.vim.key.CommandPartNode
import com.maddyhome.idea.vim.key.Node
import com.maddyhome.idea.vim.key.RootNode
import com.maddyhome.idea.vim.newapi.VimActionsInitiator
import com.maddyhome.idea.vim.newapi.debug
import com.maddyhome.idea.vim.newapi.vimLogger
import org.jetbrains.annotations.TestOnly
import java.util.*

View File

@ -18,6 +18,7 @@
package com.maddyhome.idea.vim.command
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.diagnostic.debug
import com.maddyhome.idea.vim.helper.DigraphResult
import com.maddyhome.idea.vim.helper.DigraphSequence
import com.maddyhome.idea.vim.helper.MessageHelper
@ -30,7 +31,6 @@ import com.maddyhome.idea.vim.helper.vimCommandState
import com.maddyhome.idea.vim.key.CommandPartNode
import com.maddyhome.idea.vim.newapi.VimActionsInitiator
import com.maddyhome.idea.vim.newapi.VimEditor
import com.maddyhome.idea.vim.newapi.debug
import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.newapi.vimLogger
import com.maddyhome.idea.vim.vimscript.services.OptionConstants

View File

@ -0,0 +1,33 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2022 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.newapi
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.ModalityState
class IjVimApplication : VimApplication {
override fun isMainThread(): Boolean {
return ApplicationManager.getApplication().isDispatchThread
}
override fun invokeLater(runnable: () -> Unit, editor: VimEditor) {
ApplicationManager.getApplication()
.invokeLater(runnable, ModalityState.stateForComponent((editor as IjVimEditor).editor.component))
}
}

View File

@ -0,0 +1,49 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2022 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.newapi
import com.intellij.openapi.util.Key
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimDataType
class IjVimLocalOptions : VimLocalOptions {
private val localValuesKey = Key<MutableMap<String, VimDataType>>("localOptions")
override fun getOptions(editor: VimEditor): Map<String, VimDataType> {
val ijEditor = (editor as IjVimEditor).editor
return ijEditor.getUserData(localValuesKey) ?: emptyMap()
}
override fun setOption(editor: VimEditor, optionName: String, value: VimDataType) {
val ijEditor = (editor as IjVimEditor).editor
if (ijEditor.getUserData(localValuesKey) == null) {
ijEditor.putUserData(localValuesKey, mutableMapOf(optionName to value))
} else {
ijEditor.getUserData(localValuesKey)!![optionName] = value
}
}
override fun reset(editor: VimEditor) {
val ijEditor = (editor as IjVimEditor).editor
ijEditor.getUserData(localValuesKey)?.clear()
}
}

View File

@ -19,7 +19,7 @@
package com.maddyhome.idea.vim.newapi
import com.intellij.openapi.diagnostic.Logger
import com.maddyhome.idea.vim.common.VimLogger
import com.maddyhome.idea.vim.diagnostic.VimLogger
class IjVimLogger(private val logger: Logger) : VimLogger {
override fun isTrace(): Boolean = logger.isTraceEnabled

View File

@ -21,18 +21,11 @@ package com.maddyhome.idea.vim.newapi
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.wm.WindowManager
import com.maddyhome.idea.vim.common.VimMessages
import com.maddyhome.idea.vim.vimscript.services.OptionConstants
import com.maddyhome.idea.vim.vimscript.services.OptionService
import java.awt.Toolkit
interface VimMessages {
fun showMessage(message: String?)
fun getMessage(): String?
fun indicateError()
fun clearError()
fun isError(): Boolean
}
class IjVimMessages : VimMessages {
private var message: String? = null
@ -63,9 +56,9 @@ class IjVimMessages : VimMessages {
if (ApplicationManager.getApplication().isUnitTestMode) {
error = true
} else if (!injector.optionService.isSet(
OptionService.Scope.GLOBAL,
OptionConstants.visualbellName,
OptionConstants.visualbellName
OptionService.Scope.GLOBAL,
OptionConstants.visualbellName,
OptionConstants.visualbellName
)
) {
// Vim only allows a beep once every half second - :help 'visualbell'
@ -84,4 +77,4 @@ class IjVimMessages : VimMessages {
}
override fun isError(): Boolean = error
}
}

View File

@ -18,21 +18,7 @@
package com.maddyhome.idea.vim.newapi
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.ModalityState
interface VimApplication {
fun isMainThread(): Boolean
fun invokeLater(action: () -> Unit, editor: VimEditor)
}
class IjVimApplication : VimApplication {
override fun isMainThread(): Boolean {
return ApplicationManager.getApplication().isDispatchThread
}
override fun invokeLater(runnable: () -> Unit, editor: VimEditor) {
ApplicationManager.getApplication()
.invokeLater(runnable, ModalityState.stateForComponent((editor as IjVimEditor).editor.component))
}
}

View File

@ -21,6 +21,8 @@ package com.maddyhome.idea.vim.newapi
import com.intellij.openapi.components.service
import com.intellij.openapi.components.serviceIfCreated
import com.intellij.openapi.diagnostic.Logger
import com.maddyhome.idea.vim.common.VimMessages
import com.maddyhome.idea.vim.diagnostic.VimLogger
import com.maddyhome.idea.vim.group.VimChangeGroup
import com.maddyhome.idea.vim.group.VimKeyGroup
import com.maddyhome.idea.vim.group.VimProcessGroup

View File

@ -18,7 +18,6 @@
package com.maddyhome.idea.vim.newapi
import com.intellij.openapi.util.Key
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimDataType
interface VimLocalOptions {
@ -26,30 +25,3 @@ interface VimLocalOptions {
fun setOption(editor: VimEditor, optionName: String, value: VimDataType)
fun reset(editor: VimEditor)
}
class IjVimLocalOptions : VimLocalOptions {
private val localValuesKey = Key<MutableMap<String, VimDataType>>("localOptions")
override fun getOptions(editor: VimEditor): Map<String, VimDataType> {
val ijEditor = (editor as IjVimEditor).editor
return ijEditor.getUserData(localValuesKey) ?: emptyMap()
}
override fun setOption(editor: VimEditor, optionName: String, value: VimDataType) {
val ijEditor = (editor as IjVimEditor).editor
if (ijEditor.getUserData(localValuesKey) == null) {
ijEditor.putUserData(localValuesKey, mutableMapOf(optionName to value))
} else {
ijEditor.getUserData(localValuesKey)!![optionName] = value
}
}
override fun reset(editor: VimEditor) {
val ijEditor = (editor as IjVimEditor).editor
ijEditor.getUserData(localValuesKey)?.clear()
}
}

View File

@ -0,0 +1,28 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2022 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.common
interface VimMessages {
fun showMessage(message: String?)
fun getMessage(): String?
fun indicateError()
fun clearError()
fun isError(): Boolean
}

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.common
package com.maddyhome.idea.vim.diagnostic
interface VimLogger {
fun isTrace(): Boolean