• Is a virtual channel right approach?

    From Alex (Oleksandr) Malyushytskyy@21:1/5 to All on Fri Oct 8 18:17:08 2021
    I would like Tcl_MainEx to be waiting not only for user to type into the terminal,
    but also for a script coming from non-tcl source in a different thread (not managed by tcl).
    I can execute any custom C code , but prefer keep Tcl_MainEx untouched.

    Documentation states :
    "A virtual channel is a channel composed of other channels or of non-channel constructs. reflected channels, and stacked channels are two examples."

    Questions:
    1. Is it a right approach?
    2. If yes, could anybody point to any examples of virtual channel , preferably in C? ( I fail to find anything)

    Best regards,
    Alex

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Werner@21:1/5 to All on Fri Oct 8 21:40:02 2021
    Maybe the pure Tcl readline from the wiki is a starting point, see

    https://wiki.tcl.tk/20215 and https://wiki.tcl.tk/16139 and https://wiki.tcl-lang.org/page/Pure%2Dtcl+readline2

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alex (Oleksandr) Malyushytskyy@21:1/5 to Christian Werner on Mon Oct 11 16:43:23 2021
    On Friday, October 8, 2021 at 9:40:05 PM UTC-7, Christian Werner wrote:
    Maybe the pure Tcl readline from the wiki is a starting point, see

    https://wiki.tcl.tk/20215 and https://wiki.tcl.tk/16139 and https://wiki.tcl-lang.org/page/Pure%2Dtcl+readline2

    What I ended up doing - >
    1- Registered 2 commands I needed anyway

    Tcl_CreateCommand(interp, "show_gui", StartTclEventLoop,
    NULL, NULL);
    Tcl_CreateCommand(interp, "hide_gui", EndTclEventLoop,
    NULL, NULL);

    2. Such commands enter /exit event loop :

    static Tcl_CmdProc StartTclEventLoop;
    static Tcl_CmdProc EndTclEventLoop;


    static void MainTclLoop(void);
    static void MainTclLoop(void)
    {
    while (!exitMainLoop) {
    Tcl_DoOneEvent(0);
    }
    fprintf(stdout, "Exit MainLoop\n");
    fflush(stdout);
    }

    static int StartTclEventLoop(
    ClientData dummy, /* Not used. */
    Tcl_Interp* interp,/* Current interpreter. */
    int argc, /* Number of arguments. */
    const char** argv) /* Argument strings. */
    {
    exitMainLoop = 0;
    Tcl_SetMainLoop(MainTclLoop);
    return TCL_OK;
    }

    static int EndTclEventLoop(
    ClientData dummy, /* Not used. */
    Tcl_Interp* interp,/* Current interpreter. */
    int argc, /* Number of arguments. */
    const char** argv) /* Argument strings. */
    {
    exitMainLoop = 1;
    return TCL_OK;
    }
    }

    3. Everything works with original tcl_mainexcept command prompt is not printed for sometimes after command is executed through the sent message from other thread, trying investigate this right now

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Conor Williams@21:1/5 to All on Mon Oct 11 19:04:28 2021
    did u no: if you have two or more wish shells running then this works:

    send "wish #2" whoami

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Conor Williams@21:1/5 to All on Mon Oct 11 20:46:57 2021
    yes it does my friend yes it does you are incorrect..
    there is a flag in the makefile (compiler directives file) which needs to be turned on
    once it is compiled with this flag on, then it will work...
    i bet you a cup of tea that whomsoever compiled your windoze and OSMac wish
    did not set the flag, to confuse you, to try and trample you to the ground... .... it is an independent wish thing...
    not an os specific thing...
    /c:202112100345:34
    ps:

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Conor Williams on Tue Oct 12 03:28:16 2021
    Conor Williams <conor.williams@gmail.com> wrote:
    did u no: if you have two or more wish shells running then this works:

    send "wish #2" whoami

    Only on X11. Does not work on windows or macos.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Conor Williams on Tue Oct 12 13:51:03 2021
    Conor Williams <conor.williams@gmail.com> wrote:
    yes it does my friend yes it does you are incorrect..
    there is a flag in the makefile (compiler directives file) which
    needs to be turned on
    once it is compiled with this flag on, then it will work...
    i bet you a cup of tea that whomsoever compiled your windoze and
    OSMac wish did not set the flag, to confuse you, to try and trample
    you to the ground...
    .... it is an independent wish thing...
    not an os specific thing...

    Be that as it may, the fact that all the standard builds have it
    disabled means it, effectively, does not work on windows/macos for most
    people.

    Note the docs specifically mention it being disabled on windows:

    man n send:

    ... Under Windows, send is currently disabled. Most of the
    functionality is provided by the dde command instead. ...

    Few are going to find, and recompile, wish under windows or macos to
    get the 'send' functionality turned back on.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)