id stringlengths 20 30 | source stringclasses 1
value | chunk_index int64 0 520k | token_count int32 154 512 | content stringlengths 185 57.5k |
|---|---|---|---|---|
rust_dataset_chunk_518600 | rust_dataset.txt | 518,600 | 512 | PaneFrameStyle::None
);
assert!("bogus".parse::<PaneFrameStyle>().is_err());
}
#[test]
fn host_notification_protocol_from_str_accepts_all_variants() {
assert_eq!(
"auto".parse::<HostNotificationProtocol>().unwrap(),
HostNotificationProtocol::Auto
... |
rust_dataset_chunk_518601 | rust_dataset.txt | 518,601 | 512 | );
}
#[test]
fn a_host_notification_protocol_unset_everywhere_stays_unset() {
assert_eq!(
Options::default()
.merge(Options::default())
.host_notification_protocol,
None
);
assert_eq!(
Options::default()
... |
rust_dataset_chunk_518602 | rust_dataset.txt | 518,602 | 512 | let mut all_granted = true;
for permission in permissions_to_check {
if !target.contains(permission) {
all_granted = false;
}
}
return all_granted;
}
false
}
pub fn from_path_or_default(cache_path: Option<... |
rust_dataset_chunk_518603 | rust_dataset.txt | 518,603 | 512 | Location,
/// Custom configuration for this plugin
pub initial_userspace_configuration: PluginUserConfiguration,
/// plugin initial working directory
pub initial_cwd: Option<PathBuf>,
}
impl PluginConfig {
pub fn from_run_plugin(run_plugin: &RunPlugin) -> Option<PluginConfig> {
match &run_p... |
rust_dataset_chunk_518604 | rust_dataset.txt | 518,604 | 512 | , and finally the system data directory joined with
/// "plugins" and the same file name. So if our path is "tab-bar" and the given plugin dir is
/// "/home/bob/.local/share/zellij/plugins" the lookup chain will be this:
///
/// ```bash
/// /home/bob/.local/share/zellij/plugins/tab-bar.wasm
//... |
rust_dataset_chunk_518605 | rust_dataset.txt | 518,605 | 512 | must initialize `last_err` with something,
// and since the user will only get to see it when loading a plugin failed, we may as well
// spell it out right here.
let mut last_err: Result<Vec<u8>> = Err(anyhow!("failed to load plugin from disk"));
for path in paths {
// Try t... |
rust_dataset_chunk_518606 | rust_dataset.txt | 518,606 | 512 | match location {
RunPluginLocation::Zellij(tag) if legacy_bars_role(&tag.to_string()).is_some() => {
RunPluginLocation::Zellij(PluginTag::new(BARS_PLUGIN_NAME))
},
other => other.clone(),
}
}
pub fn canonical_run_plugin(run_plugin: &RunPlugin) -> RunPlugin {
let mut cano... |
rust_dataset_chunk_518607 | rust_dataset.txt | 518,607 | 512 | FACT_GIT_BRANCH,
FACT_GIT_WORKTREE,
FACT_HOSTNAME,
];
pub const DEFAULT_SCRIPT_TIMEOUT_MS: u64 = 300;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
pub enum FactTiming {
Start,
#[default]
Live,
}
impl FactTiming {
fn as_str(&self) -> &'static str {
... |
rust_dataset_chunk_518608 | rust_dataset.txt | 518,608 | 512 | Node) -> ConfigError {
ConfigError::new_kdl_error(message, node.span().offset(), node.span().len())
}
fn string_property<'a>(node: &'a KdlNode, name: &str) -> Option<&'a str> {
node.get(name).and_then(|e| e.value().as_string())
}
fn positional_strings(node: &KdlNode) -> Vec<String> {
node.entries()
... |
rust_dataset_chunk_518609 | rust_dataset.txt | 518,609 | 512 | .as_str()) {
return Err(kdl_error(
format!("\"{}\" is a built-in fact and cannot be redefined", name),
node,
));
}
let command = string_property(node, "command")
... |
rust_dataset_chunk_518610 | rust_dataset.txt | 518,610 | 512 | ("hide_unlisted").map(|e| e.value()) {
None => false,
Some(value) => value.as_bool().ok_or_else(|| {
kdl_error("hide_unlisted must be true or false".to_owned(), node)
})?,
};
confi... |
rust_dataset_chunk_518611 | rust_dataset.txt | 518,611 | 512 | if let Some(then) = &self.then {
let mut then_node = KdlNode::new("then");
then_node.push(KdlValue::String(then.as_str().to_owned()));
children.nodes_mut().push(then_node);
}
if let Some(script) = &self.script {
let mut script_node = KdlNode::new("script"... |
rust_dataset_chunk_518612 | rust_dataset.txt | 518,612 | 512 | : FactTiming::Start,
}]
);
assert_eq!(
config.rules,
Some(vec![
MatchRule {
facts: vec!["directory".to_owned(), "git_branch".to_owned()]
},
MatchRule {
facts: vec!["project".to_own... |
rust_dataset_chunk_518613 | rust_dataset.txt | 518,613 | 512 | from("rank.sh"),
timeout_ms: DEFAULT_SCRIPT_TIMEOUT_MS,
hide_unlisted: false,
})
);
}
#[test]
fn to_kdl_round_trips() {
let config = parse(
r#"
session_suggestions {
fact "project" command="echo $PROJECT" co... |
rust_dataset_chunk_518614 | rust_dataset.txt | 518,614 | 512 | _get_child, kdl_get_child_entry_bool_value, kdl_get_child_entry_string_value};
use super::config::ConfigError;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum CursorStyle {
Block,
Bar,
Underline,
}
impl CursorStyle {
pub fn from_kdl(kdl: &KdlNode) -> Result<Self, ConfigE... |
rust_dataset_chunk_518615 | rust_dataset.txt | 518,615 | 512 | ellMode::Both),
Some("none") => Ok(BellMode::None),
_ => Err(ConfigError::new_kdl_error(
"bell must be \"visual\", \"audible\", \"both\" or \"none\"".to_owned(),
kdl.span().offset(),
kdl.span().len(),
)),
}
}
pub fn to_... |
rust_dataset_chunk_518616 | rust_dataset.txt | 518,616 | 512 | KdlNode) -> Result<Self, ConfigError> {
let named = kdl
.entries()
.iter()
.next()
.and_then(|entry| entry.value().as_string());
match named.map(str::to_ascii_lowercase).as_deref() {
Some("windowed") => Ok(StartupMode::Windowed),
So... |
rust_dataset_chunk_518617 | rust_dataset.txt | 518,617 | 512 | "everything",
}
.to_owned(),
));
node
}
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum TitlebarTheme {
#[default]
System,
Light,
Dark,
}
impl TitlebarTheme {
pub fn from_kdl(kdl: &KdlNode) -> Result<Self, Config... |
rust_dataset_chunk_518618 | rust_dataset.txt | 518,618 | 512 | = KdlNode::new("padding_color");
node.push(KdlValue::String(
match self {
PaddingColor::Background => "background",
PaddingColor::Extend => "extend",
}
.to_owned(),
));
node
}
}
#[derive(Debug, Default, Clone, Copy, Partia... |
rust_dataset_chunk_518619 | rust_dataset.txt | 518,619 | 512 | ),
("medium", 500),
("semibold", 600),
("demibold", 600),
("bold", 700),
("extrabold", 800),
("ultrabold", 800),
("black", 900),
("heavy", 900),
];
pub const MIN_CELL_SCALE: f32 = 0.5;
pub const MAX_CELL_SCALE: f32 = 3.0;
pub const MAX_PIXEL_ADJUSTMENT: i32 = 64;
pub const MAX_PADDING: ... |
rust_dataset_chunk_518620 | rust_dataset.txt | 518,620 | 512 | KdlDocument::new();
for (name, color) in [
("foreground", self.foreground),
("background", self.background),
("cursor", self.cursor),
] {
if let Some(color) = color {
children.nodes_mut().push(color.to_kdl(name));
}
}
... |
rust_dataset_chunk_518621 | rust_dataset.txt | 518,621 | 512 | match self.explicit_hue {
Some(ThemeHue::Light) => HostTerminalThemeMode::Light,
_ => HostTerminalThemeMode::Dark,
}
}
pub fn to_json(&self) -> Result<String, String> {
serde_json::to_string(self).map_err(|e| e.to_string())
}
pub fn from_json(text: &str)... |
rust_dataset_chunk_518622 | rust_dataset.txt | 518,622 | 512 | <String>>,
pub fullscreen_keys: Option<Vec<KeyWithModifier>>,
pub hide_pointer_while_typing: Option<bool>,
pub cursor_unfocused_hollow: Option<bool>,
pub minimum_contrast: Option<f32>,
pub smooth_scrolling: Option<bool>,
pub scroll_animation_duration: Option<u16>,
pub scroll_momentum: Option... |
rust_dataset_chunk_518623 | rust_dataset.txt | 518,623 | 512 | kdl, "zoom_in_keys") {
window.zoom_in_keys = Some(keys_from_kdl(zoom_in_keys)?);
}
if let Some(zoom_out_keys) = kdl_get_child!(kdl, "zoom_out_keys") {
window.zoom_out_keys = Some(keys_from_kdl(zoom_out_keys)?);
}
if let Some(zoom_reset_keys) = kdl_get_child!(kdl, ... |
rust_dataset_chunk_518624 | rust_dataset.txt | 518,624 | 512 | if let Some(titlebar_theme) = kdl_get_child!(kdl, "titlebar_theme") {
window.titlebar_theme = Some(TitlebarTheme::from_kdl(titlebar_theme)?);
}
if let Some(option_as_alt) = kdl_get_child!(kdl, "macos_option_as_alt") {
window.macos_option_as_alt = Some(OptionAsAlt::from_kdl(optio... |
rust_dataset_chunk_518625 | rust_dataset.txt | 518,625 | 512 | name) {
*slot = Some(initial_cells_from_kdl(node, name)?);
}
}
if let Some(font_weight) = kdl_get_child!(kdl, "font_weight") {
window.font_weight = Some(font_weight_from_kdl(font_weight)?);
}
if let Some(font_features) = kdl_get_child!(kdl, "font_... |
rust_dataset_chunk_518626 | rust_dataset.txt | 518,626 | 512 | let Some(reuse) = kdl_get_child_entry_bool_value!(kdl, "reuse_session_windows") {
window.reuse_session_windows = Some(reuse);
}
if let Some(allow) = kdl_get_child_entry_bool_value!(kdl, "allow_remote_clipboard_read") {
window.allow_remote_clipboard_read = Some(allow);
}
... |
rust_dataset_chunk_518627 | rust_dataset.txt | 518,627 | 512 | _node);
}
for (name, keys) in [
("paste_keys", &self.paste_keys),
("zoom_in_keys", &self.zoom_in_keys),
("zoom_out_keys", &self.zoom_out_keys),
("zoom_reset_keys", &self.zoom_reset_keys),
("fullscreen_keys", &self.fullscreen_keys),
] {
... |
rust_dataset_chunk_518628 | rust_dataset.txt | 518,628 | 512 | ations) = self.window_decorations {
let mut decorations_node = KdlNode::new("window_decorations");
decorations_node.push(KdlValue::Bool(decorations));
children.nodes_mut().push(decorations_node);
}
if let Some(titlebar_theme) = self.titlebar_theme {
childr... |
rust_dataset_chunk_518629 | rust_dataset.txt | 518,629 | 512 | 10(value as i64));
children.nodes_mut().push(cells_node);
}
}
if let Some(font_weight) = self.font_weight {
let mut font_weight_node = KdlNode::new("font_weight");
font_weight_node.push(KdlValue::Base10(font_weight as i64));
children.nodes_... |
rust_dataset_chunk_518630 | rust_dataset.txt | 518,630 | 512 | mut keys_node = KdlNode::new("copy_keys");
for key in keys {
keys_node.push(KdlValue::String(key.to_kdl()));
}
children.nodes_mut().push(keys_node);
}
if children.nodes().is_empty() {
return None;
}
node.set_children(child... |
rust_dataset_chunk_518631 | rust_dataset.txt | 518,631 | 512 | theirs) => theirs.or(mine),
};
merged.padding = other.padding.or(merged.padding);
merged.padding_top = other.padding_top.or(merged.padding_top);
merged.padding_right = other.padding_right.or(merged.padding_right);
merged.padding_bottom = other.padding_bottom.or(merged.padding_bo... |
rust_dataset_chunk_518632 | rust_dataset.txt | 518,632 | 512 |
.or(merged.allow_remote_clipboard_read);
merged
}
}
fn number_node(name: &str, value: f32) -> KdlNode {
let mut node = KdlNode::new(name);
if value.fract() == 0.0 {
node.push(KdlValue::Base10(value as i64));
} else {
node.push(KdlValue::Base10Float(value as f64));
... |
rust_dataset_chunk_518633 | rust_dataset.txt | 518,633 | 512 | padding, MAX_PADDING
),
node.span().offset(),
node.span().len(),
));
}
Ok(padding as f32)
}
fn cell_scale_from_kdl(node: &KdlNode, name: &str) -> Result<f32, ConfigError> {
let scale = number_from_kdl(node, name)?;
if !(MIN_CELL_SCALE as f64..=MAX_CELL_SCALE... |
rust_dataset_chunk_518634 | rust_dataset.txt | 518,634 | 512 | _error(
format!(
"{} {} is outside the range {} to {} milliseconds",
name, duration, MIN_SCROLL_ANIMATION_MS, MAX_SCROLL_ANIMATION_MS
),
node.span().offset(),
node.span().len(),
));
}
Ok(duration as u16)
}
fn bool_from_kdl(... |
rust_dataset_chunk_518635 | rust_dataset.txt | 518,635 | 512 | *known == lowered)
.map(|(_, weight)| *weight)
.ok_or_else(|| {
error(format!(
"font_weight {:?} is not a weight; use a number from 100 to 900 or one of {}",
name,
names()
))
});
}
le... |
rust_dataset_chunk_518636 | rust_dataset.txt | 518,636 | 512 | ; use a four-character OpenType tag such as \"ss01\", \
optionally prefixed with - to turn it off",
text
)));
}
features.push(text.to_owned());
}
Ok(features)
}
fn font_size_from_kdl(node: &KdlNode) -> Result<f32, ConfigError> {
let error = |mess... |
rust_dataset_chunk_518637 | rust_dataset.txt | 518,637 | 512 | -> Result<Vec<KeyWithModifier>, ConfigError> {
let mut keys = Vec::new();
for entry in node.entries() {
let error = |message: String| {
ConfigError::new_kdl_error(message, entry.span().offset(), entry.span().len())
};
let text = entry
.value()
.as_str... |
rust_dataset_chunk_518638 | rust_dataset.txt | 518,638 | 512 | }
}
"##,
)
.unwrap();
assert_eq!(parsed.font.as_deref(), Some("Iosevka Term"));
assert_eq!(parsed.font_size, Some(18.0));
assert_eq!(parsed.system_fonts, Some(false));
assert_eq!(parsed.ligatures, Some(false));
assert_eq!(p... |
rust_dataset_chunk_518639 | rust_dataset.txt | 518,639 | 512 | 0))));
assert_eq!(theme.ansi[15], Some(PaletteColor::Rgb((255, 255, 255))));
assert_eq!(theme.ansi[0], None);
let emitted = parsed.to_kdl().unwrap().to_string();
let reparsed = section(&emitted).unwrap();
assert_eq!(reparsed, parsed);
}
#[test]
fn a_fractional_font... |
rust_dataset_chunk_518640 | rust_dataset.txt | 518,640 | 512 | ("terminal {\n open_links true\n}")
.unwrap()
.open_links,
Some(true)
);
assert_eq!(section("terminal {\n}").unwrap().open_links, None);
}
#[test]
fn a_key_that_does_not_parse_is_a_config_error() {
assert!(section("terminal {\n paste_keys ... |
rust_dataset_chunk_518641 | rust_dataset.txt | 518,641 | 512 | merged.theme.unwrap();
assert_eq!(theme.ansi[1], Some(PaletteColor::Rgb((1, 1, 1))));
assert_eq!(theme.ansi[2], Some(PaletteColor::Rgb((2, 2, 2))));
}
#[test]
fn every_cursor_style_is_named_the_way_the_web_client_names_it() {
for (text, expected) in [
("block", CursorSt... |
rust_dataset_chunk_518642 | rust_dataset.txt | 518,642 | 512 | _back() {
use crate::input::config::Config;
let config = Config::from_kdl("default_mode \"locked\"\n", None).unwrap();
assert_eq!(config.terminal, TerminalConfig::default());
assert!(
!config.to_string(false).contains("terminal"),
"an untouched section was writte... |
rust_dataset_chunk_518643 | rust_dataset.txt | 518,643 | 512 | StartupMode::Remember),
] {
let parsed = section(&format!("terminal {{\n startup_mode \"{}\"\n}}", text)).unwrap();
assert_eq!(parsed.startup_mode, Some(expected), "{}", text);
let reparsed = section(&parsed.to_kdl().unwrap().to_string()).unwrap();
assert_eq!(rep... |
rust_dataset_chunk_518644 | rust_dataset.txt | 518,644 | 512 | _is_named_and_an_unknown_one_lists_the_valid_ones() {
for (text, expected) in [
("background", OpacityMode::Background),
("everything", OpacityMode::Everything),
("Everything", OpacityMode::Everything),
] {
let parsed = section(&format!("terminal {{\n opac... |
rust_dataset_chunk_518645 | rust_dataset.txt | 518,645 | 512 | ater_section_supersedes_the_option_as_alt_side() {
let first = section("terminal {\n macos_option_as_alt \"both\"\n}").unwrap();
let kept = first.merge(section("terminal {\n blur true\n}").unwrap());
assert_eq!(kept.macos_option_as_alt, Some(OptionAsAlt::Both));
let replaced = kept.merge... |
rust_dataset_chunk_518646 | rust_dataset.txt | 518,646 | 512 | assert!(section("terminal {\n zoom_in_keys \"Ctrl nonsense\"\n}").is_err());
}
#[test]
fn a_modifierless_key_is_accepted() {
let parsed = section("terminal {\n paste_keys \"F5\"\n}").unwrap();
assert_eq!(
parsed.paste_keys,
Some(vec![KeyWithModifier::new(Bare... |
rust_dataset_chunk_518647 | rust_dataset.txt | 518,647 | 512 | _owned(),
"+dlig".to_owned()
])
);
let emitted = parsed.to_kdl().unwrap().to_string();
assert_eq!(section(&emitted).unwrap(), parsed, "{}", emitted);
}
#[test]
fn layout_options_are_unset_in_an_empty_section() {
let empty = section("terminal {\n}... |
rust_dataset_chunk_518648 | rust_dataset.txt | 518,648 | 512 | (&format!("terminal {{\n {} 1.5\n}}", name)).is_err());
assert!(section(&format!("terminal {{\n {} 65\n}}", name)).is_err());
assert!(section(&format!("terminal {{\n {} -65\n}}", name)).is_err());
assert!(section(&format!("terminal {{\n {} -3\n}}", name)).is_ok());
}
}
... |
rust_dataset_chunk_518649 | rust_dataset.txt | 518,649 | 512 | "4",
"\"ss 1\"",
] {
let err = section(&format!("terminal {{\n font_features {}\n}}", text)).unwrap_err();
assert!(
format!("{:?}", err).contains("font feature"),
"{}: {:?}",
text,
err
);
... |
rust_dataset_chunk_518650 | rust_dataset.txt | 518,650 | 512 | , Some(false));
assert_eq!(
parsed.copy_keys,
Some(vec![
KeyWithModifier::new(BareKey::Char('c'))
.with_ctrl_modifier()
.with_shift_modifier(),
KeyWithModifier::new(BareKey::Char('c')).with_super_modifier(),
... |
rust_dataset_chunk_518651 | rust_dataset.txt | 518,651 | 512 | ("terminal {\n}").unwrap();
assert_eq!(empty.window_decorations, None);
let merged = parsed.clone().merge(TerminalConfig {
window_decorations: Some(true),
..TerminalConfig::default()
});
assert_eq!(merged.window_decorations, Some(true));
let kept = parsed... |
rust_dataset_chunk_518652 | rust_dataset.txt | 518,652 | 512 | unwrap(), parsed, "{}", emitted);
let empty = section("terminal {\n}").unwrap();
assert_eq!(empty.smooth_scrolling, None);
assert_eq!(empty.scroll_animation_duration, None);
let merged = parsed.merge(section("terminal {\n smooth_scrolling true\n}").unwrap());
assert_eq!(merged.... |
rust_dataset_chunk_518653 | rust_dataset.txt | 518,653 | 512 | );
}
for text in ["1", "\"yes\"", ""] {
let err = section(&format!("terminal {{\n scroll_momentum {}\n}}", text)).unwrap_err();
assert!(
format!("{:?}", err).contains("scroll_momentum"),
"{}: {:?}",
text,
err
... |
rust_dataset_chunk_518654 | rust_dataset.txt | 518,654 | 512 | 4\n line_height 1.5\n}").unwrap();
let second = section("terminal {\n padding_left 9\n line_height 1.1\n}").unwrap();
let merged = first.merge(second);
assert_eq!(merged.padding, Some(4.0));
assert_eq!(merged.padding_left, Some(9.0));
assert_eq!(merged.line_height, Some(1.1));
... |
rust_dataset_chunk_518655 | rust_dataset.txt | 518,655 | 512 | 6) as usize],
CUBE_LEVELS[(cube % 6) as usize],
)
},
PaletteColor::EightBit(index) => {
let level = 8 + (index - 232) * 10;
(level, level, level)
},
}
}
fn channel(value: u8) -> f64 {
let value = value as f64 / 255.0;
if value <= 0... |
rust_dataset_chunk_518656 | rust_dataset.txt | 518,656 | 512 | ];
const STYLES_ALSO_ON_THE_PAGE: [&str; 3] =
["table_title", "table_cell_unselected", "list_unselected"];
const LINES_ON_THE_PAGE: [(&str, &str); 8] = [
("frame_unselected", "base"),
("frame_selected", "base"),
("frame_highlight", "base"),
("frame_highlight", "emphasis_0"),
("frame_highlight"... |
rust_dataset_chunk_518657 | rust_dataset.txt | 518,657 | 512 | (DrawnPair {
foreground: (MULTIPLAYER_COLOURS, player),
background: DrawnOn::CursorText,
target: LINE_CONTRAST,
});
}
pairs
}
#[derive(Debug, Clone, PartialEq)]
pub struct PairContrast {
pub pair: DrawnPair,
pub foreground: PaletteColor,
pub background: P... |
rust_dataset_chunk_518658 | rust_dataset.txt | 518,658 | 512 | ,
};
use std::{
collections::{BTreeMap, HashMap},
fmt,
};
use crate::data::{BorderStyle, BorderStyleOverride, PaletteColor, Styling};
#[derive(Debug, Default, Clone, Copy, PartialEq, Deserialize, Serialize)]
pub struct UiConfig {
pub pane_frames: FrameConfig,
}
impl UiConfig {
pub fn merge(&self, oth... |
rust_dataset_chunk_518659 | rust_dataset.txt | 518,659 | 512 | -> Self {
let mut merged = self.clone();
for (name, theme) in other.0.drain() {
merged.0.insert(name, theme);
}
merged
}
pub fn get_theme(&self, theme_name: &str) -> Option<&Theme> {
self.0.get(theme_name)
}
pub fn inner(&self) -> &HashMap<String, The... |
rust_dataset_chunk_518660 | rust_dataset.txt | 518,660 | 512 | , u8, u8) {
fn from(e: HexColor) -> (u8, u8, u8) {
let HexColor(r, g, b) = e;
(r, g, b)
}
}
pub struct HexColorVisitor();
impl<'de> Visitor<'de> for HexColorVisitor {
type Value = HexColor;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, ... |
rust_dataset_chunk_518661 | rust_dataset.txt | 518,661 | 512 | (format!("{:02X}{:02X}{:02X}", self.0, self.1, self.2).as_str())
}
}
#[cfg(test)]
#[path = "./unit/theme_test.rs"]
mod theme_test;
--- FILE: zellij/zellij-utils/src/input/unit/config_blocks_test.rs ---
use super::super::config::Config;
use super::super::config_blocks::*;
use super::super::config_file_edit::{appl... |
rust_dataset_chunk_518662 | rust_dataset.txt | 518,662 | 512 | 34, 0x56)))
);
assert_eq!(
parse_colour("rgb(111, 222, 33)"),
Some(PaletteColor::Rgb((111, 222, 33)))
);
assert_eq!(
parse_colour("RGB(1 2 3)"),
Some(PaletteColor::Rgb((1, 2, 3)))
);
assert_eq!(parse_colour("rgb(5)"), None);
assert_eq!(parse_colour("rgb(300, 0... |
rust_dataset_chunk_518663 | rust_dataset.txt | 518,663 | 512 | let not_a_folder = dir.path().join("themes");
std::fs::write(¬_a_folder, "").unwrap();
let error = create_theme_file(¬_a_folder, "mine", &sample_palette(), None).unwrap_err();
assert!(error.contains("not a folder"));
}
const TWO_THEMES: &str = "themes {\n first {\n fg 1\n bg 2\n ... |
rust_dataset_chunk_518664 | rust_dataset.txt | 518,664 | 512 | is_err());
assert_eq!(delete_theme_from_file(&path, "second"), Ok(true));
assert!(!path.exists());
}
#[test]
fn theme_files_are_found_by_theme_name() {
let dir = tempfile::tempdir().unwrap();
std::fs::write(dir.path().join("both.kdl"), TWO_THEMES).unwrap();
std::fs::write(dir.path().join("broken.kd... |
rust_dataset_chunk_518665 | rust_dataset.txt | 518,665 | 512 | let colours = styling_colours(&styling);
assert_eq!(colours.len(), theme_slots().len());
assert_eq!(styling_from_colours(&colours), styling);
let mut without_frame = DEFAULT_STYLES;
without_frame.frame_unselected = None;
assert_eq!(
styling_from_colours(&styling_colours(&without_frame)),
... |
rust_dataset_chunk_518666 | rust_dataset.txt | 518,666 | 512 | 7; orange 8; cyan 9; black 10; white 11; }; }",
);
replace_config_blocks(
&mut config,
"env {\n}\nthemes {\n}\nplugins {\n other location=\"zellij:strider\"\n}",
)
.unwrap();
assert!(config.env.inner().is_empty());
assert!(config.themes.get_theme("mine").is_none());
assert... |
rust_dataset_chunk_518667 | rust_dataset.txt | 518,667 | 512 | assert_eq!(pane.len(), 3);
assert!(pane[1].is_separator());
}
#[test]
fn a_keybinding_change_is_written_as_a_keybinds_block() {
let text = keybind_change_kdl(
InputMode::Normal,
&key("Alt y"),
Some(&["NewTab".to_owned(), "SwitchToMode \"locked\"".to_owned()]),
)
.unwrap();
... |
rust_dataset_chunk_518668 | rust_dataset.txt | 518,668 | 512 | assert_eq!(
find(InputMode::Normal, "Alt u").source,
KeybindingSource::User
);
let unbound = find(InputMode::Normal, "Alt n");
assert!(unbound.unbound);
assert!(unbound.preset_actions.is_some());
assert!(!unbound.unsaved);
assert_eq!(
find(InputMode::Normal, "Alt h").... |
rust_dataset_chunk_518669 | rust_dataset.txt | 518,669 | 512 | , 2, 3], &[1, 9, 3]),
vec![ListEdit::Replace { index: 1, item: 9 }]
);
}
--- FILE: zellij/zellij-utils/src/input/unit/config_file_edit_test.rs ---
use super::super::actions::Action;
use super::super::config::Config;
use super::super::config_file_edit::*;
use super::super::config_settings::config_settings_... |
rust_dataset_chunk_518670 | rust_dataset.txt | 518,670 | 512 | ) in bind {
changes.bind(*mode, key(key_text), actions.clone());
}
let mut rebound = config.clone();
rebound.keybinds_layers.user.changes.compose(changes);
rebound.resolve_keybinds();
rebound
}
const COMMENTED_FILE: &str = "// my settings
// are here
mouse_mode false // I like it off
plug... |
rust_dataset_chunk_518671 | rust_dataset.txt | 518,671 | 512 | file:/tmp/plugin.wasm\"
}
/* block comment */
pane_frames true
"
);
let file = "pane_frames true\n";
let saved = load(file);
let mut runtime = reconfigure(&saved, "copy_on_select false");
let edits = edits_between(&load(file), &runtime);
assert_eq!(
apply_edits(Some(file), &edits, &runt... |
rust_dataset_chunk_518672 | rust_dataset.txt | 518,672 | 512 | "ui {\n pane_frames {\n border_style \"heavy\"\n }\n}\n"
);
}
#[test]
fn web_client_settings_go_inside_web_client() {
let file = "web_client {\n font \"monospace\"\n}\n";
let text = saved_text_after(file, |saved| {
reconfigure(saved, "web_client { font_size 14; font \"Fira C... |
rust_dataset_chunk_518673 | rust_dataset.txt | 518,673 | 512 | secondary=\"Alt\" {\n normal {\n bind \"Alt y\" { NewTab; }\n }\n}\n";
let text = saved_text_after(file, |saved| {
let mut runtime = reconfigure(saved, "keybinds preset=\"unlock-first\" primary=\"Ctrl\"");
runtime.keybinds_layers.user.secondary = None;
runtime.resolve_keybinds(... |
rust_dataset_chunk_518674 | rust_dataset.txt | 518,674 | 512 | unbind \"Alt n\"\n bind \"Alt u\" { NewTab; }\n }\n}\n";
let text = saved_text_after(file, |saved| {
let mut runtime = saved.clone();
let normal = runtime
.keybinds_layers
.user
.changes
.modes
.get_mut(&InputMode::Normal)
... |
rust_dataset_chunk_518675 | rust_dataset.txt | 518,675 | 512 | file = "keybinds {\n shared {\n bind \"Alt y\" { NewTab; }\n }\n}\n";
let text = saved_text_after(file, |saved| {
rebind(
saved,
&[],
&[(InputMode::Normal, "Alt y", actions_of("Detach;"))],
)
});
assert_eq!(
text,
"keybinds {\... |
rust_dataset_chunk_518676 | rust_dataset.txt | 518,676 | 512 | "Alt y", actions_of("Detach;"))],
)
});
assert_eq!(
text,
"keybinds {\n shared {\n unbind \"Alt y\"\n }\n normal {\n bind \"Alt y\" { Detach; }\n }\n}\n"
);
}
#[test]
fn a_key_bound_in_one_mode_keeps_a_top_level_unbind_of_another_key() {
let file = "ke... |
rust_dataset_chunk_518677 | rust_dataset.txt | 518,677 | 512 | tab {\n item \"Hi\" { NewTab; }\n }\n bar clear-defaults=true {\n item \"Only\" { NewTab; }\n }\n}\n"
);
}
fn temp_config(contents: Option<&str>) -> (tempfile::TempDir, std::path::PathBuf) {
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("config.kdl");
if ... |
rust_dataset_chunk_518678 | rust_dataset.txt | 518,678 | 512 | ";
let (_dir, path) = temp_config(Some(file));
let saved = load(file);
let runtime = reconfigure(&saved, "pane_frames false");
let outside = "// edited elsewhere\nmouse_mode false\ntheme \"nord\"\n";
std::fs::write(&path, outside).unwrap();
assert_eq!(
save_config_in_place(&path, Some(fi... |
rust_dataset_chunk_518679 | rust_dataset.txt | 518,679 | 512 | });
assert_eq!(
changed,
COMMENTED_FILE.replace("/tmp/plugin.wasm", "/tmp/other.wasm")
);
let removed = saved_text_after(COMMENTED_FILE, |saved| {
let mut runtime = saved.clone();
runtime.plugins.aliases.remove("my-plugin");
runtime
});
assert!(!removed.co... |
rust_dataset_chunk_518680 | rust_dataset.txt | 518,680 | 512 | reordered = saved_text_after(file, |saved| {
let mut runtime = saved.clone();
runtime.background_plugins.swap(0, 1);
runtime
});
assert_eq!(
reordered,
"load_plugins {\n \"zellij:about\"\n // first\n \"zellij:strider\"\n}\n"
);
let added = saved_text_aft... |
rust_dataset_chunk_518681 | rust_dataset.txt | 518,681 | 512 | clear-defaults=true {\n item \"B\" { NewPane; }\n // mine\n item \"A\" { NewTab; }\n }\n}\n"
);
let removed = saved_text_after(file, |saved| {
let mut runtime = saved.clone();
runtime.context_menu.pane.remove(1);
runtime
});
assert_eq!(
removed,
... |
rust_dataset_chunk_518682 | rust_dataset.txt | 518,682 | 512 | !(
text.contains("item \"Middle\" after=\"New tab\" { NewTab; }"),
"{}",
text
);
assert!(!text.contains("clear-defaults"), "{}", text);
}
#[test]
fn a_changed_default_item_is_written_as_an_item_with_its_label() {
let text = saved_text_after(BAR_FILE, |saved| {
let mut runtim... |
rust_dataset_chunk_518683 | rust_dataset.txt | 518,683 | 512 | menu_item("Mine");
runtime
});
assert_eq!(
text,
"context_menu {\n tab {\n remove \"Gone\"\n // mine\n item \"Mine\" { NewTab; }\n }\n}\n"
);
}
#[test]
fn a_merged_section_back_at_the_defaults_is_removed() {
let text = saved_text_after(BAR_FILE, |save... |
rust_dataset_chunk_518684 | rust_dataset.txt | 518,684 | 512 | _text_after(THEME_FILE, |saved| {
let mut runtime = saved.clone();
let theme = runtime.themes.get_theme("mine").unwrap().clone();
runtime.themes.insert("copy".to_owned(), theme);
runtime
});
assert!(
added.starts_with(&THEME_FILE[..THEME_FILE.len() - 2]),
"{}",
... |
rust_dataset_chunk_518685 | rust_dataset.txt | 518,685 | 512 | let file = "context_menu {\n pane clear-defaults=true {\n item \"A\" { NewTab; }\n item \"B\" { NewTab; }\n }\n}\n";
let (_dir, path) = temp_config(Some(file));
let saved = load(file);
let mut runtime = saved.clone();
runtime.context_menu.pane.push(menu_item("C"));
let outsid... |
rust_dataset_chunk_518686 | rust_dataset.txt | 518,686 | 512 | \"New tab\"\n }\n}\n"
);
}
#[test]
fn an_overwrite_save_keeps_a_plugin_loaded_outside() {
let file = "load_plugins {\n \"zellij:strider\"\n}\n";
let (_dir, path) = temp_config(Some(file));
let saved = load(file);
let mut runtime = saved.clone();
let mut more = load("load_plugins { \"zell... |
rust_dataset_chunk_518687 | rust_dataset.txt | 518,687 | 512 | ();
assert!(
contents.contains(&format!("COPIED TO: {}\n", first_copy.display())),
"{}",
contents
);
assert!(contents.contains("mouse_mode true"), "{}", contents);
let saved = load(&contents);
let runtime = reconfigure(&saved, "mouse_mode false");
written(save_config_in_p... |
rust_dataset_chunk_518688 | rust_dataset.txt | 518,688 | 512 | _after(file, |saved| {
reconfigure(saved, "terminal { theme { red \"#0a0b0c\"; }; }")
});
assert_eq!(
text,
"terminal {\n theme {\n red \"#0a0b0c\"\n }\n}\n"
);
}
#[test]
fn a_shorter_window_key_list_drops_the_extra_keys() {
let file = "terminal {\n paste_keys \"... |
rust_dataset_chunk_518689 | rust_dataset.txt | 518,689 | 512 | IAS_FILE, |saved| {
with_alias_option(saved, "zjhints", "overflow_str", Some(" "))
});
assert_eq!(
text,
ALIAS_FILE.replace("overflow_str \"...\"", "overflow_str \" \"")
);
}
#[test]
fn a_changed_alias_option_keeps_its_trailing_comment_and_integer_literal() {
let text = saved_te... |
rust_dataset_chunk_518690 | rust_dataset.txt | 518,690 | 512 | ider\"",
"other location=\"zellij:about\""
)
);
}
fn with_alias_cwd(config: &Config, cwd: Option<&str>) -> Config {
let mut runtime = config.clone();
runtime
.plugins
.aliases
.get_mut("my-plugin")
.unwrap()
.initial_cwd = cwd.map(std::path::PathB... |
rust_dataset_chunk_518691 | rust_dataset.txt | 518,691 | 512 | \"ignored by the parser\"\n }\n}\n"
);
}
#[test]
fn an_alias_without_children_gets_a_block_for_its_first_option_and_keeps_it_when_emptied() {
let added = saved_text_after(COMMENTED_FILE, |saved| {
with_alias_option(saved, "my-plugin", "a", Some("1"))
});
assert_eq!(
added,
C... |
rust_dataset_chunk_518692 | rust_dataset.txt | 518,692 | 512 | list \"a\" \"b\"\n nested { x 1; }\n b \"2\"\n }\n}\n";
let text = saved_text_after(file, |saved| {
with_alias_option(saved, "my-plugin", "b", Some("3"))
});
assert_eq!(text, file.replace("b \"2\"", "b \"3\""));
}
#[test]
fn an_alias_in_two_plugins_blocks_is_edited_at_its_first_oc... |
rust_dataset_chunk_518693 | rust_dataset.txt | 518,693 | 512 | [0] {
plugin.configuration.insert("a", "9");
}
runtime
});
assert_eq!(text, file.replace("a \"1\"", "a \"9\""));
}
#[test]
fn a_swapped_load_plugins_entry_keeps_the_block_indentation() {
let file = "load_plugins {\n \"zellij:strider\"\n}\n";
let text = saved_text_after(file... |
rust_dataset_chunk_518694 | rust_dataset.txt | 518,694 | 512 | ),
default_shell: Some(PathBuf::from("/bin/fish")),
default_cwd: Some(PathBuf::from("/tmp/work")),
default_layout: Some(PathBuf::from("compact")),
layout_dir: Some(PathBuf::from("/tmp/layouts")),
theme_dir: Some(PathBuf::from("/tmp/themes")),
keybinds_dir: Some(PathBuf::f... |
rust_dataset_chunk_518695 | rust_dataset.txt | 518,695 | 512 | (true),
context_menu_enabled: Some(false),
osc133_command_selection: Some(false),
word_separators: Some("[]".to_owned()),
host_notification_protocol: Some(HostNotificationProtocol::Osc99),
web_server_ip: Some("127.0.0.2".parse().unwrap()),
web_server_port: Some(9000),
... |
rust_dataset_chunk_518696 | rust_dataset.txt | 518,696 | 512 | terminal {
font \"Iosevka Term\"
font_bold \"Iosevka Term Bold\"
font_italic \"Iosevka Term Italic\"
font_bold_italic \"Iosevka Term Bold Italic\"
font_size 13.5
font_weight 500
system_fonts false
ligatures false
font_features \"calt\" \"ss01\"
cursor_style \"bar\"
cursor_bli... |
rust_dataset_chunk_518697 | rust_dataset.txt | 518,697 | 512 | bright_black 80 80 80
bright_red 255 80 80
bright_green 80 255 80
bright_yellow 255 255 80
bright_blue 80 80 255
bright_magenta 255 80 255
bright_cyan 80 255 255
bright_white 255 255 255
}
}
";
pub(crate) fn every_window_setting_set() -> TerminalConfig {
... |
rust_dataset_chunk_518698 | rust_dataset.txt | 518,698 | 512 | Some(crate::input::attention::StartupCard::Never),
tray_icon: Some(false),
enabled: Some(false),
desktop_notifications: crate::input::attention::StatusMap {
needs_you: Some(true),
failed: Some(false),
done: Some(true),
... |
rust_dataset_chunk_518699 | rust_dataset.txt | 518,699 | 512 | .get("pane_frames"))
.and_then(|pane_frames| pane_frames.children())
.unwrap();
for node in pane_frames.nodes() {
names.insert((SettingSection::PaneFrames, node.name().value().to_owned()));
}
let web_client = document
.get("web_client")
.and_then(|web_client| web_clie... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.