mirror of
https://github.com/zyedidia/micro.git
synced 2024-10-06 00:22:12 +03:00
Compare commits
24 Commits
492d2b97a1
...
6254a7c41d
Author | SHA1 | Date | |
---|---|---|---|
|
6254a7c41d | ||
|
4f4a13a9a1 | ||
|
9eaeb193d4 | ||
|
ca6012086b | ||
|
5f83661fee | ||
|
2e44db1ee9 | ||
|
bf6584739f | ||
|
68d6f43c63 | ||
|
6f724bc424 | ||
|
25f71eec2d | ||
|
33a1bb120f | ||
|
04143c7a89 | ||
|
e6825f0e08 | ||
|
fdacb28962 | ||
|
9f7bdb109b | ||
|
c1bbd7b041 | ||
|
a317aefd6d | ||
|
830768b715 | ||
|
2860efbe3a | ||
|
52ed4315ff | ||
|
8bc67569f9 | ||
|
df8d5285bf | ||
|
19c69f9eaa | ||
|
30291fa75d |
52
completions/bash/micro.bash
Normal file
52
completions/bash/micro.bash
Normal file
@ -0,0 +1,52 @@
|
||||
#compdef micro -*- shell-script -*-
|
||||
|
||||
# Shell completion for micro command
|
||||
# To be installed in "/usr/share/bash-completion/completions/micro"
|
||||
# and "/usr/share/zsh/site-functions/"
|
||||
|
||||
_micro() {
|
||||
local prev cur plugin_opts all_opts
|
||||
COMPREPLY=()
|
||||
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
plugin_opts='remove update search list available'
|
||||
all_opts='-clean -config-dir -options -debug -version -plugin'
|
||||
|
||||
case "${prev}" in
|
||||
-plugin)
|
||||
COMPREPLY=( $(compgen -W "${plugin_opts}" -- "${cur}") )
|
||||
return 0
|
||||
;;
|
||||
-config-dir)
|
||||
_filedir -d
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
_filedir -d
|
||||
;;
|
||||
esac
|
||||
|
||||
# Options
|
||||
case "${cur}" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "${all_opts}" -- "${cur}") )
|
||||
return 0
|
||||
;;
|
||||
--*)
|
||||
COMPREPLY=( $( compgen -W "--version --help" -- "${cur}") )
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $( compgen -W "${all_opts}" -- "${cur}") )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
if [[ -n ${ZSH_VERSION} ]]; then
|
||||
autoload -U bashcompinit
|
||||
bashcompinit
|
||||
fi
|
||||
|
||||
complete -F _micro micro
|
9
completions/nush/micro.nu
Normal file
9
completions/nush/micro.nu
Normal file
@ -0,0 +1,9 @@
|
||||
export extern "micro" [
|
||||
-version(-v) # Show version of eza
|
||||
-help # Show list of command-line options
|
||||
-clean # Cleans the configuration directory
|
||||
-config-dir # Specify a custom location for the configuration directory
|
||||
-option # Show all option help
|
||||
-debug # Enable debug mode (enables logging to ./log.txt)
|
||||
-plugin # Manage micro plugins. Use either of "remove", "update", "search", "list", or "available" subcommands
|
||||
]
|
24
completions/zsh/micro.zsh
Normal file
24
completions/zsh/micro.zsh
Normal file
@ -0,0 +1,24 @@
|
||||
#compdef micro -*- shell-script -*-
|
||||
|
||||
# Save this file as _micro in /usr/local/share/zsh/site-functions or in any
|
||||
# other folder in $fpath. E.g. save it in a folder called ~/.zfunc and add a
|
||||
# line containing `fpath=(~/.zfunc $fpath)` somewhere before `compinit` in your
|
||||
# ~/.zshrc.
|
||||
|
||||
__micro() {
|
||||
# Give completions using the `_arguments` utility function with
|
||||
# `-s` for option stacking like `micro -ab` for `micro -a -b` and
|
||||
# `-S` for delimiting options with `--` like in `micro -- -a`.
|
||||
_arguments -s -S \
|
||||
"(- *)"{-v,-version}"[Show the version number and information]" \
|
||||
"(- *)"-help"[Show list of command-line options]" \
|
||||
-clean"[Cleans the configuration directory]" \
|
||||
-config-dir"[Specify a custom location for the configuration directory]" \
|
||||
-option"[Show all option help]" \
|
||||
-debug"[Enable debug mode (enables logging to ./log.txt)]" \
|
||||
-plugin"[Manage micro plugins]:(action):(remove update search list available)" \
|
||||
'*:filename:_files'
|
||||
}
|
||||
#$(micro -options | grep -oE '^-[[:alnum:]@-]+' | tr '\n' ' ') \
|
||||
|
||||
__micro
|
@ -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
|
||||
}
|
||||
@ -1793,27 +1871,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 +1937,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 +2167,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 +2184,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 +2204,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 {
|
||||
|
@ -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,6 +851,7 @@ var BufKeyActions = map[string]BufKeyAction{
|
||||
"RemoveMultiCursor": (*BufPane).RemoveMultiCursor,
|
||||
"RemoveAllMultiCursors": (*BufPane).RemoveAllMultiCursors,
|
||||
"SkipMultiCursor": (*BufPane).SkipMultiCursor,
|
||||
"SkipMultiCursorBack": (*BufPane).SkipMultiCursorBack,
|
||||
"JumpToMatchingBrace": (*BufPane).JumpToMatchingBrace,
|
||||
"JumpLine": (*BufPane).JumpLine,
|
||||
"Deselect": (*BufPane).Deselect,
|
||||
@ -907,6 +918,7 @@ var MultiActions = map[string]bool{
|
||||
"Copy": true,
|
||||
"Cut": true,
|
||||
"CutLine": true,
|
||||
"Duplicate": true,
|
||||
"DuplicateLine": true,
|
||||
"DeleteLine": true,
|
||||
"MoveLinesUp": true,
|
||||
|
@ -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
|
||||
|
@ -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,7 +72,7 @@ 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",
|
||||
@ -146,8 +146,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",
|
||||
|
@ -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,7 +75,7 @@ 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",
|
||||
@ -149,8 +149,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",
|
||||
|
@ -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 {
|
||||
|
@ -253,11 +253,15 @@ QuitAll
|
||||
AddTab
|
||||
PreviousTab
|
||||
NextTab
|
||||
FirstTab
|
||||
LastTab
|
||||
NextSplit
|
||||
Unsplit
|
||||
VSplit
|
||||
HSplit
|
||||
PreviousSplit
|
||||
FirstSplit
|
||||
LastSplit
|
||||
ToggleMacro
|
||||
PlayMacro
|
||||
Suspend (Unix only)
|
||||
@ -270,6 +274,7 @@ SpawnMultiCursorSelect
|
||||
RemoveMultiCursor
|
||||
RemoveAllMultiCursors
|
||||
SkipMultiCursor
|
||||
SkipMultiCursorBack
|
||||
None
|
||||
JumpToMatchingBrace
|
||||
Autocomplete
|
||||
@ -278,6 +283,14 @@ 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 +508,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,7 +535,7 @@ 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",
|
||||
@ -621,8 +634,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",
|
||||
|
Loading…
Reference in New Issue
Block a user