-
Notifications
You must be signed in to change notification settings - Fork 6
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
Pause/disable user input when displaying stats for countdown game #11
Comments
Thanks again for the help 😁. The solution you proposed in PR makes sense, but I would like to suppress the error, I'll look into it and try to come up with a different solution. If I don't make any progress, I will merge the PR (it's much better than the current state 😀). |
Yeah - it would be better for sure 👍 I did go over the API, forums, LLMs, for all 3 of these, and couldn't find an elegant way to resolve this 😅 Maybe you have better luck 😉 |
I was just about to type this. The only other way I thought of was to do something like this: local keys_to_disable =
{ "a", "A", "i", "I", "o", "O", "s", "S", "x", "d", "D", "c", "C", "p", "P", "u", "U", "J", "r", "R", ".", }
for _, key in pairs(keys_to_disable) do
vim.keymap.set("n", key, "<nop>", { buffer = 0 })
end But it's very hacky, there are a lot of edge cases that aren't covered. Also, when I tried using the solution you proposed in PR, I noticed that the error it was throwing was not the same as the ones that block your Neovim instance (I don't know what are they called), as I thought at first. So I think this solution is good enough until the better one emerges. PS: I will not merge your PR, because it uses the API function that is deprecated in nightly versions, and the "use instead" function already exists in versions 0.9.x |
Yeah that is a hell of a hack but it could do the trick - as long as the user can't enter insert mode 👍 Great that it got solved - thanks 🙏 |
I keep getting the Can you still merge the hack that disables all inserting commands? 🙏 |
fix: hacky solution that solves #11
Do you mind testing it now, @gerazov? I will leave this issue open for now. |
Works great - thanks 🤟 |
It would be nice if the user input is paused for a bit, or even better completely disabled, after the game finishes and the stats are displayed.
Otherwise depending on what word your typing you can edit over the displayed text.
I tried the following:
Pause Neovim using
vim.wait(500)
. This doesn't really work, if it does pause Vim the keypresses are still accumulated sent after the wait.Turn off modifiable via
api.nvim_buf_set_option(0, "modifiable", false)
, this I think is a good choice but can lead to a bunch ofE21: Cannot make changes, 'modifiable' is off
. I couldn't find if this can be suppressed at a buffer level..Prompt user for input, e.g. "Press Enter to continue ..." but
vim.fn.input()
would open a new prompt. Maybe a custom function could be implemented 🤔I'm pushing the 2. PR - seems the cleanest.
Ignore if it doesn't make sense 😅 :
The text was updated successfully, but these errors were encountered: