TVision

 view release on metacpan or  search on metacpan

tvision.git/source/platform/gpminput.cpp  view on Meta::CPAN

        .eventMask = GPM_DOWN | GPM_UP | GPM_DRAG | GPM_MOVE,
        .defaultMask = 0, // Disable cursor drawing by the server.
        // Report keyboard modifiers except Shift, which terminal emulators
        // usually reserve for selecting text. Here GPM will do the same.
        .minMod = 0,
        .maxMod = (ushort) ~(1 << KG_SHIFT) };
    // Because we only instantiate GPM in the Linux console, unset the
    // TERM variable during Gpm_Open so that GPM won't assume it is being
    // ran under xterm (e.g. if TERM=xterm), and 'gpm_fd' won't be -2.
    char *term = newStr(getenv("TERM"));
    if (term) unsetenv("TERM");
    Gpm_Open(&conn, 0);
    if (term) setenv("TERM", term, 1);
    delete[] term;

    if (gpm_fd != -1)
        return new GpmInput(displayBuf);
    return nullptr;
}

inline GpmInput::GpmInput(DisplayBuffer &aDisplayBuf) noexcept :
    InputStrategy(gpm_fd),
    displayBuf(aDisplayBuf)

tvision.git/source/platform/unixclip.cpp  view on Meta::CPAN


static run_subprocess_t run_subprocess(const char * const argv[], const char * const env[], run_subprocess_mode mode)
{
    int fds[2];
    if (pipe(fds) == -1)
        return {};
    pid_t pid = fork();
    if (pid == 0)
    {
        for (auto *p = env; p && *p; p += 2)
            setenv(p[0], p[1], true);

        int nul     = open("/dev/null", O_RDWR);
        int new_in  = mode == run_subprocess_mode::read ? nul    : fds[0];
        int new_out = mode == run_subprocess_mode::read ? fds[1] : nul;

        if ( nul != -1
             && dup2(new_in, STDIN_FILENO) != -1
             && dup2(new_out, STDOUT_FILENO) != -1
             && dup2(nul, STDERR_FILENO) != -1
             && close(fds[0]) != -1



( run in 0.388 second using v1.01-cache-2.11-cpan-283623ac599 )