nadrad / h-m-m

Hackers Mind Map
GNU General Public License v3.0
1.89k stars 53 forks source link

Compatibility with Windows #29

Closed nadrad closed 4 months ago

nadrad commented 2 years ago

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

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?

TorgovetsSKotom commented 9 months ago

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 commented 8 months ago

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.

nadrad commented 8 months ago

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!

TorgovetsSKotom commented 8 months ago

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

nadrad commented 8 months ago

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 commented 4 months ago

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.