1 // VoRS -- Vo(IP) Really Simple
2 // Copyright (C) 2024 Sergey Matveev <stargrave@stargrave.org>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, version 3 of the License.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Affero General Public License for more details.
13 // You should have received a copy of the GNU Affero General Public License
14 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 "github.com/jroimartin/gocui"
24 vors "go.stargrave.org/vors/v3/internal"
30 GUIReadyC = make(chan struct{})
35 func tabHandle(gui *gocui.Gui, v *gocui.View) error {
36 sids := make([]int, 0, len(Streams)+1)
37 sids = append(sids, -1)
38 for sid := range Streams {
39 sids = append(sids, int(sid))
42 if CurrentView+1 >= len(sids) {
48 gui.SetCurrentView("chat")
50 gui.SetCurrentView(Streams[byte(sids[CurrentView])].name)
55 func chatEnter(gui *gocui.Gui, v *gocui.View) error {
58 Ctrl <- vors.ArgsEncode([]byte(vors.CmdChat), []byte(msg[:len(msg)-1]))
59 log.Println("me:", msg[:len(msg)-1])
66 func guiLayout(gui *gocui.Gui) error {
68 maxX, GUIMaxY = gui.Size()
70 v, err := gui.SetView("logs", 0, prevY, maxX-1, prevY+7+2)
73 if err != gocui.ErrUnknownView {
76 v.Title = fmt.Sprintf("Logs room=%s", *Room)
80 v, err = gui.SetView("chat", 0, prevY, maxX-1, prevY+2)
82 if err != gocui.ErrUnknownView {
87 if err := GUI.SetKeybinding(
88 "chat", gocui.KeyEnter, gocui.ModNone, chatEnter,
94 sids := make([]int, 0, len(Streams))
95 for sid := range Streams {
96 sids = append(sids, int(sid))
99 for _, sid := range sids {
100 stream := Streams[byte(sid)]
101 v, err = gui.SetView(stream.name, 0, prevY, maxX/2-1, prevY+2)
103 if err != gocui.ErrUnknownView {
106 if stream.name == *Name {
107 v.Title = ">" + stream.name + "<"
109 v.Title = stream.name
110 if err := GUI.SetKeybinding(
111 stream.name, gocui.KeyEnter, gocui.ModNone, func(*gocui.Gui, *gocui.View) error {
112 stream.silenced = !stream.silenced
120 _, err = gui.SetView(stream.name+"-vol", maxX/2, prevY, maxX-1, prevY+2)
123 if err != gocui.ErrUnknownView {
131 gui.SetCurrentView("chat")