From f8a171379a1922c7fb211a3524e94b26b7497060 Mon Sep 17 00:00:00 2001 From: JT Olio Date: Thu, 5 Apr 2018 15:25:30 -0600 Subject: [PATCH 1/3] home toggles between start of line and start of text by default home sends the cursor to the beginning of the line. if the cursor is at the beginning of the line already though, home will send the cursor to the first non-whitespace rune. tapping home will toggle between these two line starts. --- cmd/micro/actions.go | 6 +++++- cmd/micro/cursor.go | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/cmd/micro/actions.go b/cmd/micro/actions.go index 21179e3b..4d52e79b 100644 --- a/cmd/micro/actions.go +++ b/cmd/micro/actions.go @@ -435,7 +435,11 @@ func (v *View) StartOfLine(usePlugin bool) bool { v.deselect(0) - v.Cursor.Start() + if v.Cursor.X != 0 { + v.Cursor.Start() + } else { + v.Cursor.StartOfText() + } if usePlugin { return PostActionCall("StartOfLine", v) diff --git a/cmd/micro/cursor.go b/cmd/micro/cursor.go index 15b01010..452268ba 100644 --- a/cmd/micro/cursor.go +++ b/cmd/micro/cursor.go @@ -333,6 +333,18 @@ func (c *Cursor) Start() { c.LastVisualX = c.GetVisualX() } +// StartOfText moves the cursor to the first non-whitespace rune of +// the line it is on +func (c *Cursor) StartOfText() { + c.Start() + for IsWhitespace(c.RuneUnder(c.X)) { + if c.X == Count(c.buf.Line(c.Y)) { + break + } + c.Right() + } +} + // GetCharPosInLine gets the char position of a visual x y // coordinate (this is necessary because tabs are 1 char but // 4 visual spaces) From 0eadf283a52246b606e192e57fb20b81a4777f42 Mon Sep 17 00:00:00 2001 From: JT Olio Date: Thu, 5 Apr 2018 19:45:11 -0600 Subject: [PATCH 2/3] darcula: fix highlighted line and color column --- runtime/colorschemes/darcula.micro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/colorschemes/darcula.micro b/runtime/colorschemes/darcula.micro index 1511a0ad..435b579e 100644 --- a/runtime/colorschemes/darcula.micro +++ b/runtime/colorschemes/darcula.micro @@ -19,8 +19,8 @@ color-link line-number "#666666,#242424" color-link current-line-number "#666666,#242424" color-link gutter-error "#CB4B16,#242424" color-link gutter-warning "#E6DB74,#242424" -color-link cursor-line "#2C2C2C" -color-link color-column "#2C2C2C" +color-link cursor-line "default,#2C2C2C" +color-link color-column "default,#2C2C2C" #No extended types; Plain brackets. color-link type.extended "default" #color-link symbol.brackets "default" From b181342ff1117c1014323eb4bef5188b7f2ec7f4 Mon Sep 17 00:00:00 2001 From: Mark Weston Date: Mon, 23 Apr 2018 22:34:45 +0300 Subject: [PATCH 3/3] Make ^X act like ^K when nothing is selected (#1092) * Make ^X act like ^K when nothing is selected ^K is hard to reach with your left hand or requires to use both hands Also with this you could remove ^K whatsoever and make room for a different command This is how I configured nano by the way Line duplication also becomes nearly instantaneous with a flash-quick ^X+^V+^V combo (nano doesn't have a dedicated shortcut) Small block (5-10 lines) cuts/copies/duplicates can also be made this way * Remove unnecessary lines * Call CutLine the right way --- cmd/micro/actions.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/micro/actions.go b/cmd/micro/actions.go index 4d52e79b..a291c88d 100644 --- a/cmd/micro/actions.go +++ b/cmd/micro/actions.go @@ -1219,9 +1219,9 @@ func (v *View) Cut(usePlugin bool) bool { return PostActionCall("Cut", v) } return true + } else { + return v.CutLine(usePlugin) } - - return false } // DuplicateLine duplicates the current line or selection