~taiite/public-inbox

senpai: Make Ctrl-] toggle the member list, Ctrl-\ the channel list v2 PROPOSED

mooff: 1
 Make Ctrl-] toggle the member list, Ctrl-\ the channel list

 3 files changed, 36 insertions(+), 6 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~taiite/public-inbox/patches/31144/mbox | git am -3
Learn more about email & git

[PATCH senpai v2] Make Ctrl-] toggle the member list, Ctrl-\ the channel list Export this patch

---
 app.go           | 32 ++++++++++++++++++++++++++------
 doc/senpai.1.scd |  6 ++++++
 ui/ui.go         |  4 ++++
 3 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/app.go b/app.go
index 5973986..0673392 100644
--- a/app.go
+++ b/app.go
@@ -404,9 +404,9 @@ func (app *App) handleMouseEvent(ev *tcell.EventMouse) {
	x, y := ev.Position()
	w, _ := app.win.Size()
	if ev.Buttons()&tcell.WheelUp != 0 {
		if x < app.cfg.ChanColWidth {
		if x < app.win.Config().ChanColWidth {
			app.win.ScrollChannelUpBy(4)
		} else if x > w-app.cfg.MemberColWidth {
		} else if x > w-app.win.Config().MemberColWidth {
			app.win.ScrollMemberUpBy(4)
		} else {
			app.win.ScrollUpBy(4)
@@ -414,19 +414,19 @@ func (app *App) handleMouseEvent(ev *tcell.EventMouse) {
		}
	}
	if ev.Buttons()&tcell.WheelDown != 0 {
		if x < app.cfg.ChanColWidth {
		if x < app.win.Config().ChanColWidth {
			app.win.ScrollChannelDownBy(4)
		} else if x > w-app.cfg.MemberColWidth {
		} else if x > w-app.win.Config().MemberColWidth {
			app.win.ScrollMemberDownBy(4)
		} else {
			app.win.ScrollDownBy(4)
		}
	}
	if ev.Buttons()&tcell.ButtonPrimary != 0 && x < app.cfg.ChanColWidth {
	if ev.Buttons()&tcell.ButtonPrimary != 0 && x < app.win.Config().ChanColWidth {
		app.win.ClickBuffer(y + app.win.ChannelOffset())
	}
	if ev.Buttons() == 0 {
		if x < app.cfg.ChanColWidth {
		if x < app.win.Config().ChanColWidth {
			if i := y + app.win.ChannelOffset(); i == app.win.ClickedBuffer() {
				app.win.GoToBufferNo(i)
			}
@@ -521,6 +521,26 @@ func (app *App) handleKeyEvent(ev *tcell.EventKey) {
		if ok {
			app.typing()
		}
	case tcell.KeyCtrlRightSq:
		if app.cfg.MemberColWidth == 0 {
			app.cfg.MemberColWidth = 16
		}
		if app.win.Config().MemberColWidth == app.cfg.MemberColWidth {
			app.win.Config().MemberColWidth = 0
		} else {
			app.win.Config().MemberColWidth = app.cfg.MemberColWidth
		}
		app.win.Resize()
	case tcell.KeyCtrlBackslash:
		if app.cfg.ChanColWidth == 0 {
			app.cfg.ChanColWidth = 16
		}
		if app.win.Config().ChanColWidth == app.cfg.ChanColWidth {
			app.win.Config().ChanColWidth = 0
		} else {
			app.win.Config().ChanColWidth = app.cfg.ChanColWidth
		}
		app.win.Resize()
	case tcell.KeyBacktab:
		ok := app.win.InputAutoComplete(-1)
		if ok {
diff --git a/doc/senpai.1.scd b/doc/senpai.1.scd
index 8ff0d18..6014b17 100644
--- a/doc/senpai.1.scd
+++ b/doc/senpai.1.scd
@@ -107,6 +107,12 @@ of messages are in the timeline:
	Trigger the auto-completion.  Press several times to cycle through
	completions.

*CTRL-]*
	Show / hide the member list.

*CTRL-\\*
	Toggle the channel list (column vs row mode).

*CTRL-L*
	Refresh the window.

diff --git a/ui/ui.go b/ui/ui.go
index 7e02812..492411d 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -78,6 +78,10 @@ func New(config Config) (ui *UI, err error) {
	return
}

func (ui *UI) Config() *Config {
	return &ui.config
}

func (ui *UI) ShouldExit() bool {
	return ui.exit.Load().(bool)
}
-- 
2.30.2
Thanks for the patch!

I had trouble applying it at first: maybe it wasn't based off of the latest master (or maybe due to master changing around the time you sent this patch in)?

After manually applying it, I found that it worked exactly as described. I really think this is an important feature for senpai to have.

On Fri Apr 15, 2022 at 12:14 PM EST, mooff wrote:
Thanks for the patch!

I have modified it to my liking and merged it as 
db5a4b730f72a66c60074a0854f64f05c1bf6c1d.

I set keys F7 & F8 in order to make them keyboard layout independent.