From cb7553181822ea0f95a5d50e1d64d0cdb2a888b2 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Thu, 21 Sep 2017 17:10:53 -0400 Subject: [PATCH] Make mouse option global option Fixes #816 --- cmd/micro/buffer.go | 4 ---- cmd/micro/micro.go | 4 ++++ cmd/micro/settings.go | 17 ++++++++--------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/cmd/micro/buffer.go b/cmd/micro/buffer.go index 692fad8e..776ee65d 100644 --- a/cmd/micro/buffer.go +++ b/cmd/micro/buffer.go @@ -188,10 +188,6 @@ func NewBuffer(reader io.Reader, size int64, path string) *Buffer { file.Close() } - if b.Settings["mouse"].(bool) { - screen.EnableMouse() - } - if !b.Settings["fastdirty"].(bool) { b.origHash = md5.Sum([]byte(b.String())) } diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index d2fc5227..dc7b1c0e 100644 --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -202,6 +202,10 @@ func InitScreen() { os.Setenv("TERM", oldTerm) } + if GetGlobalOption("mouse").(bool) { + screen.EnableMouse() + } + screen.SetStyle(defStyle) } diff --git a/cmd/micro/settings.go b/cmd/micro/settings.go index 134ef68f..336a2295 100644 --- a/cmd/micro/settings.go +++ b/cmd/micro/settings.go @@ -243,7 +243,6 @@ func DefaultLocalSettings() map[string]interface{} { "filetype": "Unknown", "ignorecase": false, "indentchar": " ", - "mouse": true, "rmtrailingws": false, "ruler": true, "savecursor": false, @@ -318,6 +317,14 @@ func SetOption(option, value string) error { } } + if option == "mouse" { + if !nativeValue.(bool) { + screen.DisableMouse() + } else { + screen.EnableMouse() + } + } + if _, ok := CurView().Buf.Settings[option]; ok { for _, tab := range tabs { for _, view := range tab.views { @@ -405,14 +412,6 @@ func SetLocalOption(option, value string, view *View) error { } } - if option == "mouse" { - if !nativeValue.(bool) { - screen.DisableMouse() - } else { - screen.EnableMouse() - } - } - return nil }