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

feat: Implement bell #2469

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

feat: Implement bell #2469

wants to merge 2 commits into from

Conversation

4513ECHO
Copy link

@4513ECHO 4513ECHO commented Apr 5, 2024

What kind of change does this PR introduce?

  • Feature

Implement bell sound on macOS and Windows. For users of other OS, g:neovide_bell_command can be used.
Close #1967

TODO

  • Implement visual bell
  • Should we implement neovide.bell rpc method for user?

Did this PR introduce a breaking change?

A breaking change includes anything that breaks backwards compatibility either at compile or run time.

  • No

@fredizzimo
Copy link
Member

Another option for the bell is to use a configurable external command like Alacritty:

That's probably the only easy way on X11/Wayland. On Windows and macOS it could still default to built-ins like you do here, but allow a command for more customization.

@4513ECHO
Copy link
Author

4513ECHO commented Apr 8, 2024

I've added g:neovide_bell_command option. I want to make its type Vec<String>, but I can't fix typing error...

@4513ECHO 4513ECHO force-pushed the feat/bell branch 2 times, most recently from eb4a0bc to 3b09d35 Compare April 19, 2024 15:15
@fredizzimo
Copy link
Member

I've added g:neovide_bell_command option. I want to make its type Vec<String>, but I can't fix typing error...

Sorry for not coming back to you earlier. Supporting vectors is indeed not supported by our settings system right now. But I think a single command is good enough. You can always call a shell script if you want a more complex command.

Copy link
Member

@fredizzimo fredizzimo left a comment

Choose a reason for hiding this comment

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

This needs rebasing on the latest master

}
RedrawEvent::VisualBell => {
tracy_zone!("EditorVisualBell");
// TODO: Implement visual bell
Copy link
Member

Choose a reason for hiding this comment

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

Do you need help implementing this?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I am not familiar with skia...

Copy link
Member

Choose a reason for hiding this comment

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

I think you can add draw_rect (https://rust-skia.github.io/doc/skia_safe/canvas/struct.Canvas.html#method.draw_rect) to renderer::draw_frame after everything else is rendered. Either black or white, with some alpha that animates in and out. Compare against the default background color, and select using this condition

neovide/src/editor/mod.rs

Lines 595 to 597 in 4096e4c

fn is_light_color(color: &Color4f) -> bool {
0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b > 0.5
}

The updating of the alpha value could be done in renderer::animate_frame

src/window/window_wrapper.rs Outdated Show resolved Hide resolved
#[cfg(target_os = "windows")]
MessageBeep(MB_OK);
}
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be enabled on all platforms. And used instead of the platform bells if defined.

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.

Is there any bell sound system?
2 participants