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

Adding ReadConsoleInput to the API. #237

Merged
merged 2 commits into from
Nov 28, 2024
Merged

Conversation

chhackett
Copy link
Contributor

Description

There are some new data types in Console/Internal.hsc to support the ReadConsoleInput API:
KEY_EVENT_RECORD
MOUSE_EVENT_RECORD
WINDOW_BUFFER_SIZE_RECORD
MENU_EVENT_RECORD
FOCUS_EVENT_RECORD
INPUT_RECORD

The exported function readConsoleInput is also added.

Motivation and Context

There are several apps that have used the ReadConsoleInput Win32 API method. This
leads to a bit of code duplication. Since these apps already use the Win32 library, it
just makes sense to consolidate that code into one place.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.
  • I have not added a new Haskell dependency.
  • I have included a changelog entry.
  • I have not modified the version of the package in Win32.cabal.

@chhackett
Copy link
Contributor Author

Looks like one of the CI tests is failing on several PRs. Here's the error:
ERROR: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Cannot find path 'C:\WORK\s\appveyor\AppData\Roaming\cabal\config' because it does not exist.
Environment Vars (like PATH) have changed. Close/reopen your shell to
see the changes (or in powershell/cmd.exe just type refreshenv).
The install of cabal was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\cabal\tools\chocolateyInstall.ps1'.
See log for details.

@Mistuke
Copy link
Contributor

Mistuke commented Nov 27, 2024

Yeah the 32-bit CI is broken, don't worry about that. Thanks for the PR!

FocusEvent `fmap` (#peek INPUT_RECORD, Event) buf
_ -> error $ "Unknown input event type " ++ show event

foreign import ccall unsafe "windows.h ReadConsoleInputW"
Copy link
Contributor

Choose a reason for hiding this comment

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

This should use the WINDOWS_CCONV macro instead of ccall but other than that looks good!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, took care of that.

@Mistuke
Copy link
Contributor

Mistuke commented Nov 28, 2024

Thanks!

@Mistuke Mistuke merged commit 427e76a into haskell:master Nov 28, 2024
1 check failed
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