Introduce an outline panel (#12637)
Adds a new panel: `OutlinePanel` which looks very close to project panel: <img width="256" alt="Screenshot 2024-06-10 at 23 19 05" src="https://github.com/zed-industries/zed/assets/2690773/c66e6e78-44ec-4de8-8d60-43238bb09ae9"> has similar settings and keymap (actions work in the `OutlinePanel` context and are under `outline_panel::` namespace), with two notable differences: * no "edit" actions such as cut/copy/paste/delete/etc. * directory auto folding is enabled by default Empty view: <img width="841" alt="Screenshot 2024-06-10 at 23 19 11" src="https://github.com/zed-industries/zed/assets/2690773/dc8bf37c-5a70-4fd5-9b57-76271eb7a40c"> When editor gets active, the panel displays all related files in a tree (similar to what the project panel does) and all related excerpts' outlines under each file. Same as in the project panel, directories can be expanded or collapsed, unfolded or folded; clicking file entries or outlines scrolls the buffer to the corresponding excerpt; changing editor's selection reveals the corresponding outline in the panel. The panel is applicable to any singleton buffer: <img width="1215" alt="Screenshot 2024-06-10 at 23 19 35" src="https://github.com/zed-industries/zed/assets/2690773/a087631f-5c2d-4d4d-ae25-30ab9731d528"> <img width="1728" alt="image" src="https://github.com/zed-industries/zed/assets/2690773/e4f8082c-d12d-4473-8500-e8fd1051285b"> or any multi buffer: (search multi buffer) <img width="1728" alt="Screenshot 2024-06-10 at 23 19 41" src="https://github.com/zed-industries/zed/assets/2690773/60f768a3-6716-4520-9b13-42da8fd15f50"> (diagnostics multi buffer) <img width="1728" alt="image" src="https://github.com/zed-industries/zed/assets/2690773/64e285bd-9530-4bf2-8f1f-10ee5596067c"> Release Notes: - Added an outline panel to show a "map" of the active editor
This commit is contained in:
parent
7f56f4e78e
commit
8451dba6a7
27 changed files with 2860 additions and 57 deletions
|
@ -1,6 +1,9 @@
|
|||
use anyhow::{bail, Context};
|
||||
use serde::de::{self, Deserialize, Deserializer, Visitor};
|
||||
use std::fmt;
|
||||
use std::{
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
};
|
||||
|
||||
/// Convert an RGB hex color code number to a color type
|
||||
pub fn rgb(hex: u32) -> Rgba {
|
||||
|
@ -267,6 +270,15 @@ impl Ord for Hsla {
|
|||
|
||||
impl Eq for Hsla {}
|
||||
|
||||
impl Hash for Hsla {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
state.write_u32(u32::from_be_bytes(self.h.to_be_bytes()));
|
||||
state.write_u32(u32::from_be_bytes(self.s.to_be_bytes()));
|
||||
state.write_u32(u32::from_be_bytes(self.l.to_be_bytes()));
|
||||
state.write_u32(u32::from_be_bytes(self.a.to_be_bytes()));
|
||||
}
|
||||
}
|
||||
|
||||
/// Construct an [`Hsla`] object from plain values
|
||||
pub fn hsla(h: f32, s: f32, l: f32, a: f32) -> Hsla {
|
||||
Hsla {
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
use std::{iter, mem, ops::Range};
|
||||
use std::{
|
||||
hash::{Hash, Hasher},
|
||||
iter, mem,
|
||||
ops::Range,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
black, phi, point, quad, rems, AbsoluteLength, Bounds, ContentMask, Corners, CornersRefinement,
|
||||
|
@ -319,6 +323,20 @@ pub struct HighlightStyle {
|
|||
|
||||
impl Eq for HighlightStyle {}
|
||||
|
||||
impl Hash for HighlightStyle {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.color.hash(state);
|
||||
self.font_weight.hash(state);
|
||||
self.font_style.hash(state);
|
||||
self.background_color.hash(state);
|
||||
self.underline.hash(state);
|
||||
self.strikethrough.hash(state);
|
||||
state.write_u32(u32::from_be_bytes(
|
||||
self.fade_out.map(|f| f.to_be_bytes()).unwrap_or_default(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
impl Style {
|
||||
/// Returns true if the style is visible and the background is opaque.
|
||||
pub fn has_opaque_background(&self) -> bool {
|
||||
|
@ -549,7 +567,7 @@ impl Default for Style {
|
|||
}
|
||||
|
||||
/// The properties that can be applied to an underline.
|
||||
#[derive(Refineable, Copy, Clone, Default, Debug, PartialEq, Eq)]
|
||||
#[derive(Refineable, Copy, Clone, Default, Debug, PartialEq, Eq, Hash)]
|
||||
#[refineable(Debug)]
|
||||
pub struct UnderlineStyle {
|
||||
/// The thickness of the underline.
|
||||
|
@ -563,7 +581,7 @@ pub struct UnderlineStyle {
|
|||
}
|
||||
|
||||
/// The properties that can be applied to a strikethrough.
|
||||
#[derive(Refineable, Copy, Clone, Default, Debug, PartialEq, Eq)]
|
||||
#[derive(Refineable, Copy, Clone, Default, Debug, PartialEq, Eq, Hash)]
|
||||
#[refineable(Debug)]
|
||||
pub struct StrikethroughStyle {
|
||||
/// The thickness of the strikethrough.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue