Skip to content

Windows support#87

Merged
japhb merged 2 commits intoab5tract:masterfrom
patrickbkr:no-tput
Mar 24, 2025
Merged

Windows support#87
japhb merged 2 commits intoab5tract:masterfrom
patrickbkr:no-tput

Conversation

@patrickbkr
Copy link
Copy Markdown
Collaborator

Do so by relying on Terminal-API for retrieving the Window size and using VT codes directly for output instead of using on a tput redirection.

Part of a set of PRs in Terminal-LineEditor, Terminal-Print and Terminal-Widgets.

Don't merge yet, Terminal-API isn't released yet!

This gets rid of using the tput program to retrieve the ANSI escape codes.
One dependency on tput still remains: Determining the current number of
rows and cols of the terminal window. That's to be removed in a separate
commit.
@patrickbkr
Copy link
Copy Markdown
Collaborator Author

@patrickbkr
Copy link
Copy Markdown
Collaborator Author

I'd like to get feedback on the PRs first and when things look good release Terminal-API. This will allow me to still make changes to T-API without burning version numbers.

Terminal::MakeRaw::makeraw($fd, |$mode);
$saved-term-config = Terminal::API::get-config($fd);
my $when = $drop-old-unread ?? Terminal::API::FLUSH !! Terminal::API::DRAIN;
Terminal::API::make-raw($fd, :$when);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:when is a somewhat odd name for this parameter. Maybe :how or :method or :cleanup or so?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was inspired by the man page (highlight mine):

optional_actions specifies **when** the changes take effect:
TCSANOW
    the change occurs immediately. 
TCSADRAIN
    the change occurs after all output written to fd has been transmitted. This function should be used when changing parameters that affect output. 
TCSAFLUSH
    the change occurs after all output written to the object referred by fd has been transmitted, and all input that has been received but not read will be discarded before the change is made. 

Do you still think the name is suboptimal? (I don't have strong emotions, so if you think something else is better, I'll gladly change it.)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. In that case, I think your choice is correct (to match the underlying documentation, since this is a relatively thin layer in the Unix world at least).

Whether the original API had good naming sense is a different question -- but not your problem to solve. ;-)

Copy link
Copy Markdown
Collaborator

@japhb japhb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally! Kind of nice seeing tput go away. 😁

@japhb japhb merged commit efbb169 into ab5tract:master Mar 24, 2025
@patrickbkr
Copy link
Copy Markdown
Collaborator Author

@japhb This fails on MacOS. Reason: Terminal-API is native-calling ioctl. That's a vararg function. NativeCall doesn't support those yet. Calling them as normal functions happens to work on x64 (often / always?). But on ARM, it does not and trashes the arguments. As far as I see there is no easy way out. To fix this we'll have to implement vararg support in MoarVM and NativeCall. This will take some time. Thus I propose we revert the merge to keep Terminal-Print in a working state. 😞

@japhb
Copy link
Copy Markdown
Collaborator

japhb commented Mar 25, 2025

Well shoot, that bites. All right, reverting.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants