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 guiQuit(gui *gocui.Gui, v *gocui.View) error {
40 func mute(gui *gocui.Gui, v *gocui.View) error {
45 func tabHandle(gui *gocui.Gui, v *gocui.View) error {
46 sids := make([]int, 0, len(Streams)+1)
47 sids = append(sids, -1)
48 for sid := range Streams {
49 sids = append(sids, int(sid))
52 if CurrentView+1 >= len(sids) {
58 gui.SetCurrentView("chat")
60 gui.SetCurrentView(Streams[byte(sids[CurrentView])].name)
65 func chatEnter(gui *gocui.Gui, v *gocui.View) error {
68 Ctrl <- vors.ArgsEncode([]byte(vors.CmdChat), []byte(msg[:len(msg)-1]))
69 log.Println("me:", msg[:len(msg)-1])
76 func guiLayout(gui *gocui.Gui) error {
78 maxX, GUIMaxY = gui.Size()
80 v, err := gui.SetView("logs", 0, prevY, maxX-1, prevY+7+2)
83 if err != gocui.ErrUnknownView {
86 v.Title = fmt.Sprintf("Logs room=%s", *Room)
90 v, err = gui.SetView("chat", 0, prevY, maxX-1, prevY+2)
92 if err != gocui.ErrUnknownView {
97 if err := GUI.SetKeybinding(
98 "chat", gocui.KeyEnter, gocui.ModNone, chatEnter,
104 sids := make([]int, 0, len(Streams))
105 for sid := range Streams {
106 sids = append(sids, int(sid))
110 for _, sid := range sids {
111 stream = Streams[byte(sid)]
112 v, err = gui.SetView(stream.name, 0, prevY, maxX/2-1, prevY+2)
114 if err != gocui.ErrUnknownView {
117 if stream.name == *Name {
118 v.Title = ">" + stream.name + "<"
120 v.Title = stream.name
123 _, err = gui.SetView(stream.name+"-vol", maxX/2, prevY, maxX-1, prevY+2)
126 if err != gocui.ErrUnknownView {
134 gui.SetCurrentView("chat")