diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..1fcbbc8 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,92 @@ +# Builds and tests the three apps and the library they share +name: Build + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + linux: + name: Linux (GTK 4) + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - name: Packages + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + cmake ninja-build pkg-config libgtk-4-dev libadwaita-1-dev \ + libvte-2.91-gtk4-dev + - name: Build + run: | + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo + cmake --build build + - name: Test + run: ctest --test-dir build --output-on-failure + - name: Test with the sanitizers + run: | + cmake -S . -B build-asan -G Ninja -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_C_FLAGS="-fsanitize=address,undefined -fno-sanitize-recover=all" + cmake --build build-asan --target dmodemctl_test + ctest --test-dir build-asan --output-on-failure + + windows-9x: + name: Windows 95 and later (Open Watcom) + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: open-watcom/setup-watcom@v0 + with: + version: "2.0" + - name: Build + run: sh windows/build-watcom.sh build/watcom + - uses: actions/upload-artifact@v4 + with: + name: dmodem-windows-9x + path: build/watcom/dmodem.exe + + windows: + name: Windows (MSVC) + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - name: Build + run: | + cmake -S . -B build -A Win32 + cmake --build build --config Release + - name: Test + run: ctest --test-dir build -C Release --output-on-failure + - uses: actions/upload-artifact@v4 + with: + name: dmodem-windows + path: build/windows/Release/dmodem.exe + + macos: + name: macOS (SwiftUI) + runs-on: macos-15 + steps: + - uses: actions/checkout@v4 + - name: Library tests + run: | + cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo + cmake --build build + ctest --test-dir build --output-on-failure + - name: Project + run: | + brew install xcodegen + cd macos && xcodegen + - name: Build + run: | + cd macos + xcodebuild -project DModem.xcodeproj -scheme DModem \ + -configuration Release -derivedDataPath ../build/xcode \ + CODE_SIGN_IDENTITY=- build + - uses: actions/upload-artifact@v4 + with: + name: dmodem-macos + path: build/xcode/Build/Products/Release/D-Modem.app diff --git a/core/src/session.c b/core/src/session.c index 5d52fd9..17858aa 100644 --- a/core/src/session.c +++ b/core/src/session.c @@ -32,7 +32,8 @@ #define ESCAPE_OK_MS 3000 /* RINGs are this far apart at most (a ring cadence is 6 s) */ #define RING_GAP_MS 8000 -/* a line longer than this is cut (a configurator's screen has none) */ +/* a line longer than this keeps only its end (a configurator's + screens come with no line ends, and its OK after the last one) */ #define LINE_MAX 4096 struct command { @@ -602,8 +603,9 @@ void dmc_feed(dmc_session *s, const char *data, int n) } if (c == '\r') continue; - if (s->line.n < LINE_MAX) - buf_addc(&s->line, c); + if (s->line.n >= LINE_MAX) + buf_drop(&s->line, s->line.n - LINE_MAX / 2); + buf_addc(&s->line, c); } } diff --git a/core/test/dmodemctl_test.c b/core/test/dmodemctl_test.c index c990505..3f27d81 100644 --- a/core/test/dmodemctl_test.c +++ b/core/test/dmodemctl_test.c @@ -243,6 +243,16 @@ static void test_typed(void) CHECK(dmc_state(s) == DMC_CONFIGURATOR); feed(s, "\x1b[0m\x1b[2J\x1b[H\x1b[?25h\r\nOK\r\n"); CHECK(dmc_state(s) == DMC_IDLE); + /* its screens as one line longer than a line is kept, the OK at the + end of it (as AT!CF's Alt-X sends it) */ + dmc_type(s, "AT!CF\r", 6); + out(s); + CHECK(dmc_state(s) == DMC_CONFIGURATOR); + for (int i = 0; i < 1000; i++) + feed(s, "\x1b[0;30;47m\xe2\x96\x91"); + CHECK(dmc_state(s) == DMC_CONFIGURATOR); + feed(s, "\x1b[0m\x1b[2J\x1b[H\x1b[?25hOK\r\n"); + CHECK(dmc_state(s) == DMC_IDLE); /* refused (off hook) */ dmc_type(s, "AT!CT\r", 6); CHECK(dmc_state(s) == DMC_CONFIGURATOR); diff --git a/docs/images/windows-modem.png b/docs/images/windows-modem.png new file mode 100644 index 0000000..41e338f Binary files /dev/null and b/docs/images/windows-modem.png differ diff --git a/docs/images/windows-settings.png b/docs/images/windows-settings.png new file mode 100644 index 0000000..d1e0c44 Binary files /dev/null and b/docs/images/windows-settings.png differ diff --git a/docs/images/windows-setup-screen.png b/docs/images/windows-setup-screen.png new file mode 100644 index 0000000..b12bbf5 Binary files /dev/null and b/docs/images/windows-setup-screen.png differ diff --git a/windows/src/pages.cpp b/windows/src/pages.cpp index 97ca820..1312130 100644 --- a/windows/src/pages.cpp +++ b/windows/src/pages.cpp @@ -38,8 +38,10 @@ HWND page_new(HWND parent, CommandFn fn) RegisterClass(&wc); registered = true; } + /* (no WS_CLIPCHILDREN: a group box paints only its frame, so the + page paints behind it) */ HWND w = CreateWindowEx(WS_EX_CONTROLPARENT, "DModemPage", "", - WS_CHILD | WS_CLIPCHILDREN, 0, 0, 10, 10, parent, + WS_CHILD, 0, 0, 10, 10, parent, NULL, app.inst, NULL); SetWindowLongPtr(w, GWLP_USERDATA, (LONG_PTR)fn); return w;