Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121287 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 63571 invoked from network); 12 Oct 2023 23:49:48 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Oct 2023 23:49:48 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CCD0B180212 for ; Thu, 12 Oct 2023 16:49:47 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URI_TRY_3LD autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS43037 77.75.78.0/23 X-Spam-Virus: No X-Envelope-From: Received: from mxe.seznam.cz (mxe.seznam.cz [77.75.78.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 12 Oct 2023 16:49:47 -0700 (PDT) Received: from email.seznam.cz by smtpc-mxe-766459644b-cv6gc (smtpc-mxe-766459644b-cv6gc [2a02:598:64:8a00::1000:ad0]) id 5b70a0ef476044535b4d991b; Fri, 13 Oct 2023 01:49:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seznam.cz; s=szn20221014; t=1697154586; bh=x0CGMlbr5R2voP2cZ+NE3w6/QcLByPG1iwdJIStr+eQ=; h=Received:From:To:Subject:Date:Message-Id:Mime-Version:X-Mailer: Content-Type:Content-Transfer-Encoding; b=Qi6nI9YCRpQe15BxSu9GHRAQB4CQlfY5dLq4a/HuBbcG7lZ8g2dBDLnYa0EmoVbkD cPmoC8rbPUO/QZgcn/3TaO/bHtgfQJbbAYVxeTTBqEG3J29iDd7t+NjURs65xt5qGO weoNi/94uXVS+94lKlbjEwI7Myd0vqnZq8jCZZ6SJYGq6ItHkJ4KJ3nb4qo75SifBM k12Ftywar/9+iBRcvr2NaNla2zYFEhc+gCP99O1NGXFpRvUL4i1KIEMpLe6VBhFuCr wGTtuL2mVCbfFFiJntyKcdWVlKKiiTeRXc7fLMFiy4+bfkbCjVdOyD7lk/QlvDQY/p PLbGAED1Gko4Q== Received: from unknown ([2a02:8308:301:6200:fd2c:3e09:a2da:a74f]) by email.seznam.cz (szn-ebox-5.0.162) with HTTP; Fri, 13 Oct 2023 01:49:43 +0200 (CEST) To: Date: Fri, 13 Oct 2023 01:49:43 +0200 (CEST) Message-ID: <2CM.F7Wx.3pPEkL6u{51.1bA8ON@seznam.cz> Mime-Version: 1.0 (szn-mime-2.1.33) X-Mailer: szn-ebox-5.0.162 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Proposal: Add support for interactive console application on Windows From: Plaki@seznam.cz (=?utf-8?q?Patrik_Paster=C4=8D=C3=ADk?=) Hi internals I would like to propose extending PHP with support functions to enable interactive console work on Windows system. I mean the ability to control a PHP script running from the console using arrow keys, or function keys like "F1", etc. For example, when a list is displayed to the user and the user can select the desired item using the arrow keys and confirm it with the Enter key. An analysis of other solutions, a detailed description of the problems and a proof of concept is in the proposal in the issue here: https://github.com/php/php-src/issues/12227 The short version is that on Linux you can use "fread" function to read these keys (arrows, etc.) if you use an external `stty` command to set the console input processing modes (for example the laravel/prompts package use "stty -icanon -isig -echo"). However, there is no equivalent of the `stty` command for Windows (without the need to use the FFI extension, or the need to call an external program to read pressed keys, see issue for more details), so I propose to extend PHP with support functions for setting the console input mode (ENABLE_ECHO_INPUT, ENABLE_LINE_INPUT, ENABLE_PROCESSED_INPUT, ENABLE_VIRTUAL_TERMINAL_INPUT) by "SetConsoleMode" function, see: https://learn.microsoft.com/en-us/windows/console/setconsolemode I would like to know your opinion on this proposal. Or if you have any questions. And then as a next step I would like to create an RFC proposing these functions for Windows support. And possibly I could help with implementation (see my proof of concept in the issue). Alternatively, there is the question of whether to generalize this and directly design a multiplatform API that would allow to read these keys without the need to use any external programs even on Linux (where "stty" is used). But I don't know which has a better chance of implementation, a simple extension for Windows or a more complex multiplatform solution. Best regards Patrik Paster=C4=8D=C3=ADk