diff --git a/cmd/micro/lineArray.go b/cmd/micro/lineArray.go index 18ec251b..955ceec7 100644 --- a/cmd/micro/lineArray.go +++ b/cmd/micro/lineArray.go @@ -2,32 +2,12 @@ package main import ( "bufio" - "bytes" "io" "unicode/utf8" "github.com/zyedidia/micro/cmd/micro/highlight" ) -func lineCounter(r io.Reader) (int, error) { - buf := make([]byte, 32*1024) - count := 0 - lineSep := []byte{'\n'} - - for { - c, err := r.Read(buf) - count += bytes.Count(buf[:c], lineSep) - - switch { - case err == io.EOF: - return count, nil - - case err != nil: - return count, err - } - } -} - func runeToByteIndex(n int, txt []byte) int { if n == 0 { return 0 diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index 663b217b..f2c1e466 100644 --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -439,25 +439,27 @@ func main() { t.Resize() } case *tcell.EventMouse: - if e.Buttons() == tcell.Button1 { - // If the user left clicked we check a couple things - _, h := screen.Size() - x, y := e.Position() - if y == h-1 && messenger.message != "" && globalSettings["infobar"].(bool) { - // If the user clicked in the bottom bar, and there is a message down there - // we copy it to the clipboard. - // Often error messages are displayed down there so it can be useful to easily - // copy the message - clipboard.WriteAll(messenger.message, "primary") - break - } + if !searching { + if e.Buttons() == tcell.Button1 { + // If the user left clicked we check a couple things + _, h := screen.Size() + x, y := e.Position() + if y == h-1 && messenger.message != "" && globalSettings["infobar"].(bool) { + // If the user clicked in the bottom bar, and there is a message down there + // we copy it to the clipboard. + // Often error messages are displayed down there so it can be useful to easily + // copy the message + clipboard.WriteAll(messenger.message, "primary") + break + } - if CurView().mouseReleased { - // We loop through each view in the current tab and make sure the current view - // is the one being clicked in - for _, v := range tabs[curTab].views { - if x >= v.x && x < v.x+v.Width && y >= v.y && y < v.y+v.Height { - tabs[curTab].CurView = v.Num + if CurView().mouseReleased { + // We loop through each view in the current tab and make sure the current view + // is the one being clicked in + for _, v := range tabs[curTab].views { + if x >= v.x && x < v.x+v.Width && y >= v.y && y < v.y+v.Height { + tabs[curTab].CurView = v.Num + } } } } diff --git a/cmd/micro/view.go b/cmd/micro/view.go index 5f80f55d..946fd7fc 100644 --- a/cmd/micro/view.go +++ b/cmd/micro/view.go @@ -929,12 +929,6 @@ func (v *View) DisplayView() { } } -// DisplayCursor draws the current buffer's cursor to the screen -func (v *View) DisplayCursor(x, y int) { - // screen.ShowCursor(v.x+v.Cursor.GetVisualX()+v.lineNumOffset-v.leftCol, y) - screen.ShowCursor(x, y) -} - // Display renders the view, the cursor, and statusline func (v *View) Display() { if GetGlobalOption("termtitle").(bool) { @@ -942,7 +936,7 @@ func (v *View) Display() { } v.DisplayView() // Don't draw the cursor if it is out of the viewport or if it has a selection - if (v.Cursor.Y-v.Topline < 0 || v.Cursor.Y-v.Topline > v.Height-1) || v.Cursor.HasSelection() { + if (v.Cursor.Y-v.Topline < 0 || v.Cursor.Y-v.Topline > v.Height-1) || (v.Cursor.HasSelection() && v.Num == tabs[curTab].CurView) { screen.HideCursor() } _, screenH := screen.Size()