Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Add new feature: Vim mode #368

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 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 Nov 13, 2020
f0515f4
Added most of the new vim keys (needs rework)
invalid-email-address Nov 14, 2020
a15d76c
Partially working vim movements. Cannot get ESC key to work.
invalid-email-address Nov 15, 2020
26d6a15
Removed some useless lines
invalid-email-address Nov 16, 2020
714e23b
Vim mode working. Added simulation keys inside some lists.
invalid-email-address Nov 16, 2020
ce00566
Dynamic status bar and shortcuts menu
invalid-email-address Nov 16, 2020
56fcff0
Dynamic status bar and shortcuts menu
invalid-email-address Nov 16, 2020
2016462
Fixed some keybindings
invalid-email-address Nov 16, 2020
2c86b71
Merged from upstream
invalid-email-address Nov 16, 2020
7219309
Fixed little issues
invalid-email-address Nov 16, 2020
155c160
Edited changelog
invalid-email-address Nov 16, 2020
ad82e0e
Fixed go.sum
invalid-email-address Nov 16, 2020
9e0b15d
Vim directional keys working everywhere (only in visual mode)
steewbsd Nov 17, 2020
1b1c0c1
Added brief manpage of vim mode
steewbsd Nov 17, 2020
86df4fd
Fixed normal mode binding
steewbsd Nov 17, 2020
a2cc7de
Removed useless go sum lines
steewbsd Nov 17, 2020
5050954
Added replace instruction in go.mod
steewbsd Nov 17, 2020
422d825
Removed upstream fork from go.mod
steewbsd Nov 17, 2020
87a8946
Fixed escape binding
steewbsd Nov 17, 2020
b55c343
Fixed shortcuts dialog inconsistency
steewbsd Nov 17, 2020
b38cbd9
Fixed weird behaviour in text input
steewbsd Nov 17, 2020
6de4e41
Changed expand selection shortcuts, conflicted with movement
steewbsd Nov 18, 2020
eea5b6b
Vim can now be toggled in command mode
steewbsd Nov 18, 2020
1cc4e20
Added vim command synopsis toggle line
steewbsd Nov 18, 2020
9e8bd4c
Moved VimMode to app instead of config
steewbsd Nov 19, 2020
b2bd175
Merged with upstream, fixed conflicts
steewbsd Nov 19, 2020
9d79a7f
Merge branch 'master' of https://github.com/Bios-Marcel/cordless into…
steewbsd Nov 20, 2020
076d73b
"Reverted merge
steewbsd Nov 21, 2020
8774ec7
Fixed windows build
steewbsd Nov 21, 2020
1e22b40
Fixed windows build
steewbsd Nov 21, 2020
e7e4512
Fixed SIGSEGV
steewbsd Nov 21, 2020
dfdc8c6
Attempt to fix appveyor compilation
steewbsd Nov 21, 2020
30b8b96
Fixed go.mod and go.sum
steewbsd Nov 22, 2020
68d0832
Fixed format and qol
steewbsd Nov 22, 2020
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
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func SetupApplicationWithAccount(app *tview.Application, account string) {
window.RegisterCommand(serverCreateCmd)
window.RegisterCommand(commandimpls.NewServerCommand(serverJoinCmd, serverLeaveCmd, serverCreateCmd))
window.RegisterCommand(commandimpls.NewNickSetCmd(discord, window))
window.RegisterCommand(commandimpls.NewVimCmd())
tfaEnableCmd := commandimpls.NewTFAEnableCommand(window, discord)
tfaDisableCmd := commandimpls.NewTFADisableCommand(discord)
tfaBackupGetCmd := commandimpls.NewTFABackupGetCmd(discord, window)
Expand Down
66 changes: 66 additions & 0 deletions commands/commandimpls/vim.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package commandimpls

import (
"fmt"
"io"

"github.com/Bios-Marcel/cordless/config"
"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`
)

type VimHelp struct {
}

func NewVimCmd() *VimHelp {
return new(VimHelp)
}

// 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 config.Current.VimMode.CurrentMode == vim.Disabled {
config.Current.VimMode.Normal()
fmt.Fprintf(writer, "Vim mode enabled")
} else {
config.Current.VimMode.SetMode(vim.Disabled)
fmt.Fprintf(writer, "Vim mode disabled")
}
config.PersistConfig()
}

// 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"}
}
4 changes: 4 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"

"github.com/Bios-Marcel/cordless/util/files"
"github.com/Bios-Marcel/cordless/util/vim"
)

const (
Expand Down Expand Up @@ -155,6 +156,8 @@ type Config struct {
// download files to. If FileOpenSaveFilesPermanently has been set to
// true, then all opened files are saved in this folder for example.
FileDownloadSaveLocation string

VimMode *vim.Vim
}

// Account has a name and a token. The name is just for the users recognition.
Expand Down Expand Up @@ -211,6 +214,7 @@ func createDefaultConfig() *Config {
FileOpenHandlers: make(map[string]string),
FileOpenSaveFilesPermanently: false,
FileDownloadSaveLocation: "~/Downloads",
VimMode: &vim.Vim{CurrentMode: vim.Disabled},
}
}

Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
replace github.com/Bios-Marcel/cordless => github.com/0xSteeW/cordless v0.0.0-20201117104521-a2cc7de4b6dd
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be upstream, it shouldn't be necessary at all.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will not build either way. It was a quick test to try to get appveyor to recognize my files


module github.com/Bios-Marcel/cordless

go 1.12
Expand All @@ -9,6 +11,7 @@ require (
github.com/Bios-Marcel/shortnotforlong v1.1.1
github.com/alecthomas/chroma v0.7.3
github.com/atotto/clipboard v0.1.2
github.com/bunyk/gokeybr v0.0.0-20201019133936-f9e4ed3fdc5d // indirect
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installed some things while working on this, thought I had reverted go.sum and go.mod. Will fix

github.com/gdamore/tcell/v2 v2.0.0
github.com/gen2brain/beeep v0.0.0-20200526185328-e9c15c258e28
github.com/google/go-github/v29 v29.0.3
Expand All @@ -20,6 +23,8 @@ require (
github.com/robertkrimen/otto v0.0.0-20200922221731-ef014fd054ac
github.com/sergi/go-diff v1.1.0
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
golang.org/x/tools v0.0.0-20201112171726-b38955972a18 // indirect
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous

golang.org/x/tools/gopls v0.5.2 // indirect
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous

gopkg.in/sourcemap.v1 v1.0.5 // indirect
rsc.io/qr v0.2.0
)
Loading