commit b5d6516

sewn  ·  2026-08-14 14:21:08 +0000 UTC
parent 454d290
Remove buttons

This partially reverts commits c7858c8978c46dceff912191c9f23d153fcd09dc,
f5c599efccb261ab051037a54cefbd7b6765149a,
206be659439e3e11461daf17cf5ca04e9417cf85
4 files changed,  +6, -149
M app.go
M app.go
+6, -86
  1@@ -189,9 +189,6 @@ func NewApp(cfg Config) (app *App, err error) {
  2 		}
  3 	}
  4 
  5-	mouse := cfg.Mouse
  6-	buttons := cfg.Buttons
  7-
  8 	app.win, app.cfg.Colors, err = ui.New(ui.Config{
  9 		NickColWidth:     cfg.NickColWidth,
 10 		ChanColWidth:     cfg.ChanColWidth,
 11@@ -202,8 +199,7 @@ func NewApp(cfg Config) (app *App, err error) {
 12 		AutoComplete: func(cursorIdx int, text []rune) []ui.Completion {
 13 			return app.completions(cursorIdx, text)
 14 		},
 15-		Mouse:   mouse,
 16-		Buttons: buttons,
 17+		Mouse: cfg.Mouse,
 18 		MergeLine: func(former *ui.Line, addition ui.Line) {
 19 			app.mergeLine(former, addition)
 20 		},
 21@@ -643,11 +639,6 @@ func (app *App) handleUIEvent(ev interface{}) bool {
 22 }
 23 
 24 func (app *App) handleMouseEvent(ev vaxis.Mouse) {
 25-	memberItems := 3
 26-	if !app.cfg.Buttons {
 27-		memberItems = 0
 28-	}
 29-
 30 	x, y := ev.Col, ev.Row
 31 	w, h := app.win.Size()
 32 
 33@@ -663,7 +654,7 @@ func (app *App) handleMouseEvent(ev vaxis.Mouse) {
 34 		if ev.Button == vaxis.MouseWheelUp {
 35 			if x < app.win.ChannelWidth() || (app.win.ChannelWidth() == 0 && y == h-1) {
 36 				app.win.ScrollChannelUpBy(4)
 37-			} else if x > w-app.win.MemberWidth() && y < h-memberItems*2 {
 38+			} else if x > w-app.win.MemberWidth() {
 39 				app.win.ScrollMemberUpBy(4)
 40 			} else if y == 0 {
 41 				app.win.ScrollTopicLeftBy(12)
 42@@ -674,7 +665,7 @@ func (app *App) handleMouseEvent(ev vaxis.Mouse) {
 43 		if ev.Button == vaxis.MouseWheelDown {
 44 			if x < app.win.ChannelWidth() || (app.win.ChannelWidth() == 0 && y == h-1) {
 45 				app.win.ScrollChannelDownBy(4)
 46-			} else if x > w-app.win.MemberWidth() && y < h-memberItems*2 {
 47+			} else if x > w-app.win.MemberWidth() {
 48 				app.win.ScrollMemberDownBy(4)
 49 			} else if y == 0 {
 50 				app.win.ScrollTopicRightBy(12)
 51@@ -691,42 +682,8 @@ func (app *App) handleMouseEvent(ev vaxis.Mouse) {
 52 				app.win.ClickBuffer(app.win.HorizontalBufferOffset(x))
 53 			} else if x == w-app.win.MemberWidth() {
 54 				app.win.ClickMemberCol(true)
 55-			} else if x > w-app.win.MemberWidth() && y >= 2 && y < h-memberItems*2 {
 56+			} else if x > w-app.win.MemberWidth() && y >= 2 {
 57 				app.win.ClickMember(y - 2 + app.win.MemberOffset())
 58-			} else if x > w-app.win.MemberWidth() && y >= h-memberItems*2 && (y-(h-memberItems*2))%2 == 1 {
 59-				netID, target := app.win.CurrentBuffer()
 60-				var failed bool
 61-				switch (y - (h - memberItems*2)) / 2 {
 62-				case 0:
 63-					muted := app.win.GetMuted(netID, target)
 64-					if s := app.sessions[netID]; s != nil && target != "" {
 65-						if !s.MutedSet(target, !muted) {
 66-							failed = true
 67-						}
 68-					}
 69-				case 1:
 70-					pinned := app.win.GetPinned(netID, target)
 71-					if s := app.sessions[netID]; s != nil && target != "" {
 72-						if !s.PinnedSet(target, !pinned) {
 73-							failed = true
 74-						}
 75-					}
 76-				case 2:
 77-					s := app.sessions[netID]
 78-					if s != nil && s.IsChannel(target) {
 79-						s.Part(target, "")
 80-					} else {
 81-						app.win.RemoveBuffer(netID, target)
 82-					}
 83-				}
 84-				if failed {
 85-					netID, buffer := app.win.CurrentBuffer()
 86-					app.win.AddLine(netID, buffer, ui.Line{
 87-						At:   time.Now(),
 88-						Head: ui.ColorString("!!", ui.ColorRed),
 89-						Body: ui.PlainString(errNotSupported.Error()),
 90-					})
 91-				}
 92 			} else {
 93 				app.win.SelectMessageAt(y)
 94 				app.win.Click(x, y, ev)
 95@@ -774,47 +731,10 @@ func (app *App) handleMouseEvent(ev vaxis.Mouse) {
 96 				app.win.GoToBufferNo(i)
 97 				app.clearBufferCommand()
 98 			}
 99-		} else if x > w-app.win.MemberWidth() && y < h-memberItems*2 {
100+		} else if x > w-app.win.MemberWidth() {
101 			if i := y - 2 + app.win.MemberOffset(); i >= 0 && i == app.win.ClickedMember() {
102 				netID, target := app.win.CurrentBuffer()
103-				if target == "" {
104-					switch y {
105-					case 2:
106-						if _, err := getBouncerService(app); err != nil {
107-							app.win.AddLine(netID, target, ui.Line{
108-								At:   time.Now(),
109-								Head: ui.ColorString("--", ui.ColorRed),
110-								Body: ui.PlainSprintf("Adding networks is not available: %v", err),
111-							})
112-						} else {
113-							app.win.AddLine(netID, target, ui.Line{
114-								At:   time.Now(),
115-								Head: ui.PlainString("--"),
116-								Body: ui.PlainString("To join a network/server, use /bouncer network create -addr <address> [-name <name>]"),
117-							})
118-							app.win.AddLine(netID, target, ui.Line{
119-								At:   time.Now(),
120-								Head: ui.PlainString("--"),
121-								Body: ui.PlainString("For details, see /bouncer help network create"),
122-							})
123-							app.win.InputSet("/bouncer network create -addr ")
124-						}
125-					case 4:
126-						app.win.AddLine(netID, target, ui.Line{
127-							At:   time.Now(),
128-							Head: ui.PlainString("--"),
129-							Body: ui.PlainString("To join a channel, use /join <#channel> [<password>]"),
130-						})
131-						app.win.InputSet("/join ")
132-					case 6:
133-						app.win.AddLine(netID, target, ui.Line{
134-							At:   time.Now(),
135-							Head: ui.PlainString("--"),
136-							Body: ui.PlainString("To message a user, use /query <user> [<message>]"),
137-						})
138-						app.win.InputSet("/query ")
139-					}
140-				} else if s := app.sessions[netID]; s != nil {
141+				if s := app.sessions[netID]; s != nil && target != "" {
142 					members := s.Names(target)
143 					if i < len(members) {
144 						buffer := members[i].Name.Name
+0, -11
 1@@ -102,7 +102,6 @@ type Config struct {
 2 	Typings     bool
 3 	Mouse       bool
 4 	NickPrefix  bool
 5-	Buttons     bool
 6 
 7 	Highlights       []string
 8 	OnHighlightPath  string
 9@@ -149,7 +148,6 @@ func Defaults() Config {
10 		NickPrefix:       true,
11 		Typings:          true,
12 		Mouse:            true,
13-		Buttons:          true,
14 		Highlights:       nil,
15 		OnHighlightPath:  "",
16 		OnHighlightBeep:  false,
17@@ -401,15 +399,6 @@ func unmarshal(filename string, cfg *Config) (err error) {
18 			if cfg.Mouse, err = strconv.ParseBool(mouse); err != nil {
19 				return err
20 			}
21-		case "buttons":
22-			var buttons string
23-			if err := d.ParseParams(&buttons); err != nil {
24-				return err
25-			}
26-
27-			if cfg.Buttons, err = strconv.ParseBool(buttons); err != nil {
28-				return err
29-			}
30 		case "nick-prefix":
31 			var nickPrefix string
32 			if err := d.ParseParams(&nickPrefix); err != nil {
+0, -4
 1@@ -135,10 +135,6 @@ pane-widths {
 2 	buffer. Only the highest-priority prefix is shown. Has no effect in
 3 	private query buffers. Defaults to false.
 4 
 5-*buttons*
 6-	Enable or disable mouse buttons in the UI.  Defaults to true.
 7-	Has no effect without mouse set to true.
 8-
 9 *colors* { ... }
10 	Settings for colors of different UI elements.
11 
+0, -48
 1@@ -25,7 +25,6 @@ type Config struct {
 2 	TextMaxWidth      int
 3 	AutoComplete      func(cursorIdx int, text []rune) []Completion
 4 	Mouse             bool
 5-	Buttons           bool
 6 	MergeLine         func(former *Line, addition Line)
 7 	Colors            ConfigColors
 8 	LocalIntegrations bool
 9@@ -934,32 +933,6 @@ func (ui *UI) drawVerticalMemberList(vx *Vaxis, x0, y0, width, height int, b *bu
10 	width--
11 	clearArea(vx, x0, y0, width, height)
12 
13-	if _, channel := ui.bs.Current(); channel == "" && ui.config.Mouse && ui.config.Buttons {
14-		x := x0 + 1
15-		printString(vx, &x, y0, Styled("Help", vaxis.Style{
16-			Foreground: ui.config.Colors.Status,
17-		}))
18-		ui.drawHorizontalLine(vx, x0, y0+1, width)
19-		y0 += 2
20-
21-		lines := []string{
22-			"→Add network",
23-			"→Join channel",
24-			"→Message user",
25-		}
26-		for i, line := range lines {
27-			var st vaxis.Style
28-			if i*2 == ui.memberClicked {
29-				st.Attribute |= vaxis.AttrReverse
30-			}
31-			x := x0
32-			printString(vx, &x, y0, Styled(line, st))
33-			ui.drawHorizontalLine(vx, x0, y0+1, width)
34-			y0 += 2
35-		}
36-		return
37-	}
38-
39 	if len(members) > 0 {
40 		var memberString string
41 		if len(members) > 1 {
42@@ -979,27 +952,6 @@ func (ui *UI) drawVerticalMemberList(vx *Vaxis, x0, y0, width, height int, b *bu
43 	y0++
44 	height--
45 
46-	if ui.config.Mouse && ui.config.Buttons {
47-		var actions []string
48-		if b.muted {
49-			actions = append(actions, "→ Unmute")
50-		} else {
51-			actions = append(actions, "→ Mute")
52-		}
53-		if b.pinned {
54-			actions = append(actions, "→ Unpin")
55-		} else {
56-			actions = append(actions, "→ Pin")
57-		}
58-		actions = append(actions, "→ Leave")
59-		for i, action := range actions {
60-			x := x0
61-			ui.drawHorizontalLine(vx, x0, y0+height-(len(actions)-i)*2, width)
62-			printString(vx, &x, y0+height-(len(actions)-i)*2+1, Styled(action, vaxis.Style{}))
63-		}
64-		height -= 2 * len(actions)
65-	}
66-
67 	padding := 1
68 	for _, m := range members {
69 		if m.Disconnected {