lib.rs

  1use gpui::{actions, impl_actions};
  2use serde::Deserialize;
  3
  4// If the zed binary doesn't use anything in this crate, it will be optimized away
  5// and the actions won't initialize. So we just provide an empty initialization function
  6// to be called from main.
  7//
  8// These may provide relevant context:
  9// https://github.com/rust-lang/rust/issues/47384
 10// https://github.com/mmastrac/rust-ctor/issues/280
 11pub fn init() {}
 12
 13#[derive(Clone, PartialEq, Deserialize)]
 14pub struct OpenBrowser {
 15    pub url: String,
 16}
 17
 18#[derive(Clone, PartialEq, Deserialize)]
 19pub struct OpenZedUrl {
 20    pub url: String,
 21}
 22
 23impl_actions!(zed, [OpenBrowser, OpenZedUrl]);
 24
 25actions!(
 26    zed,
 27    [
 28        OpenSettings,
 29        OpenDefaultKeymap,
 30        OpenAccountSettings,
 31        OpenServerSettings,
 32        Quit,
 33        OpenKeymap,
 34        About,
 35        Extensions,
 36        OpenLicenses,
 37        OpenTelemetryLog,
 38        DecreaseBufferFontSize,
 39        IncreaseBufferFontSize,
 40        ResetBufferFontSize,
 41        DecreaseUiFontSize,
 42        IncreaseUiFontSize,
 43        ResetUiFontSize
 44    ]
 45);
 46
 47#[derive(Clone, Default, Deserialize, PartialEq)]
 48pub struct InlineAssist {
 49    pub prompt: Option<String>,
 50}
 51
 52impl_actions!(assistant, [InlineAssist]);
 53
 54#[derive(PartialEq, Clone, Deserialize, Default)]
 55pub struct OpenRecent {
 56    #[serde(default)]
 57    pub create_new_window: bool,
 58}
 59gpui::impl_actions!(projects, [OpenRecent]);
 60gpui::actions!(projects, [OpenRemote]);
 61
 62/// Spawn a task with name or open tasks modal
 63#[derive(PartialEq, Clone, Deserialize, Default)]
 64pub struct Spawn {
 65    #[serde(default)]
 66    /// Name of the task to spawn.
 67    /// If it is not set, a modal with a list of available tasks is opened instead.
 68    /// Defaults to None.
 69    pub task_name: Option<String>,
 70}
 71
 72impl Spawn {
 73    pub fn modal() -> Self {
 74        Self { task_name: None }
 75    }
 76}
 77
 78/// Rerun last task
 79#[derive(PartialEq, Clone, Deserialize, Default)]
 80pub struct Rerun {
 81    /// Controls whether the task context is reevaluated prior to execution of a task.
 82    /// If it is not, environment variables such as ZED_COLUMN, ZED_FILE are gonna be the same as in the last execution of a task
 83    /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
 84    /// default: false
 85    #[serde(default)]
 86    pub reevaluate_context: bool,
 87    /// Overrides `allow_concurrent_runs` property of the task being reran.
 88    /// Default: null
 89    #[serde(default)]
 90    pub allow_concurrent_runs: Option<bool>,
 91    /// Overrides `use_new_terminal` property of the task being reran.
 92    /// Default: null
 93    #[serde(default)]
 94    pub use_new_terminal: Option<bool>,
 95
 96    /// If present, rerun the task with this ID, otherwise rerun the last task.
 97    pub task_id: Option<String>,
 98}
 99
100impl_actions!(task, [Spawn, Rerun]);