gpui: Improve window.prompt to support ESC with non-English cancel text on macOS (#29538)
Release Notes:
- N/A
----
The before version GPUI used `Cancel` for cancel text, if we use
non-English text (e.g.: "取消" in Chinese), then the press `Esc` to cancel
will not work.
So this PR to change it by use `PromptButton` to instead the `&str`,
then we can use `PromptButton::cancel("取消")` for the `Cancel` button.
Run `cargo run -p gpui --example window` to test.
---
Platform Test:
- [x] macOS
- [x] Windows
- [x] Linux (x11 and Wayland)
---------
Co-authored-by: Mikayla Maki <mikayla@zed.dev>
Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
This commit is contained in:
co-authored by
Mikayla Maki
Mikayla Maki
parent
1d5d3de85c
commit
047e7eacec
@@ -1,8 +1,8 @@
|
||||
use gpui::{
|
||||
App, AppContext as _, Context, Entity, EventEmitter, FocusHandle, Focusable, FontWeight,
|
||||
InteractiveElement, IntoElement, ParentElement, PromptHandle, PromptLevel, PromptResponse,
|
||||
Refineable, Render, RenderablePromptHandle, SharedString, Styled, TextStyleRefinement, Window,
|
||||
div,
|
||||
InteractiveElement, IntoElement, ParentElement, PromptButton, PromptHandle, PromptLevel,
|
||||
PromptResponse, Refineable, Render, RenderablePromptHandle, SharedString, Styled,
|
||||
TextStyleRefinement, Window, div,
|
||||
};
|
||||
use markdown::{Markdown, MarkdownElement, MarkdownStyle};
|
||||
use settings::{Settings, SettingsStore};
|
||||
@@ -35,7 +35,7 @@ fn zed_prompt_renderer(
|
||||
level: PromptLevel,
|
||||
message: &str,
|
||||
detail: Option<&str>,
|
||||
actions: &[&str],
|
||||
actions: &[PromptButton],
|
||||
handle: PromptHandle,
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
@@ -44,7 +44,7 @@ fn zed_prompt_renderer(
|
||||
|cx| ZedPromptRenderer {
|
||||
_level: level,
|
||||
message: message.to_string(),
|
||||
actions: actions.iter().map(ToString::to_string).collect(),
|
||||
actions: actions.iter().map(|a| a.label().to_string()).collect(),
|
||||
focus: cx.focus_handle(),
|
||||
active_action_id: 0,
|
||||
detail: detail
|
||||
|
||||
Reference in New Issue
Block a user