Compare commits

...

27 Commits

Author SHA1 Message Date
Neko Box Coder
13e9a190b1
Merge 357ec87382 into 4f4a13a9a1 2024-09-17 03:06:46 +01:00
Massimo Mund
4f4a13a9a1
Implemented SkipMultiCursorBack as a counterpart to SkipMultiCursor (#3404) 2024-09-16 22:20:12 +02:00
Dmytro Maluka
9eaeb193d4
Merge pull request #3403 from masmu/refactor/tab-actions
Implemented new actions `FirstTab`, `LastTab`, `FirstSplit` and `LastSplit`
2024-09-16 22:19:36 +02:00
Dmytro Maluka
ca6012086b
Merge pull request #3335 from dmaluka/line-actions-cleanup
Improve and unify `CopyLine`, `CutLine`, `DeleteLine`, `DuplicateLine` actions
2024-09-16 22:19:05 +02:00
Oleksandr Redko
1539da7fdc
test: simplify cmd/micro tests (#3470) 2024-09-16 19:33:59 +02:00
Oleksandr Redko
a3211dce57
Build: set 1.17 as minimum supported Go version (#3461) 2024-09-16 19:21:43 +02:00
Massimo Mund
5f83661fee Fixes a bug where new BufPanes are not being inserted into the right array index.
When adding a new `BufPane` it is always being inserted last into `MainTab().Panes`.
This leads to a confusion when using the actions `PreviousSplit`, `NextSplit` as the previous/next split may not be the expected one.

How to reproduce:
- Launch micro and insert char "1"
- Open a new vsplit via the command `vsplit` and insert "2"
- Switch back to the left split (1) by using `PreviousSplit`
- Again open a new vsplit via command: `vsplit` and type char "3"
- Now switch between the 3 splits using `PreviousSplit`, `NextSplit`

Switching from most left split to the most right, the expected order would be 1, 3, 2 but actually is 1, 2, 3.
2024-09-15 16:36:00 +02:00
Massimo Mund
2e44db1ee9 Implemented new actions FirstTab, LastTab, FirstSplit and LastSplit and changed the default behavior of NextTab, PreviousTab, NextSplit, PreviousSplit to not walk in circles anymore 2024-09-15 16:35:22 +02:00
Neko Box Coder
357ec87382
Merge branch 'master' into JumpToBraces 2024-08-18 22:47:56 +01:00
Neko Box Coder
bdc57b472d
Adding Jumping to opening and closing brace logic and actions, ...
Simplifying findMatchingBrace(),
Adding FindOpeningBrace() and FindClosingBrace(),
Adding JumpToOpeningBrace() and JumpToClosingBrace()
Adding brace jumping to default bindings
2024-07-13 16:32:40 +01:00
Dmytro Maluka
bf6584739f help/keybindings: document CutLine behavior 2024-06-14 00:49:51 +02:00
Dmytro Maluka
68d6f43c63 CutLine: remove lastCutTime feature
The lastCutTime feature (reset the clipboard instead of appending to the
clipboard if the last CutLine was more than 10 seconds ago) was
implemented 8 years ago but was always buggy and never really worked,
until we have accidentally found and fixed the bug just now. No one ever
complained or noticed that, which means it is not a very useful feature.
Fixing it changes the existing behavior (essentially adds a new feature
which did not really exist before) and there is no reason to assume that
this new behavior will be welcome by users. So it's better to remove
this feature.
2024-06-12 03:16:36 +02:00
Dmytro Maluka
6f724bc424 DuplicateLine: respect selections
Similarly to CutLine, DeleteLine and CopyLine actions, if there is a
selection, duplicate not just the current line but all the lines covered
(fully or partially) by the selection.
2024-06-09 17:11:58 +02:00
Dmytro Maluka
25f71eec2d DuplicateLine: move selection duplication to separate Duplicate action
- Add a new Duplicate action which just duplicates the selection (and
  returns false if there is no selection).
- Change the behavior of the DuplicateLine action to only duplicate the
  current line, not the selection.
- Change the default action bound to Ctrl-d from DuplicateLine to
  Duplicate|DuplicateLine, so that the default behavior doesn't change.

This allows the user to rebind keybindings in a more flexible way, i.e.
to choose whether a key should duplicate just lines, or just selections,
or both, - in a similar fashion to Copy, Cut, Delete actions.
2024-06-09 17:11:58 +02:00
Dmytro Maluka
33a1bb120f CutLine: return if cliboard read failed
If we ever encounter this clipboard.Read() failure, return false
immediately. Otherwise, InfoBar.Error(err) will have no effect (it will
be immediately overwritten by InfoBar.Message()) so we won't even know
that there was an error.
2024-06-09 17:11:58 +02:00
Dmytro Maluka
04143c7a89 Make Cut, Copy, CopyLine don't mess with CutLine's multi line cuts
Weird behavior is observed e.g. if we cut some lines with CutLine, then
copy some selection with Copy, then cut some other lines with CutLine,
and then paste. The pasted cliboard contains not just the lines that
were cut at the last step, but also the selection that was copied before
that.

Fix that by resetting the CutLine's repeated line cuts whenever we
copy anything to the clipboard via any other action (Cut, Copy or
CopyLine).
2024-06-09 17:11:58 +02:00
Dmytro Maluka
e6825f0e08 CutLine: make infobar message more useful
Since CutLine may add lines to the clipboard instead of replacing the
clipboard, improve its info message to show how many lines are in the
clipboard in total, not just how many lines were added to it last time.
2024-06-09 17:11:58 +02:00
Dmytro Maluka
fdacb28962 CopyLine, CutLine, DeleteLine: respect selection
When there is a selection containing multiple lines, CutLine, DeleteLine
and CopyLine actions currently cut/delete/copy just the "current" line,
as usual. This behavior is at least confusing, since when there is a
selection, the cursor is not displayed, so the user doesn't know which
line is the current one.

So change the behavior. When there is a multi-line selection,
cut/delete/copy all lines covered by the selection, not just the current
line. Note that it will cut/delete/copy whole lines, not just the
selection itself, i.e. if the first and/or the last line of the
selection is only partially within the selection, we will
cut/delete/copy the entire first and last lines nonetheless.
2024-06-09 17:11:58 +02:00
Dmytro Maluka
9f7bdb109b Cosmetic change: move Cut above CutLine 2024-06-09 17:11:58 +02:00
Dmytro Maluka
c1bbd7b041 CutLine: cosmetic refactoring 2024-06-09 17:11:58 +02:00
Dmytro Maluka
a317aefd6d Reorganize Cut and CutLine actions
Change behavior of the Cut action: don't implicitly call CutLine if
there is no selection. Instead, make it return false in this case
and change the default Ctrl-x binding to Cut|CutLine, to make it clear,
explicit and in line with Copy and CopyLine actions.
2024-06-09 17:11:58 +02:00
Dmytro Maluka
830768b715 Reorganize Copy and CopyLine actions
Make Copy return false if there is no selection, and change the default
binding for Ctrl-c from CopyLine|Copy to Copy|CopyLine accordingly,
to make the semantics more meaningful: copying selection always fails
if there is no selection.
2024-06-09 12:19:34 +02:00
Dmytro Maluka
2860efbe3a CutLine: remove unneeded if check 2024-06-09 12:16:25 +02:00
Dmytro Maluka
52ed4315ff Make lastCutTime actually work
The CutLine action has a feature: if we execute it multiple times to cut
multiple lines, new cut lines are added to the previously cut lines in
the clipboard instead of replacing the clipboard, unless those
previously cut lines have been already pasted or the last cut was more
than 10 seconds ago. This last bit doesn't really work: newly cut lines
are appended to the clipboard regardless of when was the last cut.
So fix it.
2024-06-09 12:07:07 +02:00
Dmytro Maluka
8bc67569f9 Fix CopyLine at the last empty line of buffer
When the cursor is at the last line of buffer and it is an empty line,
CopyLine does not copy this line, which is correct, but it shows a bogus
"Copied line" message. Fix this by adding a check for that, same as in
CutLine and DeleteLine.
2024-06-09 11:44:44 +02:00
Dmytro Maluka
df8d5285bf Fix Cursor{Up,Down} after CopyLine
After executing the CopyLine action, moving cursor up or down
unexpectedly moves cursor to the beginning of the line, since its
LastVisualX value is lost in the selection/deselection manipulations.
Fix this by restoring the original LastVisualX.
2024-06-09 11:40:30 +02:00
Dmytro Maluka
19c69f9eaa Fix Cursor{Up,Down} after DeleteLine and CutLine
After executing CutLine or DeleteLine action, the cursor is at the
beginning of a line (as expected) but then moving the cursor up or down
moves it to an unexpected location in the middle of the next or previous
line. Fix this by updating the cursor's LastVisualX.
2024-06-09 11:39:23 +02:00
16 changed files with 487 additions and 243 deletions

View File

@ -7,7 +7,7 @@ jobs:
nightly:
strategy:
matrix:
go-version: [1.19.x]
go-version: [1.23.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:

View File

@ -8,7 +8,7 @@ jobs:
release:
strategy:
matrix:
go-version: [1.19.x]
go-version: [1.23.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:

View File

@ -4,7 +4,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.19.x]
go-version: [1.17.x, 1.23.x]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:

View File

@ -162,7 +162,7 @@ Without these tools installed, micro will use an internal clipboard for copy and
If your operating system does not have a binary release, but does run Go, you can build from source.
Make sure that you have Go version 1.16 or greater and Go modules are enabled.
Make sure that you have Go version 1.17 or greater and Go modules are enabled.
```
git clone https://github.com/zyedidia/micro

View File

@ -2,7 +2,6 @@ package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"testing"
@ -26,7 +25,7 @@ func init() {
func startup(args []string) (tcell.SimulationScreen, error) {
var err error
tempDir, err = ioutil.TempDir("", "micro_test")
tempDir, err = os.MkdirTemp("", "micro_test")
if err != nil {
return nil, err
}
@ -164,20 +163,22 @@ func findBuffer(file string) *buffer.Buffer {
return buf
}
func createTestFile(name string, content string) (string, error) {
testf, err := ioutil.TempFile("", name)
func createTestFile(t *testing.T, content string) string {
f, err := os.CreateTemp(t.TempDir(), "")
if err != nil {
return "", err
t.Fatal(err)
}
defer func() {
if err := f.Close(); err != nil {
t.Fatal(err)
}
}()
if _, err := f.WriteString(content); err != nil {
t.Fatal(err)
}
if _, err := testf.Write([]byte(content)); err != nil {
return "", err
}
if err := testf.Close(); err != nil {
return "", err
}
return testf.Name(), nil
return f.Name()
}
func TestMain(m *testing.M) {
@ -194,18 +195,12 @@ func TestMain(m *testing.M) {
}
func TestSimpleEdit(t *testing.T) {
file, err := createTestFile("micro_simple_edit_test", "base content")
if err != nil {
t.Error(err)
return
}
defer os.Remove(file)
file := createTestFile(t, "base content")
openFile(file)
if findBuffer(file) == nil {
t.Errorf("Could not find buffer %s", file)
return
t.Fatalf("Could not find buffer %s", file)
}
injectKey(tcell.KeyEnter, rune(tcell.KeyEnter), tcell.ModNone)
@ -223,28 +218,21 @@ func TestSimpleEdit(t *testing.T) {
injectKey(tcell.KeyCtrlS, rune(tcell.KeyCtrlS), tcell.ModCtrl)
data, err := ioutil.ReadFile(file)
data, err := os.ReadFile(file)
if err != nil {
t.Error(err)
return
t.Fatal(err)
}
assert.Equal(t, "firstfoobar\nbase content\n", string(data))
}
func TestMouse(t *testing.T) {
file, err := createTestFile("micro_mouse_test", "base content")
if err != nil {
t.Error(err)
return
}
defer os.Remove(file)
file := createTestFile(t, "base content")
openFile(file)
if findBuffer(file) == nil {
t.Errorf("Could not find buffer %s", file)
return
t.Fatalf("Could not find buffer %s", file)
}
// buffer:
@ -275,10 +263,9 @@ func TestMouse(t *testing.T) {
// base content
injectKey(tcell.KeyCtrlS, rune(tcell.KeyCtrlS), tcell.ModCtrl)
data, err := ioutil.ReadFile(file)
data, err := os.ReadFile(file)
if err != nil {
t.Error(err)
return
t.Fatal(err)
}
assert.Equal(t, "firstline\nsecondline\nbase content\n", string(data))
@ -301,18 +288,12 @@ Ernleȝe test_string æðelen
`
func TestSearchAndReplace(t *testing.T) {
file, err := createTestFile("micro_search_replace_test", srTestStart)
if err != nil {
t.Error(err)
return
}
defer os.Remove(file)
file := createTestFile(t, srTestStart)
openFile(file)
if findBuffer(file) == nil {
t.Errorf("Could not find buffer %s", file)
return
t.Fatalf("Could not find buffer %s", file)
}
injectKey(tcell.KeyCtrlE, rune(tcell.KeyCtrlE), tcell.ModCtrl)
@ -321,10 +302,9 @@ func TestSearchAndReplace(t *testing.T) {
injectKey(tcell.KeyCtrlS, rune(tcell.KeyCtrlS), tcell.ModCtrl)
data, err := ioutil.ReadFile(file)
data, err := os.ReadFile(file)
if err != nil {
t.Error(err)
return
t.Fatal(err)
}
assert.Equal(t, srTest2, string(data))
@ -337,10 +317,9 @@ func TestSearchAndReplace(t *testing.T) {
injectKey(tcell.KeyCtrlS, rune(tcell.KeyCtrlS), tcell.ModCtrl)
data, err = ioutil.ReadFile(file)
data, err = os.ReadFile(file)
if err != nil {
t.Error(err)
return
t.Fatal(err)
}
assert.Equal(t, srTest3, string(data))

16
go.mod
View File

@ -14,17 +14,29 @@ require (
github.com/zyedidia/clipper v0.1.1
github.com/zyedidia/glob v0.0.0-20170209203856-dd4023a66dc3
github.com/zyedidia/json5 v0.0.0-20200102012142-2da050b1a98d
github.com/zyedidia/tcell/v2 v2.0.10 // indirect
github.com/zyedidia/tcell/v2 v2.0.10
github.com/zyedidia/terminal v0.0.0-20230315200948-4b3bcf6dddef
golang.org/x/text v0.3.8
gopkg.in/yaml.v2 v2.2.8
layeh.com/gopher-luar v1.0.7
)
require (
github.com/creack/pty v1.1.18 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gdamore/encoding v1.0.0 // indirect
github.com/lucasb-eyer/go-colorful v1.0.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.1.0 // indirect
github.com/xo/terminfo v0.0.0-20200218205459-454e5b68f9e8 // indirect
github.com/zyedidia/poller v1.0.1 // indirect
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
)
replace github.com/kballard/go-shellquote => github.com/zyedidia/go-shellquote v0.0.0-20200613203517-eccd813c0655
replace github.com/mattn/go-runewidth => github.com/zyedidia/go-runewidth v0.0.12
replace layeh.com/gopher-luar => github.com/layeh/gopher-luar v1.0.7
go 1.16
go 1.17

8
go.sum
View File

@ -54,14 +54,6 @@ github.com/zyedidia/json5 v0.0.0-20200102012142-2da050b1a98d h1:zmDMkh22zXOB7gz8
github.com/zyedidia/json5 v0.0.0-20200102012142-2da050b1a98d/go.mod h1:NDJSTTYWivnza6zkRapeX2/LwhKPEMQ7bJxqgDVT78I=
github.com/zyedidia/poller v1.0.1 h1:Tt9S3AxAjXwWGNiC2TUdRJkQDZSzCBNVQ4xXiQ7440s=
github.com/zyedidia/poller v1.0.1/go.mod h1:vZXJOHGDcuK08GXhF6IAY0ZFd2WcgOR5DOTp84Uk5eE=
github.com/zyedidia/tcell/v2 v2.0.9 h1:FxXRkE62N0GPHES7EMLtp2rteYqC9r1kVid8vJN1kOE=
github.com/zyedidia/tcell/v2 v2.0.9/go.mod h1:i4NNlquIQXFeNecrOgxDQQJdu+7LmTi3g62asvmwUws=
github.com/zyedidia/tcell/v2 v2.0.10-0.20221007181625-f562052bccb8 h1:53ULv4mmLyQDnqbjVxanckP57WSreWHwTmlLJrJEutY=
github.com/zyedidia/tcell/v2 v2.0.10-0.20221007181625-f562052bccb8/go.mod h1:i4NNlquIQXFeNecrOgxDQQJdu+7LmTi3g62asvmwUws=
github.com/zyedidia/tcell/v2 v2.0.10-0.20230320201625-54f6acdada4a h1:W4TWa++Wk6uRGxZoxr2nPX1TpIEl+Wxv0mTtocG4TYc=
github.com/zyedidia/tcell/v2 v2.0.10-0.20230320201625-54f6acdada4a/go.mod h1:i4NNlquIQXFeNecrOgxDQQJdu+7LmTi3g62asvmwUws=
github.com/zyedidia/tcell/v2 v2.0.10-0.20230831153116-061c5b2c7260 h1:SCAmAacT5BxZsmOFdFy5zwwi6nj1MjA60gydjKdTgXo=
github.com/zyedidia/tcell/v2 v2.0.10-0.20230831153116-061c5b2c7260/go.mod h1:i4NNlquIQXFeNecrOgxDQQJdu+7LmTi3g62asvmwUws=
github.com/zyedidia/tcell/v2 v2.0.10 h1:6fbbYAx/DYc9A//4jU1OeBrxtc9qJxYCZXCtGQbtTWU=
github.com/zyedidia/tcell/v2 v2.0.10/go.mod h1:i4NNlquIQXFeNecrOgxDQQJdu+7LmTi3g62asvmwUws=
github.com/zyedidia/terminal v0.0.0-20230315200948-4b3bcf6dddef h1:LeB4Qs0Tss4r/Qh8pfsTTqagDYHysfKJLYzAH3MVfu0=

View File

@ -1238,101 +1238,179 @@ func (h *BufPane) Redo() bool {
return true
}
func (h *BufPane) selectLines() int {
if h.Cursor.HasSelection() {
start := h.Cursor.CurSelection[0]
end := h.Cursor.CurSelection[1]
if start.GreaterThan(end) {
start, end = end, start
}
if end.X == 0 {
end = end.Move(-1, h.Buf)
}
h.Cursor.Deselect(true)
h.Cursor.SetSelectionStart(buffer.Loc{0, start.Y})
h.Cursor.SetSelectionEnd(buffer.Loc{0, end.Y + 1})
} else {
h.Cursor.SelectLine()
}
return h.Cursor.CurSelection[1].Y - h.Cursor.CurSelection[0].Y
}
// Copy the selection to the system clipboard
func (h *BufPane) Copy() bool {
if h.Cursor.HasSelection() {
h.Cursor.CopySelection(clipboard.ClipboardReg)
h.freshClip = true
InfoBar.Message("Copied selection")
}
h.Relocate()
return true
}
// CopyLine copies the current line to the clipboard
func (h *BufPane) CopyLine() bool {
if h.Cursor.HasSelection() {
return false
}
origLoc := h.Cursor.Loc
h.Cursor.SelectLine()
h.Cursor.CopySelection(clipboard.ClipboardReg)
h.freshClip = true
InfoBar.Message("Copied line")
h.Cursor.Deselect(true)
h.Cursor.Loc = origLoc
h.Relocate()
return true
}
// CutLine cuts the current line to the clipboard
func (h *BufPane) CutLine() bool {
h.Cursor.SelectLine()
if !h.Cursor.HasSelection() {
return false
}
if h.freshClip {
if h.Cursor.HasSelection() {
if clip, err := clipboard.Read(clipboard.ClipboardReg); err != nil {
InfoBar.Error(err)
} else {
clipboard.WriteMulti(clip+string(h.Cursor.GetSelection()), clipboard.ClipboardReg, h.Cursor.Num, h.Buf.NumCursors())
}
}
} else if time.Since(h.lastCutTime)/time.Second > 10*time.Second || !h.freshClip {
h.Copy()
h.Cursor.CopySelection(clipboard.ClipboardReg)
h.freshClip = false
InfoBar.Message("Copied selection")
h.Relocate()
return true
}
// CopyLine copies the current line to the clipboard. If there is a selection,
// CopyLine copies all the lines that are (fully or partially) in the selection.
func (h *BufPane) CopyLine() bool {
origLoc := h.Cursor.Loc
origLastVisualX := h.Cursor.LastVisualX
origSelection := h.Cursor.CurSelection
nlines := h.selectLines()
if nlines == 0 {
return false
}
h.freshClip = true
h.lastCutTime = time.Now()
h.Cursor.DeleteSelection()
h.Cursor.ResetSelection()
InfoBar.Message("Cut line")
h.Cursor.CopySelection(clipboard.ClipboardReg)
h.freshClip = false
if nlines > 1 {
InfoBar.Message(fmt.Sprintf("Copied %d lines", nlines))
} else {
InfoBar.Message("Copied line")
}
h.Cursor.Loc = origLoc
h.Cursor.LastVisualX = origLastVisualX
h.Cursor.CurSelection = origSelection
h.Relocate()
return true
}
// Cut the selection to the system clipboard
func (h *BufPane) Cut() bool {
if h.Cursor.HasSelection() {
h.Cursor.CopySelection(clipboard.ClipboardReg)
h.Cursor.DeleteSelection()
h.Cursor.ResetSelection()
h.freshClip = true
InfoBar.Message("Cut selection")
h.Relocate()
return true
if !h.Cursor.HasSelection() {
return false
}
return h.CutLine()
}
h.Cursor.CopySelection(clipboard.ClipboardReg)
h.Cursor.DeleteSelection()
h.Cursor.ResetSelection()
h.freshClip = false
InfoBar.Message("Cut selection")
// DuplicateLine duplicates the current line or selection
func (h *BufPane) DuplicateLine() bool {
var infoMessage = "Duplicated line"
if h.Cursor.HasSelection() {
infoMessage = "Duplicated selection"
h.Buf.Insert(h.Cursor.CurSelection[1], string(h.Cursor.GetSelection()))
} else {
h.Cursor.End()
h.Buf.Insert(h.Cursor.Loc, "\n"+string(h.Buf.LineBytes(h.Cursor.Y)))
// h.Cursor.Right()
}
InfoBar.Message(infoMessage)
h.Relocate()
return true
}
// DeleteLine deletes the current line
func (h *BufPane) DeleteLine() bool {
h.Cursor.SelectLine()
// CutLine cuts the current line to the clipboard. If there is a selection,
// CutLine cuts all the lines that are (fully or partially) in the selection.
func (h *BufPane) CutLine() bool {
nlines := h.selectLines()
if nlines == 0 {
return false
}
totalLines := nlines
if h.freshClip {
if clip, err := clipboard.Read(clipboard.ClipboardReg); err != nil {
InfoBar.Error(err)
return false
} else {
clipboard.WriteMulti(clip+string(h.Cursor.GetSelection()), clipboard.ClipboardReg, h.Cursor.Num, h.Buf.NumCursors())
totalLines = strings.Count(clip, "\n") + nlines
}
} else {
h.Cursor.CopySelection(clipboard.ClipboardReg)
}
h.freshClip = true
h.Cursor.DeleteSelection()
h.Cursor.ResetSelection()
h.Cursor.StoreVisualX()
if totalLines > 1 {
InfoBar.Message(fmt.Sprintf("Cut %d lines", totalLines))
} else {
InfoBar.Message("Cut line")
}
h.Relocate()
return true
}
// Duplicate the selection
func (h *BufPane) Duplicate() bool {
if !h.Cursor.HasSelection() {
return false
}
h.Buf.Insert(h.Cursor.CurSelection[1], string(h.Cursor.GetSelection()))
InfoBar.Message("Duplicated selection")
h.Relocate()
return true
}
// DuplicateLine duplicates the current line. If there is a selection, DuplicateLine
// duplicates all the lines that are (fully or partially) in the selection.
func (h *BufPane) DuplicateLine() bool {
if h.Cursor.HasSelection() {
origLoc := h.Cursor.Loc
origLastVisualX := h.Cursor.LastVisualX
origSelection := h.Cursor.CurSelection
start := h.Cursor.CurSelection[0]
end := h.Cursor.CurSelection[1]
if start.GreaterThan(end) {
start, end = end, start
}
if end.X == 0 {
end = end.Move(-1, h.Buf)
}
h.Cursor.Deselect(true)
h.Cursor.Loc = end
h.Cursor.End()
for y := start.Y; y <= end.Y; y++ {
h.Buf.Insert(h.Cursor.Loc, "\n"+string(h.Buf.LineBytes(y)))
}
h.Cursor.Loc = origLoc
h.Cursor.LastVisualX = origLastVisualX
h.Cursor.CurSelection = origSelection
if start.Y < end.Y {
InfoBar.Message(fmt.Sprintf("Duplicated %d lines", end.Y-start.Y+1))
} else {
InfoBar.Message("Duplicated line")
}
} else {
h.Cursor.End()
h.Buf.Insert(h.Cursor.Loc, "\n"+string(h.Buf.LineBytes(h.Cursor.Y)))
InfoBar.Message("Duplicated line")
}
h.Relocate()
return true
}
// DeleteLine deletes the current line. If there is a selection, DeleteLine
// deletes all the lines that are (fully or partially) in the selection.
func (h *BufPane) DeleteLine() bool {
nlines := h.selectLines()
if nlines == 0 {
return false
}
h.Cursor.DeleteSelection()
h.Cursor.ResetSelection()
InfoBar.Message("Deleted line")
h.Cursor.StoreVisualX()
if nlines > 1 {
InfoBar.Message(fmt.Sprintf("Deleted %d lines", nlines))
} else {
InfoBar.Message("Deleted line")
}
h.Relocate()
return true
}
@ -1487,6 +1565,28 @@ func (h *BufPane) JumpToMatchingBrace() bool {
return false
}
// JumpToOpeningBrace moves the cursor to the opening brace in current brace scope
func (h *BufPane) JumpToOpeningBrace() bool {
matchingBrace, found := h.Buf.FindOpeningBrace(h.Cursor.Loc)
if found {
h.Cursor.GotoLoc(matchingBrace)
h.Relocate()
return true
}
return false
}
// JumpToClosingBrace moves the cursor to the closing brace in current brace scope
func (h *BufPane) JumpToClosingBrace() bool {
matchingBrace, found := h.Buf.FindClosingBrace(h.Cursor.Loc)
if found {
h.Cursor.GotoLoc(matchingBrace)
h.Relocate()
return true
}
return false
}
// SelectAll selects the entire buffer
func (h *BufPane) SelectAll() bool {
h.Cursor.SetSelectionStart(h.Buf.Start())
@ -1793,27 +1893,38 @@ func (h *BufPane) AddTab() bool {
// PreviousTab switches to the previous tab in the tab list
func (h *BufPane) PreviousTab() bool {
tabsLen := len(Tabs.List)
if tabsLen == 1 {
if Tabs.Active() == 0 {
return false
}
a := Tabs.Active() + tabsLen
Tabs.SetActive((a - 1) % tabsLen)
Tabs.SetActive(Tabs.Active() - 1)
return true
}
// NextTab switches to the next tab in the tab list
func (h *BufPane) NextTab() bool {
tabsLen := len(Tabs.List)
if tabsLen == 1 {
if Tabs.Active() == len(Tabs.List)-1 {
return false
}
Tabs.SetActive(Tabs.Active() + 1)
return true
}
a := Tabs.Active()
Tabs.SetActive((a + 1) % tabsLen)
// FirstTab switches to the first tab in the tab list
func (h *BufPane) FirstTab() bool {
if Tabs.Active() == 0 {
return false
}
Tabs.SetActive(0)
return true
}
// LastTab switches to the last tab in the tab list
func (h *BufPane) LastTab() bool {
lastTabIndex := len(Tabs.List) - 1
if Tabs.Active() == lastTabIndex {
return false
}
Tabs.SetActive(lastTabIndex)
return true
}
@ -1848,36 +1959,38 @@ func (h *BufPane) Unsplit() bool {
// NextSplit changes the view to the next split
func (h *BufPane) NextSplit() bool {
if len(h.tab.Panes) == 1 {
if h.tab.active == len(h.tab.Panes)-1 {
return false
}
a := h.tab.active
if a < len(h.tab.Panes)-1 {
a++
} else {
a = 0
}
h.tab.SetActive(a)
h.tab.SetActive(h.tab.active + 1)
return true
}
// PreviousSplit changes the view to the previous split
func (h *BufPane) PreviousSplit() bool {
if len(h.tab.Panes) == 1 {
if h.tab.active == 0 {
return false
}
h.tab.SetActive(h.tab.active - 1)
return true
}
a := h.tab.active
if a > 0 {
a--
} else {
a = len(h.tab.Panes) - 1
// FirstSplit changes the view to the first split
func (h *BufPane) FirstSplit() bool {
if h.tab.active == 0 {
return false
}
h.tab.SetActive(a)
h.tab.SetActive(0)
return true
}
// LastSplit changes the view to the last split
func (h *BufPane) LastSplit() bool {
lastPaneIdx := len(h.tab.Panes) - 1
if h.tab.active == lastPaneIdx {
return false
}
h.tab.SetActive(lastPaneIdx)
return true
}
@ -2076,14 +2189,16 @@ func (h *BufPane) MouseMultiCursor(e *tcell.EventMouse) bool {
return true
}
// SkipMultiCursor moves the current multiple cursor to the next available position
func (h *BufPane) SkipMultiCursor() bool {
func (h *BufPane) skipMultiCursor(forward bool) bool {
lastC := h.Buf.GetCursor(h.Buf.NumCursors() - 1)
if !lastC.HasSelection() {
return false
}
sel := lastC.GetSelection()
searchStart := lastC.CurSelection[1]
if !forward {
searchStart = lastC.CurSelection[0]
}
search := string(sel)
search = regexp.QuoteMeta(search)
@ -2091,7 +2206,7 @@ func (h *BufPane) SkipMultiCursor() bool {
search = "\\b" + search + "\\b"
}
match, found, err := h.Buf.FindNext(search, h.Buf.Start(), h.Buf.End(), searchStart, true, true)
match, found, err := h.Buf.FindNext(search, h.Buf.Start(), h.Buf.End(), searchStart, forward, true)
if err != nil {
InfoBar.Error(err)
}
@ -2111,6 +2226,16 @@ func (h *BufPane) SkipMultiCursor() bool {
return true
}
// SkipMultiCursor moves the current multiple cursor to the next available position
func (h *BufPane) SkipMultiCursor() bool {
return h.skipMultiCursor(true)
}
// SkipMultiCursorBack moves the current multiple cursor to the previous available position
func (h *BufPane) SkipMultiCursorBack() bool {
return h.skipMultiCursor(false)
}
// RemoveMultiCursor removes the latest multiple cursor
func (h *BufPane) RemoveMultiCursor() bool {
if h.Buf.NumCursors() > 1 {

View File

@ -233,11 +233,8 @@ type BufPane struct {
lastClickTime time.Time
lastLoc buffer.Loc
// lastCutTime stores when the last ctrl+k was issued.
// It is used for clearing the clipboard to replace it with fresh cut lines.
lastCutTime time.Time
// freshClip returns true if the clipboard has never been pasted.
// freshClip returns true if one or more lines have been cut to the clipboard
// and have never been pasted yet.
freshClip bool
// Was the last mouse event actually a double click?
@ -663,9 +660,13 @@ func (h *BufPane) DoRuneInsert(r rune) {
func (h *BufPane) VSplitIndex(buf *buffer.Buffer, right bool) *BufPane {
e := NewBufPaneFromBuf(buf, h.tab)
e.splitID = MainTab().GetNode(h.splitID).VSplit(right)
MainTab().Panes = append(MainTab().Panes, e)
currentPaneIdx := MainTab().GetPane(h.splitID)
if right {
currentPaneIdx++
}
MainTab().AddPane(e, currentPaneIdx)
MainTab().Resize()
MainTab().SetActive(len(MainTab().Panes) - 1)
MainTab().SetActive(currentPaneIdx)
return e
}
@ -673,9 +674,13 @@ func (h *BufPane) VSplitIndex(buf *buffer.Buffer, right bool) *BufPane {
func (h *BufPane) HSplitIndex(buf *buffer.Buffer, bottom bool) *BufPane {
e := NewBufPaneFromBuf(buf, h.tab)
e.splitID = MainTab().GetNode(h.splitID).HSplit(bottom)
MainTab().Panes = append(MainTab().Panes, e)
currentPaneIdx := MainTab().GetPane(h.splitID)
if bottom {
currentPaneIdx++
}
MainTab().AddPane(e, currentPaneIdx)
MainTab().Resize()
MainTab().SetActive(len(MainTab().Panes) - 1)
MainTab().SetActive(currentPaneIdx)
return e
}
@ -780,6 +785,7 @@ var BufKeyActions = map[string]BufKeyAction{
"CopyLine": (*BufPane).CopyLine,
"Cut": (*BufPane).Cut,
"CutLine": (*BufPane).CutLine,
"Duplicate": (*BufPane).Duplicate,
"DuplicateLine": (*BufPane).DuplicateLine,
"DeleteLine": (*BufPane).DeleteLine,
"MoveLinesUp": (*BufPane).MoveLinesUp,
@ -824,8 +830,12 @@ var BufKeyActions = map[string]BufKeyAction{
"AddTab": (*BufPane).AddTab,
"PreviousTab": (*BufPane).PreviousTab,
"NextTab": (*BufPane).NextTab,
"FirstTab": (*BufPane).FirstTab,
"LastTab": (*BufPane).LastTab,
"NextSplit": (*BufPane).NextSplit,
"PreviousSplit": (*BufPane).PreviousSplit,
"FirstSplit": (*BufPane).FirstSplit,
"LastSplit": (*BufPane).LastSplit,
"Unsplit": (*BufPane).Unsplit,
"VSplit": (*BufPane).VSplitAction,
"HSplit": (*BufPane).HSplitAction,
@ -841,7 +851,10 @@ var BufKeyActions = map[string]BufKeyAction{
"RemoveMultiCursor": (*BufPane).RemoveMultiCursor,
"RemoveAllMultiCursors": (*BufPane).RemoveAllMultiCursors,
"SkipMultiCursor": (*BufPane).SkipMultiCursor,
"SkipMultiCursorBack": (*BufPane).SkipMultiCursorBack,
"JumpToMatchingBrace": (*BufPane).JumpToMatchingBrace,
"JumpToOpeningBrace": (*BufPane).JumpToOpeningBrace,
"JumpToClosingBrace": (*BufPane).JumpToClosingBrace,
"JumpLine": (*BufPane).JumpLine,
"Deselect": (*BufPane).Deselect,
"ClearInfo": (*BufPane).ClearInfo,
@ -907,6 +920,7 @@ var MultiActions = map[string]bool{
"Copy": true,
"Cut": true,
"CutLine": true,
"Duplicate": true,
"DuplicateLine": true,
"DeleteLine": true,
"MoveLinesUp": true,
@ -924,4 +938,6 @@ var MultiActions = map[string]bool{
"StartOfTextToggle": true,
"EndOfLine": true,
"JumpToMatchingBrace": true,
"JumpToOpeningBrace": true,
"JumpToClosingBrace": true,
}

View File

@ -3,7 +3,7 @@ package action
var termdefaults = map[string]string{
"<Ctrl-q><Ctrl-q>": "Exit",
"<Ctrl-e><Ctrl-e>": "CommandMode",
"<Ctrl-w><Ctrl-w>": "NextSplit",
"<Ctrl-w><Ctrl-w>": "NextSplit|FirstSplit",
}
// DefaultBindings returns a map containing micro's default keybindings

View File

@ -45,23 +45,23 @@ var bufdefaults = map[string]string{
"Alt-]": "DiffNext|CursorEnd",
"Ctrl-z": "Undo",
"Ctrl-y": "Redo",
"Ctrl-c": "CopyLine|Copy",
"Ctrl-x": "Cut",
"Ctrl-c": "Copy|CopyLine",
"Ctrl-x": "Cut|CutLine",
"Ctrl-k": "CutLine",
"Ctrl-d": "DuplicateLine",
"Ctrl-d": "Duplicate|DuplicateLine",
"Ctrl-v": "Paste",
"Ctrl-a": "SelectAll",
"Ctrl-t": "AddTab",
"Alt-,": "PreviousTab",
"Alt-.": "NextTab",
"Alt-,": "PreviousTab|LastTab",
"Alt-.": "NextTab|FirstTab",
"Home": "StartOfTextToggle",
"End": "EndOfLine",
"CtrlHome": "CursorStart",
"CtrlEnd": "CursorEnd",
"PageUp": "CursorPageUp",
"PageDown": "CursorPageDown",
"CtrlPageUp": "PreviousTab",
"CtrlPageDown": "NextTab",
"CtrlPageUp": "PreviousTab|LastTab",
"CtrlPageDown": "NextTab|FirstTab",
"ShiftPageUp": "SelectPageUp",
"ShiftPageDown": "SelectPageDown",
"Ctrl-g": "ToggleHelp",
@ -72,10 +72,12 @@ var bufdefaults = map[string]string{
"Ctrl-b": "ShellMode",
"Ctrl-q": "Quit",
"Ctrl-e": "CommandMode",
"Ctrl-w": "NextSplit",
"Ctrl-w": "NextSplit|FirstSplit",
"Ctrl-u": "ToggleMacro",
"Ctrl-j": "PlayMacro",
"Insert": "ToggleOverwriteMode",
"Alt-<": "JumpToOpeningBrace",
"Alt->": "JumpToClosingBrace",
// Emacs-style keybindings
"Alt-f": "WordRight",
@ -146,8 +148,8 @@ var infodefaults = map[string]string{
"Backtab": "CycleAutocompleteBack",
"Ctrl-z": "Undo",
"Ctrl-y": "Redo",
"Ctrl-c": "CopyLine|Copy",
"Ctrl-x": "Cut",
"Ctrl-c": "Copy|CopyLine",
"Ctrl-x": "Cut|CutLine",
"Ctrl-k": "CutLine",
"Ctrl-v": "Paste",
"Home": "StartOfTextToggle",

View File

@ -48,23 +48,23 @@ var bufdefaults = map[string]string{
"Alt-]": "DiffNext|CursorEnd",
"Ctrl-z": "Undo",
"Ctrl-y": "Redo",
"Ctrl-c": "CopyLine|Copy",
"Ctrl-x": "Cut",
"Ctrl-c": "Copy|CopyLine",
"Ctrl-x": "Cut|CutLine",
"Ctrl-k": "CutLine",
"Ctrl-d": "DuplicateLine",
"Ctrl-d": "Duplicate|DuplicateLine",
"Ctrl-v": "Paste",
"Ctrl-a": "SelectAll",
"Ctrl-t": "AddTab",
"Alt-,": "PreviousTab",
"Alt-.": "NextTab",
"Alt-,": "PreviousTab|LastTab",
"Alt-.": "NextTab|FirstTab",
"Home": "StartOfTextToggle",
"End": "EndOfLine",
"CtrlHome": "CursorStart",
"CtrlEnd": "CursorEnd",
"PageUp": "CursorPageUp",
"PageDown": "CursorPageDown",
"CtrlPageUp": "PreviousTab",
"CtrlPageDown": "NextTab",
"CtrlPageUp": "PreviousTab|LastTab",
"CtrlPageDown": "NextTab|FirstTab",
"ShiftPageUp": "SelectPageUp",
"ShiftPageDown": "SelectPageDown",
"Ctrl-g": "ToggleHelp",
@ -75,10 +75,12 @@ var bufdefaults = map[string]string{
"Ctrl-b": "ShellMode",
"Ctrl-q": "Quit",
"Ctrl-e": "CommandMode",
"Ctrl-w": "NextSplit",
"Ctrl-w": "NextSplit|FirstSplit",
"Ctrl-u": "ToggleMacro",
"Ctrl-j": "PlayMacro",
"Insert": "ToggleOverwriteMode",
"Alt-<": "JumpToOpeningBrace",
"Alt->": "JumpToClosingBrace",
// Emacs-style keybindings
"Alt-f": "WordRight",
@ -149,8 +151,8 @@ var infodefaults = map[string]string{
"Backtab": "CycleAutocompleteBack",
"Ctrl-z": "Undo",
"Ctrl-y": "Redo",
"Ctrl-c": "CopyLine|Copy",
"Ctrl-x": "Cut",
"Ctrl-c": "Copy|CopyLine",
"Ctrl-x": "Cut|CutLine",
"Ctrl-k": "CutLine",
"Ctrl-v": "Paste",
"Home": "StartOfTextToggle",

View File

@ -349,6 +349,16 @@ func (t *Tab) SetActive(i int) {
}
}
// AddPane adds a pane at a given index
func (t *Tab) AddPane(pane Pane, i int) {
if len(t.Panes) == i {
t.Panes = append(t.Panes, pane)
return
}
t.Panes = append(t.Panes[:i+1], t.Panes[i:]...)
t.Panes[i] = pane
}
// GetPane returns the pane with the given split index
func (t *Tab) GetPane(splitid uint64) int {
for i, p := range t.Panes {

View File

@ -1132,46 +1132,133 @@ var BracePairs = [][2]rune{
{'[', ']'},
}
func (b *Buffer) findOpeningBrace(braceType [2]rune, start Loc) (Loc, bool) {
// Bound guard
start = clamp(start, b.LineArray)
if len(b.lines) == 0 {
return start, false
}
i := 1
// If we are on a closing brace, let the counter be incremented below when we traverse
curLine := []rune(string(b.LineBytes(start.Y)))
if start.X >= 0 && start.X < len(curLine) {
startChar := curLine[start.X]
if startChar == braceType[1] {
i = 0
}
}
for y := start.Y; y >= 0; y-- {
l := []rune(string(b.lines[y].data))
xInit := len(l) - 1
if y == start.Y && start.X < len(curLine) {
xInit = start.X
}
for x := xInit; x >= 0; x-- {
r := l[x]
if r == braceType[1] {
i++
} else if r == braceType[0] {
i--
if i == 0 {
return Loc{x, y}, true
}
}
}
}
return start, false
}
// Returns the opening brace in current brace scope starting at the start location and a boolean
// indicating if an opening brace is found
func (b *Buffer) FindOpeningBrace(start Loc) (Loc, bool) {
currentDist := -1
currentMb := Loc{-1, -1}
for _, bp := range BracePairs {
mb, found := b.findOpeningBrace(bp, start)
if found {
dist := DiffLA(start, mb, b.LineArray)
if currentDist < 0 || dist < currentDist {
currentMb = mb
currentDist = dist
}
}
}
if currentDist == -1 {
return start, false
} else {
return currentMb, true
}
}
func (b *Buffer) findClosingBrace(braceType [2]rune, start Loc) (Loc, bool) {
// Bound guard
start = clamp(start, b.LineArray)
if len(b.lines) == 0 {
return start, false
}
i := 1
// If we are on an opening brace, let the counter be incremented below when we traverse
curLine := []rune(string(b.LineBytes(start.Y)))
if start.X >= 0 && start.X < len(curLine) {
startChar := curLine[start.X]
if startChar == braceType[0] {
i = 0
}
}
for y := start.Y; y < b.LinesNum(); y++ {
l := []rune(string(b.LineBytes(y)))
xInit := 0
if y == start.Y && start.X >= 0 {
xInit = start.X
}
for x := xInit; x < len(l); x++ {
r := l[x]
if r == braceType[0] {
i++
} else if r == braceType[1] {
i--
if i == 0 {
return Loc{x, y}, true
}
}
}
}
return start, false
}
// Returns the closing brace in current brace scope starting at the start location and a boolean
// indicating if an closing brace is found
func (b *Buffer) FindClosingBrace(start Loc) (Loc, bool) {
currentDist := -1
currentMb := Loc{-1, -1}
for _, bp := range BracePairs {
mb, found := b.findClosingBrace(bp, start)
if found {
dist := DiffLA(start, mb, b.LineArray)
if currentDist < 0 || dist < currentDist {
currentMb = mb
currentDist = dist
}
}
}
if currentDist == -1 {
return start, false
} else {
return currentMb, true
}
}
func (b *Buffer) findMatchingBrace(braceType [2]rune, start Loc, char rune) (Loc, bool) {
var i int
if char == braceType[0] {
for y := start.Y; y < b.LinesNum(); y++ {
l := []rune(string(b.LineBytes(y)))
xInit := 0
if y == start.Y {
xInit = start.X
}
for x := xInit; x < len(l); x++ {
r := l[x]
if r == braceType[0] {
i++
} else if r == braceType[1] {
i--
if i == 0 {
return Loc{x, y}, true
}
}
}
}
return b.findClosingBrace(braceType, start)
} else if char == braceType[1] {
for y := start.Y; y >= 0; y-- {
l := []rune(string(b.lines[y].data))
xInit := len(l) - 1
if y == start.Y {
xInit = start.X
}
for x := xInit; x >= 0; x-- {
r := l[x]
if r == braceType[1] {
i++
} else if r == braceType[0] {
i--
if i == 0 {
return Loc{x, y}, true
}
}
}
}
return b.findOpeningBrace(braceType, start)
}
return start, false
}

View File

@ -33,6 +33,8 @@ can change it!
| PageDown | Move cursor down one page |
| Ctrl-Home or Ctrl-UpArrow | Move cursor to start of document |
| Ctrl-End or Ctrl-DownArrow | Move cursor to end of document |
| Alt-< | Move cursor to opening brace in current brace scope |
| Alt-> | Move cursor to closing brace in current brace scope |
| Ctrl-l | Jump to a line in the file (prompts with #) |
| Ctrl-w | Cycle between splits in the current tab (use `> vsplit` or `> hsplit` to create a split) |

View File

@ -253,11 +253,15 @@ QuitAll
AddTab
PreviousTab
NextTab
FirstTab
LastTab
NextSplit
Unsplit
VSplit
HSplit
PreviousSplit
FirstSplit
LastSplit
ToggleMacro
PlayMacro
Suspend (Unix only)
@ -270,14 +274,25 @@ SpawnMultiCursorSelect
RemoveMultiCursor
RemoveAllMultiCursors
SkipMultiCursor
SkipMultiCursorBack
None
JumpToMatchingBrace
JumpToOpeningBrace
JumpToClosingBrace
Autocomplete
```
The `StartOfTextToggle` and `SelectToStartOfTextToggle` actions toggle between
jumping to the start of the text (first) and start of the line.
The `CutLine` action cuts the current line and adds it to the previously cut
lines in the clipboard since the last paste (rather than just replaces the
clipboard contents with this line). So you can cut multiple, not necessarily
consecutive lines to the clipboard just by pressing `Ctrl-k` multiple times,
without selecting them. If you want the more traditional behavior i.e. just
rewrite the clipboard every time, you can use `CopyLine,DeleteLine` action
instead of `CutLine`.
You can also bind some mouse actions (these must be bound to mouse buttons)
```
@ -495,23 +510,23 @@ conventions for text editing defaults.
"Alt-]": "DiffNext|CursorEnd",
"Ctrl-z": "Undo",
"Ctrl-y": "Redo",
"Ctrl-c": "CopyLine|Copy",
"Ctrl-x": "Cut",
"Ctrl-c": "Copy|CopyLine",
"Ctrl-x": "Cut|CutLine",
"Ctrl-k": "CutLine",
"Ctrl-d": "DuplicateLine",
"Ctrl-d": "Duplicate|DuplicateLine",
"Ctrl-v": "Paste",
"Ctrl-a": "SelectAll",
"Ctrl-t": "AddTab",
"Alt-,": "PreviousTab",
"Alt-.": "NextTab",
"Alt-,": "PreviousTab|LastTab",
"Alt-.": "NextTab|FirstTab",
"Home": "StartOfText",
"End": "EndOfLine",
"CtrlHome": "CursorStart",
"CtrlEnd": "CursorEnd",
"PageUp": "CursorPageUp",
"PageDown": "CursorPageDown",
"CtrlPageUp": "PreviousTab",
"CtrlPageDown": "NextTab",
"CtrlPageUp": "PreviousTab|LastTab",
"CtrlPageDown": "NextTab|FirstTab",
"ShiftPageUp": "SelectPageUp",
"ShiftPageDown": "SelectPageDown",
"Ctrl-g": "ToggleHelp",
@ -522,10 +537,12 @@ conventions for text editing defaults.
"Ctrl-b": "ShellMode",
"Ctrl-q": "Quit",
"Ctrl-e": "CommandMode",
"Ctrl-w": "NextSplit",
"Ctrl-w": "NextSplit|FirstSplit",
"Ctrl-u": "ToggleMacro",
"Ctrl-j": "PlayMacro",
"Insert": "ToggleOverwriteMode",
"Alt-<": "JumpToOpeningBrace",
"Alt->": "JumpToClosingBrace",
// Emacs-style keybindings
"Alt-f": "WordRight",
@ -621,8 +638,8 @@ are given below:
"Backtab": "CycleAutocompleteBack",
"Ctrl-z": "Undo",
"Ctrl-y": "Redo",
"Ctrl-c": "CopyLine|Copy",
"Ctrl-x": "Cut",
"Ctrl-c": "Copy|CopyLine",
"Ctrl-x": "Cut|CutLine",
"Ctrl-k": "CutLine",
"Ctrl-v": "Paste",
"Home": "StartOfTextToggle",