mirror of
https://github.com/jixishi/SerialTerminalForWindowsTerminal.git
synced 2026-06-16 00:52:44 +00:00
refactor: extract internal/session and eliminate I/O globals
Move serial port, trzsz filter, and pipe lifecycle into internal/session.SerialSession. Replace 8 global I/O vars (serialPort, trzszFilter, stdinPipe, stdoutPipe, clientIn, clientOut, termch, termchOnce) with single sess variable. Delete utils.go. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+7
-3
@@ -9,6 +9,7 @@ import (
|
||||
"go.bug.st/serial"
|
||||
|
||||
"github.com/jixishi/SerialTerminalForWindowsTerminal/internal/event"
|
||||
"github.com/jixishi/SerialTerminalForWindowsTerminal/internal/session"
|
||||
"github.com/jixishi/SerialTerminalForWindowsTerminal/pkg/forward"
|
||||
"github.com/jixishi/SerialTerminalForWindowsTerminal/pkg/luaplugin"
|
||||
)
|
||||
@@ -204,11 +205,14 @@ func TestReportForwardIngress(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendCtrl(t *testing.T) {
|
||||
oldSp := serialPort
|
||||
defer func() { serialPort = oldSp }()
|
||||
if sess == nil {
|
||||
sess = &session.SerialSession{}
|
||||
}
|
||||
oldSp := sess.Port
|
||||
defer func() { sess.Port = oldSp }()
|
||||
|
||||
// Use a mock serial port
|
||||
serialPort = &mockSerialPort{}
|
||||
sess.Port = &mockSerialPort{}
|
||||
a := &App{
|
||||
cfg: &Config{},
|
||||
uiEvents: make(chan event.UIEvent, 4),
|
||||
|
||||
Reference in New Issue
Block a user