Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

guicursor! #337

Merged
merged 36 commits into from
Oct 5, 2021
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
646a89d
Refactor showMode update
citizenmatt Jun 4, 2021
2be0f5c
Reset caret visual position after mode changes
citizenmatt Jun 4, 2021
b50281f
Extract caret shape methods to helper
citizenmatt Jun 4, 2021
6c4bd9c
Refactor caret shape functions
citizenmatt Jun 4, 2021
e859b1c
Remove resetCaret
citizenmatt Jun 4, 2021
9c71b44
Update caret visual attributes when mode changes
citizenmatt Jun 5, 2021
55dedb4
Remove resetShape method
citizenmatt Jun 10, 2021
dfbec1f
Rename "bound" options to "bounded"
citizenmatt Jun 10, 2021
287ba70
Simplify BoundedListOption
citizenmatt Jun 10, 2021
e93a619
Make ListOption generic + create StringListOption
citizenmatt Jun 10, 2021
9f46e19
Fix typo
citizenmatt Jun 10, 2021
43620c2
Add guicursor option
citizenmatt Jun 10, 2021
9cf0a1a
Report errors while parsing guicursor option
citizenmatt Jun 11, 2021
8a55199
Add guicursor to dictionary
citizenmatt Jun 11, 2021
ccd792b
Provide hook for resetting cached values
citizenmatt Jun 28, 2021
d19c776
Minor refactor
citizenmatt Jun 28, 2021
ad19dc0
Use guicursor options to draw caret
citizenmatt Jun 28, 2021
b4d40fa
Rename assert method
citizenmatt Jun 28, 2021
a6087dd
Use replace mode caret for change character action
citizenmatt Jun 28, 2021
2f73dac
Force the caret visible when updating attributes
citizenmatt Jun 28, 2021
f051231
Use guicursor instead of editor cursor settings
citizenmatt Jun 28, 2021
64be751
Use guicursor options to draw ex caret
citizenmatt Jun 29, 2021
1caf380
Improve caret painting in command line
citizenmatt Jun 29, 2021
fe7dc49
Make ExShortcutKeyAction dumb aware
citizenmatt Jun 30, 2021
0288a0f
Use insert caret for select mode
citizenmatt Jun 30, 2021
0d840b2
Merge branch 'master' into feature/guicursor
citizenmatt Jun 30, 2021
d6a99d4
Update to latest EAP
citizenmatt Jun 30, 2021
91585e1
Run linters
citizenmatt Jun 30, 2021
d63e3da
Merge branch 'master' into feature/guicursor
citizenmatt Jul 28, 2021
70a45f3
Treat use block caret option as caret override
citizenmatt Jul 29, 2021
6ab5380
Add tests for caret attributes in nested modes
citizenmatt Aug 10, 2021
ae21727
Merge branch 'master' into feature/guicursor
citizenmatt Sep 27, 2021
74b0e3b
Merge branch 'master' into feature/guicursor
AlexPl292 Sep 29, 2021
c268407
Merge branch 'master' into feature/guicursor
AlexPl292 Sep 29, 2021
3fae2fd
isBlockCursor method doesn't work for UI tests at the moment
AlexPl292 Sep 29, 2021
ee74367
Merge branch 'master' into feature/guicursor
AlexPl292 Oct 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions src/com/maddyhome/idea/vim/command/CommandState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import java.util.*
import javax.swing.KeyStroke

/**
* Used to maintain state while entering a Vim command (operator, motion, text object, etc.)
* Used to maintain state before and while entering a Vim command (operator, motion, text object, etc.)
*/
class CommandState private constructor() {
val commandBuilder = CommandBuilder(getKeyRootNode(MappingMode.NORMAL))
Expand All @@ -45,7 +45,7 @@ class CommandState private constructor() {
var isRecording = false
set(value) {
field = value
updateStatus()
doShowMode()
}
var isDotRepeatInProgress = false

Expand Down Expand Up @@ -78,17 +78,26 @@ class CommandState private constructor() {

fun pushModes(mode: Mode, submode: SubMode) {
val newModeState = ModeState(mode, submode)

logger.debug("Push new mode state: ${newModeState.toSimpleString()}")
logger.debug { "Stack of mode states before push: ${toSimpleString()}" }

val previousMode = currentModeState()
modeStates.push(newModeState)
setMappingMode()
updateStatus()

if (previousMode.mode != newModeState.mode) {
onModeChanged()
}
}

fun popModes() {
val popped = modeStates.pop()
setMappingMode()
updateStatus()
if (popped.mode != mode) {
onModeChanged()
}

logger.debug("Popped mode state: ${popped.toSimpleString()}")
logger.debug { "Stack of mode states after pop: ${toSimpleString()}" }
}
Expand All @@ -107,13 +116,16 @@ class CommandState private constructor() {

private fun resetModes() {
modeStates.clear()
onModeChanged()
setMappingMode()
}

private fun onModeChanged() {
AlexPl292 marked this conversation as resolved.
Show resolved Hide resolved
doShowMode()
}

private fun setMappingMode() {
val modeState = currentModeState()
val newMappingMode = if (modeState.mode == Mode.OP_PENDING) MappingMode.OP_PENDING else modeToMappingMode(mode)
mappingState.mappingMode = newMappingMode
mappingState.mappingMode = modeToMappingMode(mode)
}

@Contract(pure = true)
Expand All @@ -124,7 +136,7 @@ class CommandState private constructor() {
Mode.VISUAL -> MappingMode.VISUAL
Mode.SELECT -> MappingMode.SELECT
Mode.CMD_LINE -> MappingMode.CMD_LINE
else -> error("Unexpected mode: $mode")
Mode.OP_PENDING -> MappingMode.OP_PENDING
}
}

Expand All @@ -137,7 +149,6 @@ class CommandState private constructor() {
val modeState = currentModeState()
popModes()
pushModes(modeState.mode, submode)
updateStatus()
}

fun startDigraphSequence() {
Expand Down Expand Up @@ -183,7 +194,6 @@ class CommandState private constructor() {
resetModes()
commandBuilder.resetInProgressCommandPart(getKeyRootNode(mappingState.mappingMode))
digraphSequence.reset()
updateStatus()
}

fun toSimpleString(): String = modeStates.joinToString { it.toSimpleString() }
Expand Down Expand Up @@ -262,7 +272,7 @@ class CommandState private constructor() {
return if (modeStates.size > 0) modeStates.peek() else defaultModeState
}

private fun updateStatus() {
private fun doShowMode() {
val msg = StringBuilder()
if (showmode.isSet) {
msg.append(getStatusString(modeStates.size - 1))
Expand Down