h-m-m icon indicating copy to clipboard operation
h-m-m copied to clipboard

Compatibility with Windows

Open nadrad opened this issue 2 years ago • 5 comments

h-m-m doesn't work in Windows because of the following:

  • tput for getting the terminal dimensions and enabling the alternate screen
  • stty for disabling echo, ctrl+c, etc.
  • (anything else?)

I'm probably not going to investigate the solution and implement it myself. Is there anyone familiar with these topics in Windows, interested in contributing?

nadrad avatar Sep 18 '22 11:09 nadrad

The solution to the first problem can be found here: https://github.com/getopt-php/getopt-php/blob/3.1.0/src/Help.php#L298

With the second problem... "echo off" or "@echo off" disables echo. ctrl+c should work quietly. I don't know anything about alternate screen yet.

That such a program works in PowerShell. https://github.com/gabrielrcouto/php-terminal-gameboy-emulator/issues/36

If I have time, I'll try to test it.

TorgovetsSKotom avatar Jan 17 '24 16:01 TorgovetsSKotom

Here are the working functions that consistently output the width and height of the terminal in windows. Replacing all declarations of the variables $mm['terminal_width'] and $mm['terminal_height'] did not work smoothly.

function getScreenWidth()
    {
		$columns = defined('COLUMNS') ? (int)COLUMNS : (int)@getenv('COLUMNS');
		if (empty($columns)) {$columns = (int)exec('tput cols');}
        $screenWidth = !empty($columns) ? $columns: 90;
        return $screenWidth;
    }

function getScreenHeight()
    {
		$lines = defined('LINES') ? (int)LINES : (int)@getenv('LINES');
		if (empty($lines)) { $lines = (int)exec('tput lines');}
        $screenHeight = !empty($lines) ? $lines: 90;
        return $screenHeight;
    }

Also, the use of exec('echo off'); at the beginning of the script and exec('echo on'); exec('clear'); at the end did not have the expected effect. Maybe I'm calling them incorrectly.

As a result, the interface does not adjust to changing the size of the terminal and does not respond to actions. Only outputs input over the interface.

TorgovetsSKotom avatar Jan 18 '24 11:01 TorgovetsSKotom

Thanks, @TorgovetsSKotom, but if it's a fixed value for the time the program is run and can't be used to detect the current dimensions, we have to keep looking :) There must be something to report the current values!

nadrad avatar Jan 21 '24 15:01 nadrad

No, the COLUMNS and LINES variables contain exactly the current values. This has been verified.

TorgovetsSKotom avatar Jan 21 '24 16:01 TorgovetsSKotom

That's great. Submit a merge request if you'd like. Otherwise, I can do it myself in a couple of weeks because I'm very busy with an urgent project these days.

nadrad avatar Jan 29 '24 19:01 nadrad

This issue has been open for too long. It's probably a reasonable expectation from Windows users who like terminal applications to have WSL installed, and they can use that to run h-m-m. So, let's forget about making it compatible with Windows.

nadrad avatar May 23 '24 07:05 nadrad