commit b455cc9

Alexey Yerin  ·  2021-04-27 18:22:35 +0000 UTC
parent 73ad4e7
Make mouse support optional

To not break existing users, mouse is enabled by default but you have an
option to disable it with "mouse: false" in your
/.confg/senpai/senpai.yaml.
4 files changed,  +14, -1
M app.go
M app.go
+6, -0
 1@@ -52,12 +52,18 @@ func NewApp(cfg Config) (app *App, err error) {
 2 		}
 3 	}
 4 
 5+	mouse := true
 6+	if cfg.Mouse != nil {
 7+		mouse = *cfg.Mouse
 8+	}
 9+
10 	app.win, err = ui.New(ui.Config{
11 		NickColWidth: cfg.NickColWidth,
12 		ChanColWidth: cfg.ChanColWidth,
13 		AutoComplete: func(cursorIdx int, text []rune) []ui.Completion {
14 			return app.completions(cursorIdx, text)
15 		},
16+		Mouse: mouse,
17 	})
18 	if err != nil {
19 		return
+1, -0
1@@ -16,6 +16,7 @@ type Config struct {
2 	NoTLS    bool `yaml:"no-tls"`
3 
4 	NoTypings bool `yaml:"no-typings"`
5+	Mouse     *bool
6 
7 	Highlights   []string
8 	OnHighlight  string `yaml:"on-highlight"`
+3, -0
 1@@ -68,6 +68,9 @@ Some settings are required, the others are optional.
 2 	Prevent senpai from sending typing notifications which let others know when
 3 	you are typing a message.  Defaults to false.
 4 
 5+*mouse*
 6+	Enable or disable mouse support.  Defaults to true.
 7+
 8 *debug*
 9 	Dump all sent and received data to the home buffer, useful for debugging.
10 	By default, false.
+4, -1
 1@@ -12,6 +12,7 @@ type Config struct {
 2 	NickColWidth int
 3 	ChanColWidth int
 4 	AutoComplete func(cursorIdx int, text []rune) []Completion
 5+	Mouse bool
 6 }
 7 
 8 type UI struct {
 9@@ -40,7 +41,9 @@ func New(config Config) (ui *UI, err error) {
10 	if err != nil {
11 		return
12 	}
13-	ui.screen.EnableMouse()
14+	if ui.screen.HasMouse() && config.Mouse {
15+		ui.screen.EnableMouse()
16+	}
17 	ui.screen.EnablePaste()
18 
19 	w, h := ui.screen.Size()