mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-19 12:34:02 +02:00
Changes to replace ExEntryPanel with interface and move more code to engine
This commit is contained in:
parent
d00bd8bb25
commit
f5cd2c173f
src/main/java/com/maddyhome/idea/vim
vim-engine/src/main/kotlin/com/maddyhome/idea/vim
@ -38,7 +38,6 @@ import com.maddyhome.idea.vim.helper.MacKeyRepeat;
|
||||
import com.maddyhome.idea.vim.listener.VimListenerManager;
|
||||
import com.maddyhome.idea.vim.newapi.IjVimInjector;
|
||||
import com.maddyhome.idea.vim.ui.StatusBarIconFactory;
|
||||
import com.maddyhome.idea.vim.ui.ex.ExEntryPanel;
|
||||
import com.maddyhome.idea.vim.vimscript.services.VariableService;
|
||||
import com.maddyhome.idea.vim.yank.YankGroupBase;
|
||||
import org.jdom.Element;
|
||||
@ -46,6 +45,7 @@ import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static com.maddyhome.idea.vim.api.VimInjectorKt.injector;
|
||||
import static com.maddyhome.idea.vim.group.EditorGroup.EDITOR_STORE_ELEMENT;
|
||||
import static com.maddyhome.idea.vim.group.KeyGroup.SHORTCUT_CONFLICTS_ELEMENT;
|
||||
import static com.maddyhome.idea.vim.vimscript.services.VimRcService.executeIdeaVimRc;
|
||||
@ -283,11 +283,11 @@ public class VimPlugin implements PersistentStateComponent<Element>, Disposable
|
||||
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
try {
|
||||
VimInjectorKt.injector.getOptionGroup().startInitVimRc();
|
||||
injector.getOptionGroup().startInitVimRc();
|
||||
executeIdeaVimRc(editor);
|
||||
}
|
||||
finally {
|
||||
VimInjectorKt.injector.getOptionGroup().endInitVimRc();
|
||||
injector.getOptionGroup().endInitVimRc();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -352,7 +352,7 @@ public class VimPlugin implements PersistentStateComponent<Element>, Disposable
|
||||
if (unsubscribe) {
|
||||
VimListenerManager.INSTANCE.turnOff();
|
||||
}
|
||||
ExEntryPanel.fullReset();
|
||||
injector.getCommandLine().fullReset();
|
||||
|
||||
// Unregister vim actions in command mode
|
||||
RegisterActions.unregisterActions();
|
||||
|
@ -21,16 +21,15 @@ import com.intellij.util.text.CharSequenceReader
|
||||
import com.maddyhome.idea.vim.KeyHandler.Companion.getInstance
|
||||
import com.maddyhome.idea.vim.KeyProcessResult
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.VimProcessGroupBase
|
||||
import com.maddyhome.idea.vim.api.globalOptions
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.helper.requestFocus
|
||||
import com.maddyhome.idea.vim.helper.vimStateMachine
|
||||
import com.maddyhome.idea.vim.newapi.ij
|
||||
import com.maddyhome.idea.vim.state.mode.Mode
|
||||
import com.maddyhome.idea.vim.state.mode.Mode.NORMAL
|
||||
import com.maddyhome.idea.vim.state.mode.ReturnableFromCmd
|
||||
import com.maddyhome.idea.vim.state.mode.inVisualMode
|
||||
import com.maddyhome.idea.vim.state.mode.returnTo
|
||||
@ -89,10 +88,10 @@ public class ProcessGroup : VimProcessGroupBase() {
|
||||
// This will only get called if somehow the key focus ended up in the editor while the ex entry window
|
||||
// is open. So I'll put focus back in the editor and process the key.
|
||||
|
||||
val panel = ExEntryPanel.getInstance()
|
||||
if (panel.isActive) {
|
||||
val panel = injector.commandLine.getActiveCommandLine()
|
||||
if (panel != null) {
|
||||
processResultBuilder.addExecutionStep { _, _, _ ->
|
||||
requestFocus(panel.entry)
|
||||
requestFocus((panel as ExEntryPanel).entry)
|
||||
panel.handleKey(stroke)
|
||||
}
|
||||
return true
|
||||
|
@ -25,7 +25,8 @@ import javax.swing.KeyStroke
|
||||
|
||||
public class ExEntryPanelService : VimCommandLineService {
|
||||
public override fun getActiveCommandLine(): VimCommandLine? {
|
||||
return ExEntryPanel.instance
|
||||
val instance = ExEntryPanel.instance ?: return null
|
||||
return if (instance.isActive) instance else null
|
||||
}
|
||||
|
||||
override fun inputString(vimEditor: VimEditor, context: ExecutionContext, prompt: String, finishOn: Char?): String? {
|
||||
@ -93,4 +94,8 @@ public class ExEntryPanelService : VimCommandLineService {
|
||||
panel.activate(editor.ij, context.ij, label, initText, count)
|
||||
return panel
|
||||
}
|
||||
|
||||
override fun fullReset() {
|
||||
ExEntryPanel.fullReset()
|
||||
}
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ public class ProcessExCommandEntryAction : MotionActionHandler.SingleExecution()
|
||||
override val motionType: MotionType = MotionType.LINE_WISE
|
||||
|
||||
override fun getOffset(editor: VimEditor, context: ExecutionContext, argument: Argument?, operatorArguments: OperatorArguments): Motion {
|
||||
val panel = injector.commandLine.getActiveCommandLine()!!
|
||||
panel.deactivate(true)
|
||||
if (argument == null) return Motion.Error
|
||||
|
||||
try {
|
||||
// Exit Command-line mode and return to the previous mode before executing the command (this is set to Normal in
|
||||
// startExEntry). Remember from startExEntry that we might still have selection and/or multiple carets, even
|
||||
@ -71,7 +71,7 @@ public class ProcessExCommandEntryAction : MotionActionHandler.SingleExecution()
|
||||
|
||||
logger.debug("processing command")
|
||||
|
||||
val text = panel.text
|
||||
val text = argument.string
|
||||
val shouldSkipHistory = getInstance(editor).mappingState.isExecutingMap() || injector.macro.isExecutingMacro
|
||||
injector.vimscriptExecutor.execute(text, editor, context, shouldSkipHistory, true, CommandLineVimLContext)
|
||||
} catch (e: ExException) {
|
||||
|
@ -23,4 +23,6 @@ public interface VimCommandLineService {
|
||||
* @param count TODO
|
||||
*/
|
||||
public fun create(editor: VimEditor, context: ExecutionContext, label: String, initText: String, count: Int): VimCommandLine
|
||||
|
||||
public fun fullReset()
|
||||
}
|
@ -8,4 +8,14 @@
|
||||
|
||||
package com.maddyhome.idea.vim.api
|
||||
|
||||
public abstract class VimProcessGroupBase : VimProcessGroup
|
||||
import com.maddyhome.idea.vim.KeyHandler.Companion.getInstance
|
||||
import com.maddyhome.idea.vim.state.mode.Mode.NORMAL
|
||||
|
||||
public abstract class VimProcessGroupBase : VimProcessGroup {
|
||||
public override fun cancelExEntry(editor: VimEditor, resetCaret: Boolean) {
|
||||
editor.mode = NORMAL()
|
||||
injector.commandLine.getActiveCommandLine()?.deactivate(true, resetCaret)
|
||||
getInstance().keyHandlerState.leaveCommandLine()
|
||||
getInstance().reset(editor)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user