Fix some minor things, add config.toml.dist

master
Tyler Sommer 3 years ago
parent 0a1fda6ab5
commit a50cc3b667
Signed by: tyler-sommer
GPG Key ID: C09C010500DBD008

1
.gitignore vendored

@ -4,3 +4,4 @@ plugins/
plugins
squirssi*.log
vendor/
config.toml

@ -5,7 +5,7 @@ SUBPACKAGES := colors
SQUIRCY3_ROOT ?= ../squircy3
PLUGINS := $(patsubst $(SQUIRCY3_ROOT)/plugins/%,%,$(wildcard $(SQUIRCY3_ROOT)/plugins/*))
SOURCES := $(wildcard *.go) $(wildcard cmd/*/*.go) $(wildcard $(patsubst %,%/*.go,$(SUBPACKAGES))) $(shell find vendor/ -type f -name '*.go')
SOURCES := $(wildcard *.go) $(wildcard cmd/*/*.go) $(wildcard $(patsubst %,%/*.go,$(SUBPACKAGES))) $(shell find vendor/ -type f -name '*.go' 2> /dev/null)
OUTPUT_BASE := out
@ -22,7 +22,7 @@ TESTDATA_NODEMODS_TARGET := testdata/node_modules
all: build
clean:
rm -rf plugins/ && cp -r $(SQUIRCY3_ROOT)/plugins .
rm -rf plugins && cp -r $(SQUIRCY3_ROOT)/plugins .
rm -rf $(OUTPUT_BASE)
build: squirssi

@ -0,0 +1,14 @@
[irc]
auto=true
nick="squishyjones"
user="mrjones"
network="chat.freenode.net:6697"
tls=true
sasl=false
#sasl_username=""
#sasl_password=""
#server_password=""
[vm]
modules_path="/tmp/squircy_modules"

@ -6,7 +6,9 @@ require (
code.dopame.me/veonik/squircy3 v0.0.0-20200924052855-a0f559182525
github.com/dop251/goja v0.0.0-20200526165454-f1752421c432
github.com/gizak/termui/v3 v3.1.0
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mattn/go-runewidth v0.0.9
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.6.0
golang.org/x/sys v0.0.0-20200918174421-af09f7315aff // indirect

@ -1,5 +1,3 @@
code.dopame.me/veonik/squircy3 v0.0.0-20200921021324-82d536b9a59b h1:3wWnqhxFq3DkYgFRLzdRb77BZVnWAdgbs6cDgLE9e8g=
code.dopame.me/veonik/squircy3 v0.0.0-20200921021324-82d536b9a59b/go.mod h1:D0PZ58ANI0zuFIgCLrhmBSZQmLeKFd0vL+6YP2AamYc=
code.dopame.me/veonik/squircy3 v0.0.0-20200924052855-a0f559182525 h1:NkCqYaQxM02/IPmh2Epl1yi3/+SBrskLDwx3e7R3XNg=
code.dopame.me/veonik/squircy3 v0.0.0-20200924052855-a0f559182525/go.mod h1:D0PZ58ANI0zuFIgCLrhmBSZQmLeKFd0vL+6YP2AamYc=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=

@ -99,6 +99,7 @@ func onIRCNick(srv *Server, ev *IRCEvent) {
srv.mu.Lock()
if ev.Nick == srv.currentNick {
nick = MyNick(srv.currentNick)
srv.currentNick = newNick
}
srv.mu.Unlock()
WriteNick(srv.WindowManager, nick, newNick)
@ -107,11 +108,11 @@ func onIRCNick(srv *Server, ev *IRCEvent) {
func onIRCKick(srv *Server, ev *IRCEvent) {
channel := ev.Target
kicked := SomeNick(ev.Args[1])
srv.mu.Lock()
srv.mu.RLock()
if kicked.string == srv.currentNick {
kicked = MyNick(srv.currentNick)
}
srv.mu.Unlock()
srv.mu.RUnlock()
if kicked.me {
go func() {
<-time.After(2 * time.Second)
@ -194,9 +195,9 @@ func onIRCWhois(srv *Server, ev *IRCEvent) {
func onIRCNames(srv *Server, ev *IRCEvent) {
if ev.Code == "PART" || ev.Code == "KICK" {
srv.mu.Lock()
srv.mu.RLock()
myNick := srv.currentNick
srv.mu.Unlock()
srv.mu.RUnlock()
if ev.Nick == myNick {
// dont bother trying to get names when we are the one leaving
return
@ -216,7 +217,9 @@ func onIRCNames(srv *Server, ev *IRCEvent) {
func onIRCJoin(srv *Server, ev *IRCEvent) {
target := ev.Target
win := srv.WindowManager.Named(target)
srv.mu.RLock()
myNick := srv.currentNick
srv.mu.RUnlock()
if win == nil {
ch := &Channel{
bufferedWindow: newBufferedWindow(target, srv.events),
@ -232,11 +235,11 @@ func onIRCPart(srv *Server, ev *IRCEvent) {
target := ev.Target
nick := SomeNick(ev.Nick)
win := srv.WindowManager.Named(target)
srv.mu.Lock()
srv.mu.RLock()
if ev.Nick == srv.currentNick {
nick = MyNick(srv.currentNick)
}
srv.mu.Unlock()
srv.mu.RUnlock()
if win == nil {
if !nick.me {
// dont bother logging if we are the ones leaving
@ -251,9 +254,9 @@ func onIRCAction(srv *Server, ev *IRCEvent) {
direct := false
target := ev.Target
nick := ev.Nick
srv.mu.Lock()
srv.mu.RLock()
myNick := MyNick(srv.currentNick)
srv.mu.Unlock()
srv.mu.RUnlock()
if target == myNick.string {
// its a direct message!
direct = true
@ -265,11 +268,9 @@ func onIRCAction(srv *Server, ev *IRCEvent) {
logrus.Warnln("received action message with no Window:", target, ev.Message, nick)
return
} else {
srv.mu.Lock()
ch := &DirectMessage{bufferedWindow: newBufferedWindow(target, srv.events)}
srv.WindowManager.Append(ch)
win = ch
srv.mu.Unlock()
}
}
msg := SomeMessage(ev.Message, myNick)
@ -280,9 +281,9 @@ func onIRCPrivmsg(srv *Server, ev *IRCEvent) {
direct := false
target := ev.Target
nick := ev.Nick
srv.mu.Lock()
srv.mu.RLock()
myNick := MyNick(srv.currentNick)
srv.mu.Unlock()
srv.mu.RUnlock()
if target == myNick.string {
// its a direct message!
direct = true
@ -294,11 +295,9 @@ func onIRCPrivmsg(srv *Server, ev *IRCEvent) {
logrus.Warnln("received message with no Window:", target, ev.Message, nick)
return
} else {
srv.mu.Lock()
ch := &DirectMessage{bufferedWindow: newBufferedWindow(target, srv.events)}
srv.WindowManager.Append(ch)
win = ch
srv.mu.Unlock()
}
}
msg := SomeMessage(ev.Message, myNick)
@ -308,10 +307,10 @@ func onIRCPrivmsg(srv *Server, ev *IRCEvent) {
func onIRCQuit(srv *Server, ev *IRCEvent) {
nick := SomeNick(ev.Nick)
message := ev.Message
srv.mu.Lock()
srv.mu.RLock()
if ev.Nick == srv.currentNick {
nick = MyNick(srv.currentNick)
}
srv.mu.Unlock()
srv.mu.RUnlock()
WriteQuit(srv.WindowManager, nick, message)
}

@ -40,7 +40,7 @@ func (f *logFormatter) Format(entry *logrus.Entry) ([]byte, error) {
type HistoryManager struct {
histories map[Window][]ModedText
cursors map[Window]int
cursors map[Window]int
mu sync.Mutex
}
@ -48,7 +48,7 @@ type HistoryManager struct {
func NewHistoryManager() *HistoryManager {
return &HistoryManager{
histories: make(map[Window][]ModedText),
cursors: make(map[Window]int),
cursors: make(map[Window]int),
}
}
@ -58,7 +58,7 @@ func (hm *HistoryManager) Append(win Window, input ModedText) {
hm.cursors[win] = len(hm.histories[win])
hm.append(win, input)
hm.cursors[win] = len(hm.histories[win])
logrus.Infoln("resetting cursor for", win.Title(), "now on", hm.cursors[win])
logrus.Debugln("resetting cursor for", win.Title(), "now on", hm.cursors[win])
}
func (hm *HistoryManager) Insert(win Window, input ModedText) {
@ -71,7 +71,7 @@ func (hm *HistoryManager) Insert(win Window, input ModedText) {
}
func (hm *HistoryManager) append(win Window, input ModedText) {
logrus.Infoln("inserting to history for", win.Title(), input, "at index", hm.cursors[win])
logrus.Debugln("inserting to history for", win.Title(), input, "at index", hm.cursors[win])
hm.histories[win] = append(append(append([]ModedText{}, hm.histories[win][:hm.cursors[win]]...), input), hm.histories[win][hm.cursors[win]:]...)
}
@ -79,7 +79,7 @@ func (hm *HistoryManager) current(win Window) ModedText {
if hm.cursors[win] < 0 {
hm.cursors[win] = 0
}
logrus.Infof("currently have %d records for %s", len(hm.histories[win]), win.Title())
logrus.Debugln("currently have %d records for %s", len(hm.histories[win]), win.Title())
if hm.cursors[win] >= len(hm.histories[win]) {
hm.cursors[win] = len(hm.histories[win])
return ModedText{}
@ -98,7 +98,7 @@ func (hm *HistoryManager) Previous(win Window) ModedText {
defer hm.mu.Unlock()
hm.cursors[win] -= 1
res := hm.current(win)
logrus.Infoln("previous history for", win.Title(), hm.cursors[win])
logrus.Debugln("previous history for", win.Title(), hm.cursors[win])
return res
}
@ -107,7 +107,7 @@ func (hm *HistoryManager) Next(win Window) ModedText {
defer hm.mu.Unlock()
hm.cursors[win] += 1
res := hm.current(win)
logrus.Infoln("next history for", win.Title(), hm.cursors[win])
logrus.Debugln("next history for", win.Title(), hm.cursors[win])
return res
}
@ -130,10 +130,9 @@ type Server struct {
currentNick string
WindowManager *WindowManager
WindowManager *WindowManager
HistoryManager *HistoryManager
mu sync.RWMutex
done chan struct{}

@ -44,9 +44,9 @@ func (i *TextInput) Peek() string {
}
i.Lock()
defer i.Unlock()
i.Text = strings.Replace(i.Text, "[C](mod:reverse)", string(0x03),-1)
i.Text = strings.Replace(i.Text, "[B](mod:reverse)", string(0x02),-1)
i.Text = strings.Replace(i.Text, "[U](mod:reverse)", string(0x1F),-1)
i.Text = strings.Replace(i.Text, "[C](mod:reverse)", string(0x03), -1)
i.Text = strings.Replace(i.Text, "[B](mod:reverse)", string(0x02), -1)
i.Text = strings.Replace(i.Text, "[U](mod:reverse)", string(0x1F), -1)
t := i.Text[i.prefixLen : len(i.Text)-i.cursorLen]
i.Text = strings.Replace(i.Text, string(0x03), "[C](mod:reverse)", -1)
i.Text = strings.Replace(i.Text, string(0x02), "[B](mod:reverse)", -1)
@ -63,9 +63,9 @@ func (i *TextInput) Consume() string {
i.Lock()
defer i.Unlock()
t := i.Text[i.prefixLen : len(i.Text)-i.cursorLen]
t = strings.Replace(t, "[C](mod:reverse)", string(0x03),-1)
t = strings.Replace(t, "[B](mod:reverse)", string(0x02),-1)
t = strings.Replace(t, "[U](mod:reverse)", string(0x1F),-1)
t = strings.Replace(t, "[C](mod:reverse)", string(0x03), -1)
t = strings.Replace(t, "[B](mod:reverse)", string(0x02), -1)
t = strings.Replace(t, "[U](mod:reverse)", string(0x1F), -1)
return t
}
@ -73,9 +73,9 @@ func (i *TextInput) Consume() string {
func (i *TextInput) Len() int {
i.Lock()
defer i.Unlock()
i.Text = strings.Replace(i.Text, "[C](mod:reverse)", string(0x03),-1)
i.Text = strings.Replace(i.Text, "[B](mod:reverse)", string(0x02),-1)
i.Text = strings.Replace(i.Text, "[U](mod:reverse)", string(0x1F),-1)
i.Text = strings.Replace(i.Text, "[C](mod:reverse)", string(0x03), -1)
i.Text = strings.Replace(i.Text, "[B](mod:reverse)", string(0x02), -1)
i.Text = strings.Replace(i.Text, "[U](mod:reverse)", string(0x1F), -1)
l := len(i.Text) - i.cursorLen - i.prefixLen
i.Text = strings.Replace(i.Text, string(0x03), "[C](mod:reverse)", -1)
i.Text = strings.Replace(i.Text, string(0x02), "[B](mod:reverse)", -1)
@ -109,9 +109,9 @@ func (i *TextInput) Append(in string) {
func (i *TextInput) Backspace() {
i.Lock()
defer i.Unlock()
i.Text = strings.Replace(i.Text, "[C](mod:reverse)", string(0x03),-1)
i.Text = strings.Replace(i.Text, "[B](mod:reverse)", string(0x02),-1)
i.Text = strings.Replace(i.Text, "[U](mod:reverse)", string(0x1F),-1)
i.Text = strings.Replace(i.Text, "[C](mod:reverse)", string(0x03), -1)
i.Text = strings.Replace(i.Text, "[B](mod:reverse)", string(0x02), -1)
i.Text = strings.Replace(i.Text, "[U](mod:reverse)", string(0x1F), -1)
if len(i.Text) > i.prefixLen+i.cursorLen {
i.Text = (i.Text)[0:len(i.Text)-i.cursorLen-1] + i.cursor
}

@ -16,17 +16,17 @@ import (
type ChatPane struct {
ui.Block
Rows []string
WrapText bool
TextStyle ui.Style
SelectedRow int
LeftPadding int
Rows []string
WrapText bool
TextStyle ui.Style
SelectedRow int
LeftPadding int
}
func NewChatPane() *ChatPane {
return &ChatPane{
Block: *ui.NewBlock(),
TextStyle: ui.Theme.List.Text,
Block: *ui.NewBlock(),
TextStyle: ui.Theme.List.Text,
}
}
@ -69,7 +69,7 @@ func ParseIRCStyles(c []ui.Cell) []ui.Cell {
fg := ""
bg := ""
eat := 0
for j := i+1; j-i < 5 && j < len(c); j++ {
for j := i + 1; j-i < 5 && j < len(c); j++ {
cx := c[j]
if unicode.IsDigit(cx.Rune) {
eat++
@ -115,7 +115,7 @@ func WrapCellsPadded(cells []ui.Cell, width uint, leftPadding int) []ui.Cell {
wrappedCells := []ui.Cell{}
i := 0
twoLines := false
loop:
loop:
for x, _rune := range wrapped {
if _rune == '\n' {
wrappedCells = append(wrappedCells, ui.Cell{_rune, ui.StyleClear})
@ -155,7 +155,7 @@ func (self *ChatPane) Draw(buf *ui.Buffer) {
l := len(p)
e := actualLen + l
actualLen = e
rows[i] = e-1
rows[i] = e - 1
for j := 0; j < l; j++ {
actuals = append(actuals, p[j])
}
@ -219,7 +219,7 @@ type ActivityTabPane struct {
func NewActivityTabPane() *ActivityTabPane {
return &ActivityTabPane{
TabPane: widgets.NewTabPane(" 0 "),
TabPane: widgets.NewTabPane(" 0 "),
}
}

@ -45,21 +45,20 @@ type bufferedWindow struct {
lines []string
current int
hasUnseen bool
hasNotice bool
hasUnseen bool
hasNotice bool
autoScroll bool
events *event.Dispatcher
mu sync.RWMutex
}
func newBufferedWindow(name string, events *event.Dispatcher) bufferedWindow {
return bufferedWindow{
name: name,
events: events,
name: name,
events: events,
current: -1,
current: -1,
autoScroll: true,
}
}
@ -121,7 +120,7 @@ func (c *bufferedWindow) CurrentLine() int {
c.mu.RLock()
defer c.mu.RUnlock()
if c.autoScroll {
return len(c.lines)-1
return len(c.lines) - 1
}
return c.current
}

@ -27,6 +27,7 @@ func NewWindowManager(ev *event.Dispatcher) *WindowManager {
}
type activityType int
const TabHasActivity activityType = 0
const TabHasNotice activityType = 1
@ -120,7 +121,7 @@ func (wm *WindowManager) SelectIndex(idx int) {
func (wm *WindowManager) SelectNext() {
wm.mu.Lock()
defer wm.mu.Unlock()
idx := wm.activeIndex+1
idx := wm.activeIndex + 1
if idx >= len(wm.windows) || idx < 0 {
idx = 0
}
@ -131,9 +132,9 @@ func (wm *WindowManager) SelectNext() {
func (wm *WindowManager) SelectPrev() {
wm.mu.Lock()
defer wm.mu.Unlock()
idx := wm.activeIndex-1
idx := wm.activeIndex - 1
if idx >= len(wm.windows) || idx < 0 {
idx = len(wm.windows)-1
idx = len(wm.windows) - 1
}
wm.activeIndex = idx
wm.events.Emit("ui.DIRTY", nil)
@ -163,7 +164,7 @@ func (wm *WindowManager) ScrollOffset(offset int) {
wm.mu.RLock()
win := wm.windows[wm.activeIndex]
wm.mu.RUnlock()
wm.ScrollTo(win.CurrentLine()+offset)
wm.ScrollTo(win.CurrentLine() + offset)
}
// ScrollTo scrolls the currently active window to the given position.
@ -178,4 +179,4 @@ func (wm *WindowManager) ScrollTo(pos int) {
}
win.ScrollTo(pos)
wm.events.Emit("ui.DIRTY", nil)
}
}

@ -10,7 +10,7 @@ import (
type Message struct {
string
mine bool
mine bool
refsMe bool
}
@ -130,7 +130,7 @@ func WritePart(win Window, nick Nick, message string) {
if title == message {
message = ""
} else {
message = " ("+message+")"
message = " (" + message + ")"
}
if _, err := win.Write([]byte(fmt.Sprintf("%s[|](fg:grey) %s left %s%s", padding, nick.String(), title, message))); err != nil {
logrus.Warnln("%s: failed to write part message:", err)
@ -142,7 +142,7 @@ func WriteKick(win Window, nick Nick, message string) {
if nick.string == message {
message = ""
} else {
message = " ("+message+")"
message = " (" + message + ")"
}
if _, err := win.Write([]byte(fmt.Sprintf("%s[|](fg:grey) %s got kicked from %s%s", padding, nick.String(), win.Title(), message))); err != nil {
logrus.Warnln("failed to write kick message:", err)

Loading…
Cancel
Save