-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vim without search / ex commands (#565)
- Loading branch information
1 parent
a8313ba
commit 60eb17d
Showing
14 changed files
with
218 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// VimKeyBufferLabel.swift | ||
// Code | ||
// | ||
// Created by Ken Chung on 12/01/2024. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct VimKeyBufferLabel: View { | ||
@EnvironmentObject var App: MainApp | ||
@State var keyBuffer = "" | ||
|
||
var body: some View { | ||
Text(keyBuffer) | ||
.onReceive( | ||
NotificationCenter.default.publisher( | ||
for: Notification.Name("vim.keybuffer.set"), | ||
object: nil), | ||
perform: { notification in | ||
guard | ||
let sceneIdentifier = | ||
notification.userInfo?["sceneIdentifier"] as? UUID, | ||
sceneIdentifier == App.sceneIdentifier | ||
else { return } | ||
|
||
if let newKeyBuffer = notification.userInfo?["buffer"] as? String { | ||
keyBuffer = newKeyBuffer | ||
} | ||
} | ||
) | ||
.onReceive( | ||
NotificationCenter.default.publisher( | ||
for: Notification.Name("vim.clear"), | ||
object: nil), | ||
perform: { notification in | ||
guard | ||
let sceneIdentifier = | ||
notification.userInfo?["sceneIdentifier"] as? UUID, | ||
sceneIdentifier == App.sceneIdentifier | ||
else { return } | ||
|
||
keyBuffer = "" | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// VimModeLabel.swift | ||
// Code | ||
// | ||
// Created by Ken Chung on 12/01/2024. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct VimModeLabel: View { | ||
@EnvironmentObject var App: MainApp | ||
@State var mode = "--NORMAL--" | ||
@AppStorage("editor.vim.enabled") var editorVimEnabled: Bool = false | ||
|
||
var body: some View { | ||
Text(editorVimEnabled ? mode : "") | ||
.onReceive( | ||
NotificationCenter.default.publisher( | ||
for: Notification.Name("vim.mode.change"), | ||
object: nil), | ||
perform: { notification in | ||
guard | ||
let sceneIdentifier = | ||
notification.userInfo?["sceneIdentifier"] as? UUID, | ||
sceneIdentifier == App.sceneIdentifier | ||
else { return } | ||
|
||
if let newMode = notification.userInfo?["newMode"] as? String { | ||
mode = newMode | ||
} | ||
} | ||
) | ||
.onReceive( | ||
NotificationCenter.default.publisher( | ||
for: Notification.Name("vim.clear"), | ||
object: nil), | ||
perform: { notification in | ||
guard | ||
let sceneIdentifier = | ||
notification.userInfo?["sceneIdentifier"] as? UUID, | ||
sceneIdentifier == App.sceneIdentifier | ||
else { return } | ||
|
||
mode = "" | ||
}) | ||
} | ||
} |