chore: Update to use Rust edition 2024. (#1669)
This commit is contained in:
parent
af51057d52
commit
f2cbc16655
23 changed files with 133 additions and 128 deletions
|
|
@ -17,6 +17,10 @@ members = [
|
|||
]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.package]
|
||||
publish = false
|
||||
edition = "2024"
|
||||
|
||||
[workspace.dependencies]
|
||||
gpui-component = { path = "crates/ui", version = "0.4.1" }
|
||||
gpui-component-macros = { path = "crates/macros", version = "0.4.1" }
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
[package]
|
||||
name = "gpui-component-assets"
|
||||
description = "Default bundled assets for GPUI Component."
|
||||
edition = "2021"
|
||||
keywords = ["desktop", "gpui", "shadcn", "ui", "uikit"]
|
||||
license = "Apache-2.0"
|
||||
documentation = "https://docs.rs/gpui-component"
|
||||
homepage = "https://longbridge.github.io/gpui-component"
|
||||
repository = "https://github.com/longbridge/gpui-component"
|
||||
publish = true
|
||||
readme = "README.md"
|
||||
edition.workspace = true
|
||||
publish = true
|
||||
version = "0.4.1"
|
||||
|
||||
[lib]
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
[package]
|
||||
edition = "2021"
|
||||
name = "gpui-component-macros"
|
||||
description = "Macros for GPUI Component."
|
||||
version = "0.4.1"
|
||||
publish = true
|
||||
license = "Apache-2.0"
|
||||
publish = true
|
||||
edition.workspace = true
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
[package]
|
||||
name = "reqwest_client"
|
||||
version = "0.4.1"
|
||||
publish = false
|
||||
license = "Apache-2.0"
|
||||
edition = "2024"
|
||||
publish = false
|
||||
edition.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
[package]
|
||||
edition = "2024"
|
||||
name = "gpui-component-story"
|
||||
publish = false
|
||||
version = "0.4.1"
|
||||
publish = false
|
||||
edition.workspace = true
|
||||
|
||||
[features]
|
||||
inspector = ["gpui-component/inspector"]
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
[package]
|
||||
description = "UI components for building fantastic desktop application by using GPUI."
|
||||
edition = "2021"
|
||||
keywords = ["desktop", "gpui", "shadcn", "ui", "uikit"]
|
||||
license = "Apache-2.0"
|
||||
name = "gpui-component"
|
||||
documentation = "https://docs.rs/gpui-component"
|
||||
homepage = "https://longbridge.github.io/gpui-component"
|
||||
repository = "https://github.com/longbridge/gpui-component"
|
||||
publish = true
|
||||
readme = "../../README.md"
|
||||
version = "0.4.1"
|
||||
publish = true
|
||||
edition.workspace = true
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
|
|
|||
|
|
@ -1,20 +1,21 @@
|
|||
use gpui::{
|
||||
anchored, canvas, deferred, div, prelude::FluentBuilder as _, px, relative, App, AppContext,
|
||||
Bounds, ClickEvent, Context, Corner, ElementId, Entity, EventEmitter, FocusHandle, Focusable,
|
||||
Hsla, InteractiveElement as _, IntoElement, KeyBinding, MouseButton, ParentElement, Pixels,
|
||||
Point, Render, RenderOnce, SharedString, StatefulInteractiveElement as _, StyleRefinement,
|
||||
Styled, Subscription, Window,
|
||||
App, AppContext, Bounds, ClickEvent, Context, Corner, Div, ElementId, Entity, EventEmitter,
|
||||
FocusHandle, Focusable, Hsla, InteractiveElement as _, IntoElement, KeyBinding, MouseButton,
|
||||
ParentElement, Pixels, Point, Render, RenderOnce, SharedString, Stateful,
|
||||
StatefulInteractiveElement as _, StyleRefinement, Styled, Subscription, Window, anchored,
|
||||
canvas, deferred, div, prelude::FluentBuilder as _, px, relative,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
ActiveTheme as _, Colorize as _, FocusableExt as _, Icon, Selectable as _, Sizable, Size,
|
||||
StyleSized, StyledExt,
|
||||
actions::{Cancel, Confirm},
|
||||
button::{Button, ButtonVariants},
|
||||
divider::Divider,
|
||||
h_flex,
|
||||
input::{Input, InputEvent, InputState},
|
||||
tooltip::Tooltip,
|
||||
v_flex, ActiveTheme as _, Colorize as _, FocusableExt as _, Icon, Selectable as _, Sizable,
|
||||
Size, StyleSized, StyledExt,
|
||||
v_flex,
|
||||
};
|
||||
|
||||
const CONTEXT: &'static str = "ColorPicker";
|
||||
|
|
@ -250,7 +251,7 @@ impl ColorPicker {
|
|||
clickable: bool,
|
||||
window: &mut Window,
|
||||
_: &mut App,
|
||||
) -> impl IntoElement {
|
||||
) -> Stateful<Div> {
|
||||
let state = self.state.clone();
|
||||
div()
|
||||
.id(SharedString::from(format!("color-{}", color.to_hex())))
|
||||
|
|
|
|||
|
|
@ -1,20 +1,21 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use gpui::{
|
||||
div, prelude::FluentBuilder, px, relative, rems, App, AppContext, Context, Corner,
|
||||
DismissEvent, Div, DragMoveEvent, Empty, Entity, EventEmitter, FocusHandle, Focusable,
|
||||
InteractiveElement as _, IntoElement, ParentElement, Pixels, Render, ScrollHandle,
|
||||
SharedString, StatefulInteractiveElement, StyleRefinement, Styled, WeakEntity, Window,
|
||||
App, AppContext, Context, Corner, DismissEvent, Div, DragMoveEvent, Empty, Entity,
|
||||
EventEmitter, FocusHandle, Focusable, InteractiveElement as _, IntoElement, ParentElement,
|
||||
Pixels, Render, ScrollHandle, SharedString, StatefulInteractiveElement, StyleRefinement,
|
||||
Styled, WeakEntity, Window, div, prelude::FluentBuilder, px, relative, rems,
|
||||
};
|
||||
use rust_i18n::t;
|
||||
|
||||
use crate::{
|
||||
ActiveTheme, AxisExt, IconName, Placement, Selectable, Sizable,
|
||||
button::{Button, ButtonVariants as _},
|
||||
dock::PanelInfo,
|
||||
h_flex,
|
||||
menu::{DropdownMenu, PopupMenu},
|
||||
tab::{Tab, TabBar},
|
||||
v_flex, ActiveTheme, AxisExt, IconName, Placement, Selectable, Sizable,
|
||||
v_flex,
|
||||
};
|
||||
|
||||
use super::{
|
||||
|
|
@ -508,7 +509,7 @@ impl TabPanel {
|
|||
placement: DockPlacement,
|
||||
_: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Option<impl IntoElement> {
|
||||
) -> Option<Button> {
|
||||
if self.zoomed {
|
||||
return None;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,21 +5,21 @@ use std::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
h_flex,
|
||||
ActiveTheme, Icon, IconName, h_flex,
|
||||
history::{History, HistoryItem},
|
||||
scroll::{Scrollbar, ScrollbarShow, ScrollbarState},
|
||||
v_flex, ActiveTheme, Icon, IconName,
|
||||
v_flex,
|
||||
};
|
||||
|
||||
use super::{
|
||||
DockArea, Panel, PanelEvent, PanelInfo, PanelState, PanelView, StackPanel, TabPanel, TileMeta,
|
||||
};
|
||||
use gpui::{
|
||||
actions, canvas, div, prelude::FluentBuilder, px, size, AnyElement, App, AppContext, Bounds,
|
||||
Context, DismissEvent, DragMoveEvent, Empty, EntityId, EventEmitter, FocusHandle, Focusable,
|
||||
InteractiveElement, IntoElement, MouseButton, MouseDownEvent, MouseUpEvent, ParentElement,
|
||||
Pixels, Point, Render, ScrollHandle, Size, StatefulInteractiveElement, Styled, WeakEntity,
|
||||
Window,
|
||||
AnyElement, App, AppContext, Bounds, Context, DismissEvent, Div, DragMoveEvent, Empty,
|
||||
EntityId, EventEmitter, FocusHandle, Focusable, InteractiveElement, IntoElement, MouseButton,
|
||||
MouseDownEvent, MouseUpEvent, ParentElement, Pixels, Point, Render, ScrollHandle, Size,
|
||||
StatefulInteractiveElement, Styled, WeakEntity, Window, actions, canvas, div,
|
||||
prelude::FluentBuilder, px, size,
|
||||
};
|
||||
|
||||
actions!(tiles, [Undo, Redo]);
|
||||
|
|
@ -1030,7 +1030,7 @@ impl Tiles {
|
|||
item: &TileItem,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> impl IntoElement {
|
||||
) -> Div {
|
||||
let entity_id = cx.entity_id();
|
||||
let item_id = item.id;
|
||||
let panel_view = item.panel.view();
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ pub(crate) use diagnostic_popover::*;
|
|||
pub(crate) use hover_popover::*;
|
||||
|
||||
use gpui::{
|
||||
div, px, rems, App, Div, ElementId, Entity, InteractiveElement as _, IntoElement, SharedString,
|
||||
Stateful, StyleRefinement, Styled as _, Window,
|
||||
App, Div, ElementId, Entity, InteractiveElement as _, IntoElement, SharedString, Stateful,
|
||||
StyleRefinement, Styled as _, Window, div, px, rems,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
text::{TextView, TextViewStyle},
|
||||
ActiveTheme, StyledExt as _,
|
||||
text::{TextView, TextViewStyle},
|
||||
};
|
||||
|
||||
pub(crate) enum ContextMenu {
|
||||
|
|
@ -49,7 +49,7 @@ pub(super) fn render_markdown(
|
|||
markdown: impl Into<SharedString>,
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> impl IntoElement {
|
||||
) -> TextView {
|
||||
TextView::markdown(id, markdown, window, cx)
|
||||
.style(
|
||||
TextViewStyle::default()
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ use crate::actions::{Cancel, Confirm, SelectDown, SelectUp};
|
|||
use crate::actions::{SelectLeft, SelectRight};
|
||||
use crate::menu::menu_item::MenuItemElement;
|
||||
use crate::scroll::{Scrollbar, ScrollbarState};
|
||||
use crate::{h_flex, v_flex, ActiveTheme, Icon, IconName, Sizable as _};
|
||||
use crate::{kbd::Kbd, Side, Size, StyledExt};
|
||||
use crate::{ActiveTheme, Icon, IconName, Sizable as _, h_flex, v_flex};
|
||||
use crate::{Side, Size, StyledExt, kbd::Kbd};
|
||||
use gpui::{
|
||||
anchored, canvas, div, prelude::FluentBuilder, px, rems, Action, AnyElement, App, AppContext,
|
||||
Bounds, Context, Corner, DismissEvent, Edges, Entity, EventEmitter, FocusHandle, Focusable,
|
||||
InteractiveElement, IntoElement, KeyBinding, ParentElement, Pixels, Render, ScrollHandle,
|
||||
SharedString, StatefulInteractiveElement, Styled, WeakEntity, Window,
|
||||
Action, AnyElement, App, AppContext, Bounds, Context, Corner, DismissEvent, Edges, Entity,
|
||||
EventEmitter, FocusHandle, Focusable, InteractiveElement, IntoElement, KeyBinding,
|
||||
ParentElement, Pixels, Render, ScrollHandle, SharedString, StatefulInteractiveElement, Styled,
|
||||
WeakEntity, Window, anchored, canvas, div, prelude::FluentBuilder, px, rems,
|
||||
};
|
||||
use gpui::{ClickEvent, Half, MouseDownEvent, OwnedMenuItem, Subscription};
|
||||
use std::rc::Rc;
|
||||
|
|
@ -944,7 +944,7 @@ impl PopupMenu {
|
|||
action: Option<Box<dyn Action>>,
|
||||
window: &mut Window,
|
||||
_: &mut Context<Self>,
|
||||
) -> Option<impl IntoElement> {
|
||||
) -> Option<Kbd> {
|
||||
let action = action?;
|
||||
|
||||
match self
|
||||
|
|
@ -1013,7 +1013,7 @@ impl PopupMenu {
|
|||
state: ItemState,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> impl IntoElement {
|
||||
) -> MenuItemElement {
|
||||
let has_icon = self.has_icon;
|
||||
let selected = self.selected_index == Some(ix);
|
||||
const EDGE_PADDING: Pixels = px(4.);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
use crate::{
|
||||
ActiveTheme, Placement,
|
||||
dialog::Dialog,
|
||||
input::InputState,
|
||||
notification::{Notification, NotificationList},
|
||||
sheet::Sheet,
|
||||
window_border, ActiveTheme, Placement,
|
||||
window_border,
|
||||
};
|
||||
use gpui::{
|
||||
actions, canvas, div, prelude::FluentBuilder as _, AnyView, App, AppContext, Context,
|
||||
DefiniteLength, Entity, FocusHandle, InteractiveElement, IntoElement, KeyBinding,
|
||||
ParentElement as _, Render, Styled, Window,
|
||||
AnyView, App, AppContext, Context, DefiniteLength, Entity, FocusHandle, InteractiveElement,
|
||||
IntoElement, KeyBinding, ParentElement as _, Render, Styled, Window, actions, canvas, div,
|
||||
prelude::FluentBuilder as _,
|
||||
};
|
||||
use std::{any::TypeId, rc::Rc};
|
||||
|
||||
|
|
@ -278,7 +279,7 @@ impl Root {
|
|||
pub fn render_notification_layer(
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> Option<impl IntoElement> {
|
||||
) -> Option<impl IntoElement + use<>> {
|
||||
let root = window.root::<Root>()??;
|
||||
|
||||
let active_sheet_placement = root.read(cx).active_sheet.clone().map(|d| d.placement);
|
||||
|
|
@ -301,7 +302,10 @@ impl Root {
|
|||
}
|
||||
|
||||
/// Render the Sheet layer.
|
||||
pub fn render_sheet_layer(window: &mut Window, cx: &mut App) -> Option<impl IntoElement> {
|
||||
pub fn render_sheet_layer(
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> Option<impl IntoElement + use<>> {
|
||||
let root = window.root::<Root>()??;
|
||||
|
||||
if let Some(active_sheet) = root.read(cx).active_sheet.clone() {
|
||||
|
|
@ -328,7 +332,10 @@ impl Root {
|
|||
}
|
||||
|
||||
/// Render the Dialog layer.
|
||||
pub fn render_dialog_layer(window: &mut Window, cx: &mut App) -> Option<impl IntoElement> {
|
||||
pub fn render_dialog_layer(
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> Option<impl IntoElement + use<>> {
|
||||
let root = window.root::<Root>()??;
|
||||
|
||||
let active_dialogs = root.read(cx).active_dialogs.clone();
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
use gpui::{
|
||||
div, prelude::FluentBuilder as _, AnyElement, App, Axis, InteractiveElement as _, IntoElement,
|
||||
ParentElement, SharedString, Styled, Window,
|
||||
AnyElement, App, Axis, Div, InteractiveElement as _, IntoElement, ParentElement, SharedString,
|
||||
Stateful, Styled, Window, div, prelude::FluentBuilder as _,
|
||||
};
|
||||
use std::{any::TypeId, ops::Deref, rc::Rc};
|
||||
|
||||
use crate::{
|
||||
ActiveTheme as _, AxisExt, StyledExt as _,
|
||||
label::Label,
|
||||
setting::{
|
||||
fields::{BoolField, DropdownField, NumberField, SettingFieldRender, StringField},
|
||||
AnySettingField, ElementField, RenderOptions,
|
||||
fields::{BoolField, DropdownField, NumberField, SettingFieldRender, StringField},
|
||||
},
|
||||
text::Text,
|
||||
v_flex, ActiveTheme as _, AxisExt, StyledExt as _,
|
||||
v_flex,
|
||||
};
|
||||
|
||||
/// Setting item.
|
||||
|
|
@ -153,7 +154,7 @@ impl SettingItem {
|
|||
options: &RenderOptions,
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> impl IntoElement {
|
||||
) -> Stateful<Div> {
|
||||
div()
|
||||
.id(SharedString::from(format!("item-{}", ix)))
|
||||
.w_full()
|
||||
|
|
|
|||
|
|
@ -1,18 +1,19 @@
|
|||
use std::{ops::Range, rc::Rc, time::Duration};
|
||||
|
||||
use crate::{
|
||||
ActiveTheme, Icon, IconName, StyleSized as _, StyledExt, VirtualListScrollHandle,
|
||||
actions::{Cancel, SelectDown, SelectUp},
|
||||
h_flex,
|
||||
menu::{ContextMenuExt, PopupMenu},
|
||||
scroll::{ScrollableMask, Scrollbar, ScrollbarState},
|
||||
v_flex, ActiveTheme, Icon, IconName, StyleSized as _, StyledExt, VirtualListScrollHandle,
|
||||
v_flex,
|
||||
};
|
||||
use gpui::{
|
||||
canvas, div, prelude::FluentBuilder, px, uniform_list, AppContext, Axis, Bounds, ClickEvent,
|
||||
Context, Div, DragMoveEvent, EventEmitter, FocusHandle, Focusable, InteractiveElement,
|
||||
IntoElement, ListSizingBehavior, MouseButton, MouseDownEvent, ParentElement, Pixels, Point,
|
||||
Render, ScrollStrategy, SharedString, StatefulInteractiveElement as _, Styled, Task,
|
||||
UniformListScrollHandle, Window,
|
||||
AppContext, Axis, Bounds, ClickEvent, Context, Div, DragMoveEvent, EventEmitter, FocusHandle,
|
||||
Focusable, InteractiveElement, IntoElement, ListSizingBehavior, MouseButton, MouseDownEvent,
|
||||
ParentElement, Pixels, Point, Render, ScrollStrategy, SharedString, Stateful,
|
||||
StatefulInteractiveElement as _, Styled, Task, UniformListScrollHandle, Window, canvas, div,
|
||||
prelude::FluentBuilder, px, uniform_list,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
|
@ -791,12 +792,7 @@ where
|
|||
/// The children must be one by one items.
|
||||
/// Because the horizontal scroll handle will use the child_item_bounds to
|
||||
/// calculate the item position for itself's `scroll_to_item` method.
|
||||
fn render_th(
|
||||
&self,
|
||||
col_ix: usize,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> impl IntoElement {
|
||||
fn render_th(&self, col_ix: usize, window: &mut Window, cx: &mut Context<Self>) -> Div {
|
||||
let entity_id = cx.entity_id();
|
||||
let col_group = self.col_groups.get(col_ix).expect("BUG: invalid col index");
|
||||
|
||||
|
|
@ -970,7 +966,7 @@ where
|
|||
is_filled: bool,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> impl IntoElement {
|
||||
) -> Stateful<Div> {
|
||||
let horizontal_scroll_handle = self.horizontal_scroll_handle.clone();
|
||||
let is_stripe_row = self.options.stripe && row_ix % 2 != 0;
|
||||
let is_selected = self.selected_row == Some(row_ix);
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ use std::collections::HashMap;
|
|||
use std::ops::Range;
|
||||
use std::rc::Rc;
|
||||
|
||||
use gpui::{px, relative, DefiniteLength, SharedString};
|
||||
use gpui::{DefiniteLength, SharedString, px, relative};
|
||||
use html5ever::tendril::TendrilSink;
|
||||
use html5ever::{local_name, parse_document, LocalName, ParseOpts};
|
||||
use html5ever::{LocalName, ParseOpts, local_name, parse_document};
|
||||
use markup5ever_rcdom::{Node, NodeData, RcDom};
|
||||
|
||||
use crate::text::node::{
|
||||
|
|
@ -252,7 +252,7 @@ fn parse_paragraph(
|
|||
}
|
||||
|
||||
match &node.data {
|
||||
NodeData::Text { ref contents } => {
|
||||
NodeData::Text { contents } => {
|
||||
let part = &contents.borrow();
|
||||
text.push_str(&part);
|
||||
paragraph.push_str(&text);
|
||||
|
|
|
|||
|
|
@ -6,9 +6,8 @@
|
|||
use std::{cell::RefCell, io, rc::Rc, str};
|
||||
|
||||
use html5ever::{
|
||||
parse_document,
|
||||
tendril::{fmt::UTF8, Tendril, TendrilSink},
|
||||
Attribute, ParseOpts, QualName,
|
||||
Attribute, ParseOpts, QualName, parse_document,
|
||||
tendril::{Tendril, TendrilSink, fmt::UTF8},
|
||||
};
|
||||
use markup5ever_rcdom::{Node, NodeData, RcDom};
|
||||
|
||||
|
|
@ -697,7 +696,7 @@ fn is_block_element_name(name: &str) -> bool {
|
|||
|
||||
fn is_block_element(node: &Node) -> bool {
|
||||
match &node.data {
|
||||
NodeData::Element { ref name, .. } => is_block_element_name(name.local.as_ref()),
|
||||
NodeData::Element { name, .. } => is_block_element_name(name.local.as_ref()),
|
||||
NodeData::Document => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -877,19 +876,24 @@ mod tests {
|
|||
true,
|
||||
),
|
||||
// Retain end tag if touching inline element
|
||||
("<p>Some text</p><button></button>", "<p>Some text</p><button></button>", false, false),
|
||||
(
|
||||
"<p>Some text</p><button></button>",
|
||||
"<p>Some text</p><button></button>",
|
||||
false,
|
||||
false,
|
||||
),
|
||||
] {
|
||||
let mut w = vec![];
|
||||
let mut minifier = Minifier::new(&mut w);
|
||||
minifier
|
||||
.omit_doctype(true)
|
||||
.collapse_whitespace(collapse_whitespace)
|
||||
.preserve_comments(preserve_comments);
|
||||
minifier.minify(&mut input.as_bytes()).unwrap();
|
||||
let mut w = vec![];
|
||||
let mut minifier = Minifier::new(&mut w);
|
||||
minifier
|
||||
.omit_doctype(true)
|
||||
.collapse_whitespace(collapse_whitespace)
|
||||
.preserve_comments(preserve_comments);
|
||||
minifier.minify(&mut input.as_bytes()).unwrap();
|
||||
|
||||
let s = str::from_utf8(&w).unwrap();
|
||||
let s = str::from_utf8(&w).unwrap();
|
||||
|
||||
assert_eq!(expected, s);
|
||||
}
|
||||
assert_eq!(expected, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,23 +5,23 @@ use std::{
|
|||
};
|
||||
|
||||
use gpui::{
|
||||
div, img, prelude::FluentBuilder as _, px, relative, rems, AnyElement, App, DefiniteLength,
|
||||
Div, Element, ElementId, FontStyle, FontWeight, Half, HighlightStyle, InteractiveElement as _,
|
||||
IntoElement, Length, ListState, ObjectFit, ParentElement, SharedString, SharedUri,
|
||||
StatefulInteractiveElement, Styled, StyledImage as _, Window,
|
||||
AnyElement, App, DefiniteLength, Div, Element, ElementId, FontStyle, FontWeight, Half,
|
||||
HighlightStyle, InteractiveElement as _, IntoElement, Length, ListState, ObjectFit,
|
||||
ParentElement, SharedString, SharedUri, StatefulInteractiveElement, Styled, StyledImage as _,
|
||||
Window, div, img, prelude::FluentBuilder as _, px, relative, rems,
|
||||
};
|
||||
use markdown::mdast;
|
||||
use ropey::Rope;
|
||||
|
||||
use crate::{
|
||||
h_flex,
|
||||
ActiveTheme as _, Icon, IconName, StyledExt, h_flex,
|
||||
highlighter::{HighlightTheme, SyntaxHighlighter},
|
||||
text::inline::{Inline, InlineState},
|
||||
tooltip::Tooltip,
|
||||
v_flex, ActiveTheme as _, Icon, IconName, StyledExt,
|
||||
v_flex,
|
||||
};
|
||||
|
||||
use super::{utils::list_item_prefix, TextViewStyle};
|
||||
use super::{TextViewStyle, utils::list_item_prefix};
|
||||
|
||||
#[allow(unused)]
|
||||
#[derive(Debug, Default, Clone, PartialEq)]
|
||||
|
|
@ -767,11 +767,7 @@ impl Node {
|
|||
children, checked, ..
|
||||
} => {
|
||||
let checkbox = if let Some(checked) = checked {
|
||||
if *checked {
|
||||
"[x] "
|
||||
} else {
|
||||
"[ ] "
|
||||
}
|
||||
if *checked { "[x] " } else { "[ ] " }
|
||||
} else {
|
||||
""
|
||||
};
|
||||
|
|
@ -866,7 +862,7 @@ impl Node {
|
|||
node_cx: &NodeContext,
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> impl IntoElement {
|
||||
) -> AnyElement {
|
||||
match item {
|
||||
Node::ListItem {
|
||||
children,
|
||||
|
|
@ -899,10 +895,9 @@ impl Node {
|
|||
// merge content into last item.
|
||||
if last_not_list {
|
||||
if let Some(item_item) = items.last_mut() {
|
||||
item_item.extend(vec![div()
|
||||
.overflow_hidden()
|
||||
.child(text)
|
||||
.into_any_element()]);
|
||||
item_item.extend(vec![
|
||||
div().overflow_hidden().child(text).into_any_element(),
|
||||
]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
@ -1116,7 +1111,7 @@ impl Node {
|
|||
node_cx: &NodeContext,
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> impl IntoElement {
|
||||
) -> AnyElement {
|
||||
let mb = if options.in_list || options.is_last {
|
||||
rems(0.)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -2,16 +2,17 @@ use std::{borrow::Cow, rc::Rc};
|
|||
|
||||
use chrono::{Datelike, Local, NaiveDate};
|
||||
use gpui::{
|
||||
prelude::FluentBuilder as _, px, relative, App, ClickEvent, Context, ElementId, Empty, Entity,
|
||||
EventEmitter, FocusHandle, InteractiveElement, IntoElement, ParentElement, Render, RenderOnce,
|
||||
SharedString, StatefulInteractiveElement, StyleRefinement, Styled, Window,
|
||||
App, ClickEvent, Context, Div, ElementId, Empty, Entity, EventEmitter, FocusHandle,
|
||||
InteractiveElement, IntoElement, ParentElement, Render, RenderOnce, SharedString, Stateful,
|
||||
StatefulInteractiveElement, StyleRefinement, Styled, Window, prelude::FluentBuilder as _, px,
|
||||
relative,
|
||||
};
|
||||
use rust_i18n::t;
|
||||
|
||||
use crate::{
|
||||
ActiveTheme, Disableable as _, IconName, Selectable, Sizable, Size, StyledExt as _,
|
||||
button::{Button, ButtonVariants as _},
|
||||
h_flex, v_flex, ActiveTheme, Disableable as _, IconName, Selectable, Sizable, Size,
|
||||
StyledExt as _,
|
||||
h_flex, v_flex,
|
||||
};
|
||||
|
||||
use super::utils::days_in_month;
|
||||
|
|
@ -543,7 +544,7 @@ impl Calendar {
|
|||
offset_month: usize,
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> impl IntoElement {
|
||||
) -> Stateful<Div> {
|
||||
let state = self.state.read(cx);
|
||||
let (_, month) = state.offset_year_month(offset_month);
|
||||
let day = d.day();
|
||||
|
|
@ -561,7 +562,7 @@ impl Calendar {
|
|||
let date_id: SharedString = format!("{}_{}", date.format("%Y-%m-%d"), offset_month).into();
|
||||
|
||||
self.item_button(
|
||||
date_id,
|
||||
date_id.clone(),
|
||||
day.to_string(),
|
||||
is_active,
|
||||
is_in_range,
|
||||
|
|
@ -734,7 +735,7 @@ impl Calendar {
|
|||
disabled: bool,
|
||||
_: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> impl IntoElement + Styled + StatefulInteractiveElement {
|
||||
) -> Stateful<Div> {
|
||||
h_flex()
|
||||
.id(id.into())
|
||||
.map(|this| match self.size {
|
||||
|
|
@ -815,12 +816,7 @@ impl Calendar {
|
|||
)
|
||||
}
|
||||
|
||||
fn render_week(
|
||||
&self,
|
||||
week: impl Into<SharedString>,
|
||||
_: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> impl IntoElement {
|
||||
fn render_week(&self, week: impl Into<SharedString>, _: &mut Window, cx: &mut App) -> Div {
|
||||
h_flex()
|
||||
.map(|this| match self.size {
|
||||
Size::Small => this.size_7().rounded(cx.theme().radius / 2.0),
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
[package]
|
||||
edition = "2021"
|
||||
name = "app_assets"
|
||||
description = "Example to load icons or images from assets folder."
|
||||
publish = false
|
||||
version = "0.4.1"
|
||||
publish = false
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
[package]
|
||||
edition = "2021"
|
||||
name = "dialog_overlay"
|
||||
description = "An example of using gpui-component to create a Dialog with overlay."
|
||||
publish = false
|
||||
version = "0.4.1"
|
||||
publish = false
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
[package]
|
||||
edition = "2021"
|
||||
name = "hello_world"
|
||||
description = "A minimal example of application development with GPUI Component."
|
||||
publish = false
|
||||
version = "0.4.1"
|
||||
publish = false
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
name = "input"
|
||||
version = "0.4.1"
|
||||
publish = false
|
||||
edition = "2024"
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
[package]
|
||||
edition = "2021"
|
||||
name = "window_title"
|
||||
description = "An example of using gpui-component to create a window with a custom title bar."
|
||||
publish = false
|
||||
version = "0.4.1"
|
||||
publish = false
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
|
|
|
|||
Loading…
Reference in a new issue