Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal overflow and menu size #255

Open
Renji-FR opened this issue Feb 9, 2022 · 2 comments
Open

Terminal overflow and menu size #255

Renji-FR opened this issue Feb 9, 2022 · 2 comments

Comments

@Renji-FR
Copy link

Renji-FR commented Feb 9, 2022

I encountered an issue when my menu is bigger than my terminal:

phpclishell.mp4

Is it possible to print the console line number only for the menu?

I know I use stty binary to retrieve my terminal size:

<?php
	namespace Core\Console;

    class Tools
    {
		/**
		 * @return false|array
		 */
		protected static function _getSize()
		{
			$sttyCommand = 'stty size';
			exec($sttyCommand, $outputs, $status);

			if($status === 0 && count($outputs) >= 1)
			{
				if(preg_match('#^(?<rows>[0-9]+) (?<columns>[0-9]+)$#i', $outputs[0], $matches)) {
					return $matches;
				}
			}

			return false;
		}

		/**
		 * @return false|int
		 */
		public static function getRows()
		{
			$consoleSize = static::_getSize();
			return ($consoleSize !== false) ? ($consoleSize['rows']) : (false);
		}

		/**
		 * @return false|int
		 */
		public static function getColumns()
		{
			$consoleSize = static::_getSize();
			return ($consoleSize !== false) ? ($consoleSize['columns']) : (false);
		}
    }

Thank you

@programster
Copy link

programster commented Oct 26, 2023

I don't know how one could resolve this problem, but when the menu is too long for the terminal window (too many options), one has to manuallly scroll up to see the off-screen items. One can scroll up to see this, but every time I press the up/down arrows, the terminal goes to the bottom. I am guessing this is because the default terminal behaviour is to scroll down when something happens (am using Terminstor).

Also, if using this within byobu then the thing is completely unusable (at least for me) because in byobu the scrollback messes up and I have to press f7 and then scroll back using arrow keys, which then prevents the menu from working as normal.

It would be great if there was a way to have the ability to tell the menu to take up as much screen as possible, and when there are too many items, it creates an internal scrollbar or something, or just internally scrolls. If size detection is not possible, then if I could set size of the scroll window (e.g. 5 items) that would "get me by".

@AydinHassan
Copy link
Member

hi @programster we're happy to accept any enhancements you might require, feel free to coordinate with us, but it's not a priority for us at the minute, hope you understand!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants