add repository shortcuts and extract repository switcher
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run
Rust / build (macos-latest, stable) (pull_request) Waiting to run
Rust / build (ubuntu-latest, stable) (pull_request) Waiting to run
Rust / build (windows-latest, stable) (pull_request) Waiting to run

This commit is contained in:
2026-11-17 14:56:09 +07:00
parent 0cd0e4672f
commit d5bf8c3e0f
14 changed files with 702 additions and 211 deletions
+10
View File
@@ -74,6 +74,7 @@ pub struct Button {
loading: bool,
padded: bool,
fully_rounded: bool,
full_width: bool,
side: ButtonSide,
tab_stop: bool,
debug_selector: Option<Rc<dyn Fn() -> String>>,
@@ -101,6 +102,7 @@ impl Button {
loading: false,
padded: true,
fully_rounded: false,
full_width: false,
side: ButtonSide::default(),
tab_stop: true,
debug_selector: None,
@@ -190,6 +192,12 @@ impl Button {
self
}
/// Stretches the button and its content across the available width.
pub fn full_width(mut self, full_width: bool) -> Self {
self.full_width = full_width;
self
}
/// Sets the edge the content aligns to, `Right` renders the icon after the label.
pub fn side(mut self, side: ButtonSide) -> Self {
self.side = side;
@@ -313,6 +321,7 @@ impl RenderOnce for Button {
})
.h(metrics.control_height)
.when(is_icon_only, |button| button.w(metrics.control_height))
.when(self.full_width, |button| button.w_full())
.when(!is_icon_only && self.padded, |button| {
button.px(metrics.padding_x)
})
@@ -328,6 +337,7 @@ impl RenderOnce for Button {
.child(
h_flex()
.gap_2()
.when(self.full_width, |content| content.flex_1())
.when(self.loading, |content| content.invisible())
.map(|content| {
if icon_trailing {
+21 -10
View File
@@ -23,13 +23,15 @@
//! }
//! ```
use std::rc::Rc;
use gpui::prelude::FluentBuilder as _;
use gpui::{
App, Bounds, ClipboardItem, Context, ElementId, HighlightStyle, Hsla, InteractiveElement as _,
IntoElement, KeyBinding, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent,
ParentElement as _, Pixels, Point, Render, ScrollStrategy, SharedString,
StatefulInteractiveElement as _, Styled as _, TextStyle, UniformListScrollHandle, Window,
actions, canvas, div, uniform_list,
IntoElement, KeyBinding, KeyBindingContextPredicate, MouseButton, MouseDownEvent,
MouseMoveEvent, MouseUpEvent, ParentElement as _, Pixels, Point, Render, ScrollStrategy,
SharedString, StatefulInteractiveElement as _, Styled as _, TextStyle, UniformListScrollHandle,
Window, actions, canvas, div, uniform_list,
};
use crate::components::highlight::{HighlightedCode, Language, Role, highlight};
@@ -49,12 +51,21 @@ pub const CODE_VIEW_CONTEXT: &str = "CodeView";
///
/// Call once at startup. Without it, selection copy has no key.
pub fn bind_code_view_keys(cx: &mut App) {
let context = Some(CODE_VIEW_CONTEXT);
#[cfg(target_os = "macos")]
let copy = "cmd-c";
#[cfg(not(target_os = "macos"))]
let copy = "ctrl-c";
cx.bind_keys([KeyBinding::new(copy, Copy, context)]);
let context = match KeyBindingContextPredicate::parse(CODE_VIEW_CONTEXT) {
Ok(context) => Some(Rc::new(context)),
Err(error) => {
log::error!("failed to parse code view key context: {error}");
return;
}
};
let binding = match KeyBinding::load("secondary-c", Box::new(Copy), context, false, None, cx) {
Ok(binding) => binding,
Err(error) => {
log::error!("failed to parse code view copy keystroke: {error}");
return;
}
};
cx.bind_keys([binding]);
}
/// A point in the source, in lines and characters (not bytes).
+14 -3
View File
@@ -1907,6 +1907,7 @@ pub struct Input {
disabled: bool,
/// The placeholder stays visible while focused.
placeholder_when_focused: bool,
fully_rounded: bool,
a11y_label: Option<SharedString>,
/// Multiline field height in row, ignored when the state is single-line.
rows: usize,
@@ -1928,6 +1929,7 @@ impl Input {
size: Size::default(),
disabled: false,
placeholder_when_focused: false,
fully_rounded: false,
a11y_label: None,
rows: DEFAULT_ROWS,
prefix: None,
@@ -1957,8 +1959,13 @@ impl Input {
self
}
/// Renders the field inert, unfocusable, and dimmed, regardless of the
/// state's read-only setting.
/// Renders the field as a pill instead of the control radius.
pub fn fully_rounded(mut self, fully_rounded: bool) -> Self {
self.fully_rounded = fully_rounded;
self
}
/// Renders the field inert, unfocusable, and dimmed.
pub fn disabled(mut self, disabled: bool) -> Self {
self.disabled = disabled;
self
@@ -2179,7 +2186,11 @@ impl RenderOnce for Input {
metrics.dense_padding_x
})
.gap_2()
.rounded(radius.control)
.rounded(if self.fully_rounded {
radius.full
} else {
radius.control
})
.bg(colors.input)
.text_size(metrics.text_size)
.text_color(colors.foreground)
+21 -11
View File
@@ -28,17 +28,18 @@ use std::borrow::Borrow as _;
use std::collections::HashMap;
use std::hash::{DefaultHasher, Hash, Hasher};
use std::ops::Range;
use std::rc::Rc;
use std::sync::Arc;
use gpui::prelude::FluentBuilder as _;
use gpui::{
AnyElement, App, Bounds, ClipboardItem, Context, Div, Element, ElementId, Entity, FontStyle,
GlobalElementId, HighlightStyle, InspectorElementId, InteractiveElement as _, InteractiveText,
IntoElement, KeyBinding, LayoutId, ListAlignment, ListOffset, ListState, MouseButton,
MouseDownEvent, MouseMoveEvent, ObjectFit, ParentElement as _, Pixels, Refineable as _, Render,
SharedString, StatefulInteractiveElement as _, StrikethroughStyle, StyleRefinement, Styled,
StyledImage as _, StyledText, TextLayout, UnderlineStyle, Window, actions, div, img, list, px,
relative,
IntoElement, KeyBinding, KeyBindingContextPredicate, LayoutId, ListAlignment, ListOffset,
ListState, MouseButton, MouseDownEvent, MouseMoveEvent, ObjectFit, ParentElement as _, Pixels,
Refineable as _, Render, SharedString, StatefulInteractiveElement as _, StrikethroughStyle,
StyleRefinement, Styled, StyledImage as _, StyledText, TextLayout, UnderlineStyle, Window,
actions, div, img, list, px, relative,
};
use pulldown_cmark::{CodeBlockKind, Event, HeadingLevel, Options, Parser, Tag, TagEnd};
@@ -848,12 +849,21 @@ impl InlineBuilder {
///
/// Call once at startup. Without it, selection copy has no key.
pub fn bind_text_view_keys(cx: &mut App) {
let context = Some(TEXT_VIEW_CONTEXT);
#[cfg(target_os = "macos")]
let copy = "cmd-c";
#[cfg(not(target_os = "macos"))]
let copy = "ctrl-c";
cx.bind_keys([KeyBinding::new(copy, Copy, context)]);
let context = match KeyBindingContextPredicate::parse(TEXT_VIEW_CONTEXT) {
Ok(context) => Some(Rc::new(context)),
Err(error) => {
log::error!("failed to parse text view key context: {error}");
return;
}
};
let binding = match KeyBinding::load("secondary-c", Box::new(Copy), context, false, None, cx) {
Ok(binding) => binding,
Err(error) => {
log::error!("failed to parse text view copy keystroke: {error}");
return;
}
};
cx.bind_keys([binding]);
}
/// The view's base container: selection wiring, focus, and copy.
+4 -13
View File
@@ -24,6 +24,7 @@ use gpui::{
StyleRefinement, Styled as _, Window, div,
};
use crate::common::v_flex;
use crate::components::common::{
StyledExt as _, nav_key, paint_selectable_row, selectable_label_color,
};
@@ -202,8 +203,7 @@ impl Sidebar {
self.transparent
}
/// Textures the material with a film-grain overlay; it renders only while
/// the sidebar paints one.
/// Textures the sidebar with a film-grain overlay.
pub fn grain(mut self, grain: bool) -> Self {
self.grain = grain;
self
@@ -390,22 +390,13 @@ impl RenderOnce for Sidebar {
let theme = cx.theme();
div()
v_flex()
.id(id.clone())
.refine_style(&style)
.debug_selector(move || format!("sidebar-{debug_id}"))
.h_full()
.w(width)
.flex()
.flex_col()
.map(|sidebar| {
if material {
sidebar.bg(theme.material.background)
} else {
sidebar.bg(theme.colors.sidebar)
}
})
.text_size(theme.sizes.medium.text_size)
.refine_style(&style)
.when(border_right, |sidebar| {
sidebar
.border_r(BORDER_WIDTH)
-4
View File
@@ -23,8 +23,6 @@ pub struct ColorTokens {
pub foreground: Hsla,
pub surface: Hsla,
pub surface_foreground: Hsla,
/// The docked sidebar's backdrop.
pub sidebar: Hsla,
pub primary: Hsla,
pub primary_foreground: Hsla,
pub secondary: Hsla,
@@ -60,7 +58,6 @@ impl ColorTokens {
foreground: hex(0x18181b),
surface: hex(0xfafafa),
surface_foreground: hex(0x18181b),
sidebar: hex(0xf4f4f5),
primary: hex(0x2563eb),
primary_foreground: hex(0xffffff),
secondary: hex(0xf4f4f5),
@@ -95,7 +92,6 @@ impl ColorTokens {
foreground: hex(0xfafafa),
surface: hex(0x18181b),
surface_foreground: hex(0xfafafa),
sidebar: hex(0x18181b),
primary: hex(0x3b82f6),
primary_foreground: hex(0xffffff),
secondary: hex(0x27272a),
-5
View File
@@ -19,7 +19,6 @@ pub struct ThemeDefinition {
foreground: Option<String>,
surface: Option<String>,
surface_foreground: Option<String>,
sidebar: Option<String>,
primary: Option<String>,
primary_foreground: Option<String>,
secondary: Option<String>,
@@ -88,10 +87,6 @@ impl ThemeDefinition {
self.color(&self.surface_foreground, "surface_foreground")
}
pub fn sidebar(&self) -> Option<Hsla> {
self.color(&self.sidebar, "sidebar")
}
pub fn primary(&self) -> Option<Hsla> {
self.color(&self.primary, "primary")
}
-1
View File
@@ -82,7 +82,6 @@ pub(crate) fn resolve(
surface: def_color(|d| d.surface()).unwrap_or(base.surface),
surface_foreground: def_color(|d| d.surface_foreground())
.unwrap_or(base.surface_foreground),
sidebar: def_color(|d| d.sidebar()).unwrap_or(base.sidebar),
primary,
primary_foreground: def_color(|d| d.primary_foreground())
.unwrap_or_else(|| contrast_foreground(primary)),