Commit Graph

11 Commits

Author SHA1 Message Date
JiXieShi 341476f10a feat: auto-load all .lua plugins from plugins/ directory
Replace loadDefaultDemoPlugin with loadPluginsFromDir that scans the
plugins/ directory for .lua files and loads them all. All plugins are
disabled by default; user enables them via .plugin enable or TUI panel.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 02:07:26 +08:00
JiXieShi 76cd507236 test: restore and adapt test files for new package structure
- Rewrite internal/app/app_test.go for new App API (sess injection,
  command.NewDispatcher, appconfig.Config)
- Add internal/command/command_test.go (completion + parseOnOff tests)
- Console escape_test.go restored and adapted (cfg parameter)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 00:02:17 +08:00
JiXieShi 209ecac2d5 feat: enhance plugin system with Go helpers and add Modbus plugin
- Register Go helper functions (modbus.crc16, hex.encode/decode,
  util.bytes) into Lua states for Modbus RTU support
- Add plugins/modbus.lua with .modbus read/write commands
- Fix Reload race condition (hold lock across Unload+Load)
- Make App.Close nil-safe for sess
- Restore internal/console/console_test.go

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 00:01:22 +08:00
JiXieShi 30d6c2bc3c feat: add TCP Server, UDP Server, and COM port forwarding modes
Extend Mode constants (3=TCPServer, 4=UDPServer, 5=COMPort) with
explicit values. Refactor Target to support multiple connection types
(listener+conns map, packetConn, serialPort). Add acceptLoop,
readLoopPacket, readLoopSerial. Mode-aware Broadcast dispatches to
all accepted conns (TCP-S), known remotes (UDP-S), or serial port.
Update flag help, command completions, and TUI panel hints.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 23:10:02 +08:00
JiXieShi d8fc9d7374 refactor: split termapp into proper internal packages
Replace monolithic internal/termapp with proper separation:
- internal/app: App struct, lifecycle, output loops
- internal/command: CommandHost interface, Dispatcher, handlers
- internal/tui: Model, hotkeys, panels, render (with panelError + border fixes)
- internal/console: RunConsole, escape parsing, entry point logic
- cmd/serialterminal: thin main() calling console.Run()

Eliminate global vars (cfg, sess, out) via dependency injection.
Break App->CommandDispatcher cycle via CommandHost interface.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 22:46:02 +08:00
JiXieShi daad844d4f fix: TUI 'g' key input, EndStr panel editing, and mode validation
- Remove 'g' and 'shift+g' from viewport handler (conflicted with
  text input; home/end keys already provide same functionality)
- Add rawValue field to modeItem to preserve EndStr control chars
  during TUI panel editing (fixes %q round-trip corruption)
- Add validation for empty charset names and timefmt fields

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 22:25:47 +08:00
JiXieShi 8139162174 refactor: move all app code to internal/termapp and entry to cmd/
Consolidate remaining package main files into internal/termapp for
clean separation: cmd/serialterminal/ is the sole entry point.
Update .goreleaser.yaml to build from ./cmd/serialterminal.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 21:56:45 +08:00
JiXieShi 65c1a48f10 refactor: simplify flag system and extract to internal/flag
Replace complex ptrVal/Val/Flag type machinery with direct pflag
calls. Move flag logic and interactive wizard to internal/flag
package. Eliminate ~200 lines of flag boilerplate.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 21:52:40 +08:00
JiXieShi a1524a7e17 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>
2026-05-23 21:49:43 +08:00
JiXieShi 31dd9da490 refactor: extract internal/config and eliminate global config var
Move Config struct to internal/config with exported fields. Replace
global var config with package-level cfg pointer. Add OpenLogFile to
config package. Add type alias Config = appconfig.Config in main
package for backward compatibility.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 21:45:08 +08:00
JiXieShi e0de872740 refactor: extract pkg/charset and internal/event packages
Extract ConvertChunk/FormatHexFrame into pkg/charset (zero external deps).
Extract UIEvent/UIEventKind/UIPanelKind types into internal/event.
Update all references across main package to use qualified imports.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-22 02:35:30 +08:00