This repository has been archived by the owner on Dec 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 135
Add new feature: Vim mode #368
Open
steewbsd
wants to merge
34
commits into
Bios-Marcel:master
Choose a base branch
from
steewbsd:vim
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
10de420
Started working on vim event modifiers
invalid-email-address f0515f4
Added most of the new vim keys (needs rework)
invalid-email-address a15d76c
Partially working vim movements. Cannot get ESC key to work.
invalid-email-address 26d6a15
Removed some useless lines
invalid-email-address 714e23b
Vim mode working. Added simulation keys inside some lists.
invalid-email-address ce00566
Dynamic status bar and shortcuts menu
invalid-email-address 56fcff0
Dynamic status bar and shortcuts menu
invalid-email-address 2016462
Fixed some keybindings
invalid-email-address 2c86b71
Merged from upstream
invalid-email-address 7219309
Fixed little issues
invalid-email-address 155c160
Edited changelog
invalid-email-address ad82e0e
Fixed go.sum
invalid-email-address 9e0b15d
Vim directional keys working everywhere (only in visual mode)
steewbsd 1b1c0c1
Added brief manpage of vim mode
steewbsd 86df4fd
Fixed normal mode binding
steewbsd a2cc7de
Removed useless go sum lines
steewbsd 5050954
Added replace instruction in go.mod
steewbsd 422d825
Removed upstream fork from go.mod
steewbsd 87a8946
Fixed escape binding
steewbsd b55c343
Fixed shortcuts dialog inconsistency
steewbsd b38cbd9
Fixed weird behaviour in text input
steewbsd 6de4e41
Changed expand selection shortcuts, conflicted with movement
steewbsd eea5b6b
Vim can now be toggled in command mode
steewbsd 1cc4e20
Added vim command synopsis toggle line
steewbsd 9e8bd4c
Moved VimMode to app instead of config
steewbsd b2bd175
Merged with upstream, fixed conflicts
steewbsd 9d79a7f
Merge branch 'master' of https://github.com/Bios-Marcel/cordless into…
steewbsd 076d73b
"Reverted merge
steewbsd 8774ec7
Fixed windows build
steewbsd 1e22b40
Fixed windows build
steewbsd e7e4512
Fixed SIGSEGV
steewbsd dfdc8c6
Attempt to fix appveyor compilation
steewbsd 30b8b96
Fixed go.mod and go.sum
steewbsd 68d0832
Fixed format and qol
steewbsd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package commandimpls | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
|
||
"github.com/Bios-Marcel/cordless/util/vim" | ||
) | ||
|
||
const ( | ||
vimOpenHelpPage = `[::b]NAME | ||
vim-mode - minor vim mode for cordless | ||
|
||
[::b]SYNOPSIS | ||
[::b]Normal Mode: Navigate around the containers with hjkl. | ||
Perform some usual commands inside text box input, as pasting, moving cursor or such. | ||
Press ESC anywhere to return to normal mode. | ||
|
||
[::b]Insert Mode: Type inside box input, perform actions inside chatview. | ||
Insert without any key restriction inside the text box using insert mode. | ||
Inside chat view, perform useful commands such as editing message "i" or replying to user "a" | ||
|
||
[::b]Visual Mode: Move around everywhere with vim keys. | ||
This mode allows to use hjkl pretty much anywhere inside the app. Due to some restrictions, this is | ||
the only mode that officially supports using hjkl anywhere. | ||
Also allows using same commands as insert mode inside chat view, or selecting text inside text input. | ||
|
||
|
||
[::b]DESCRIPTION | ||
This is a minor mode for vim. See all the shorcuts with Ctrl K, and edit them inside shortcuts/shortcuts.go | ||
Toggle vim with vim on/off/enable/disable | ||
` | ||
) | ||
|
||
type VimHelp struct { | ||
vimMode *vim.Vim | ||
} | ||
|
||
func NewVimCmd(vimMode *vim.Vim) *VimHelp { | ||
return &VimHelp{vimMode: vimMode} | ||
} | ||
|
||
// PrintHelp prints a static help page for this command | ||
func (v VimHelp) PrintHelp(writer io.Writer) { | ||
fmt.Fprintln(writer, vimOpenHelpPage) | ||
} | ||
|
||
func (v VimHelp) Execute(writer io.Writer, parameters []string) { | ||
if len(parameters) < 1 { | ||
fmt.Fprintf(writer, "Usage: vim on/off") | ||
return | ||
} | ||
switch parameters[0] { | ||
case "on", "enable": | ||
v.vimMode.CurrentMode = vim.NormalMode | ||
fmt.Fprintf(writer, "Vim mode has been enabled.\n") | ||
case "off", "disable": | ||
v.vimMode.CurrentMode = vim.NormalMode | ||
v.vimMode.CurrentMode = vim.Disabled | ||
fmt.Fprintf(writer, "Vim mode has been disabled.\n") | ||
default: | ||
fmt.Fprintf(writer, "Parameter %s not recognized.", parameters[0]) | ||
} | ||
} | ||
|
||
// Name returns the primary name for this command. This name will also be | ||
// used for listing the command in the commandlist. | ||
func (v VimHelp) Name() string { | ||
return "vim" | ||
} | ||
|
||
// Aliases are a list of aliases for this command. There might be none. | ||
func (v VimHelp) Aliases() []string { | ||
return []string{"vim", "vim-mode"} | ||
} |
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 |
---|---|---|
|
@@ -234,4 +234,3 @@ func (la *LineArray) Substr(start, end Loc) string { | |
str += string(la.lines[end.Y].data[:endX]) | ||
return str | ||
} | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment what exactly this entails when it is set to true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do