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_517000 | rust_dataset.txt | 517,000 | 512 | = if is_up { arms.down } else { arms.up };
let junction = centered(h, junction_thickness(pen, arms.left, arms.right, weight));
if is_up {
let end = match &rows {
Some(rows) if horizontal_double && opposite == NONE => rows.first.1,
... |
rust_dataset_chunk_517001 | rust_dataset.txt | 517,001 | 512 | end = length * (index + 1) / count;
let (from, to) = (start + gap / 2, end - (gap - gap / 2));
if to <= from {
continue;
}
if horizontal {
let span = centered(h, thickness);
canvas.fill(from, span.0, to, span.1, OPAQUE);
} else {
l... |
rust_dataset_chunk_517002 | rust_dataset.txt | 517,002 | 512 | let distance = ((x - centre_x).powi(2) + (y - centre_y).powi(2)).sqrt();
(distance - radius).abs() <= half
});
let arc_end_x = centre_x.round() as i32;
if toward_right {
canvas.fill(arc_end_x, rows.0, w, rows.1, OPAQUE);
} else {
canvas.fill(0, rows.0, arc_end_x, rows.1,... |
rust_dataset_chunk_517003 | rust_dataset.txt | 517,003 | 512 | | {
let depth = if pointing_right { x } else { w - x };
let reach = w * (1.0 - (y - mid).abs() / mid);
if solid {
depth <= reach
} else {
let offset = (y - mid).abs();
let distance = (mid * depth + w * offset - w * mid).abs() / slope_length;
... |
rust_dataset_chunk_517004 | rust_dataset.txt | 517,004 | 512 | fn partial_blocks_grow_from_the_left_with_hard_edges() {
let metrics = metrics(8, 20);
let mut previous = 0;
for character in [
'\u{258f}', '\u{258e}', '\u{258d}', '\u{258c}', '\u{258b}', '\u{258a}', '\u{2589}',
] {
let bitmap = sprite(character, metrics);
... |
rust_dataset_chunk_517005 | rust_dataset.txt | 517,005 | 512 | metrics = metrics(9, 21);
for character in ['\u{2502}', '\u{2503}', '\u{2551}', '\u{253c}', '\u{256c}'] {
let bitmap = sprite(character, metrics);
let top: Vec<u8> = (0..bitmap.width).map(|x| at(&bitmap, x, 0)).collect();
let bottom: Vec<u8> = (0..bitmap.width)
... |
rust_dataset_chunk_517006 | rust_dataset.txt | 517,006 | 512 | u{e0b0}', metrics);
assert_eq!((powerline.width, powerline.height), (10, 30));
}
#[test]
fn a_corner_lines_up_with_the_straight_lines_it_joins() {
let metrics = metrics(9, 21);
let corner = sprite('\u{250c}', metrics);
let horizontal = sprite('\u{2500}', metrics);
le... |
rust_dataset_chunk_517007 | rust_dataset.txt | 517,007 | 512 | 0) / 2;
let inside_y = (rows.first.1 + rows.second.0) / 2;
assert_eq!(at(&corner, inside_x as u32, inside_y as u32), 0);
assert_eq!(at(&corner, 8, rows.first.0 as u32), OPAQUE);
assert_eq!(at(&corner, 8, rows.second.0 as u32), OPAQUE);
assert_eq!(at(&corner, columns.first.0 as u3... |
rust_dataset_chunk_517008 | rust_dataset.txt | 517,008 | 512 | Role, SharedSender,
};
use crate::session::host_reply;
use crate::session::recorder::Recorder;
const MAX_CONSECUTIVE_UNDECODABLE: usize = 1000;
const STRUCTURED_GRACE: Duration = Duration::from_secs(2);
fn stale_server_error(grace: Duration, discarded: usize) -> anyhow::Error {
anyhow!(
"this session's ... |
rust_dataset_chunk_517009 | rust_dataset.txt | 517,009 | 512 | self) -> bool {
false
}
}
fn paste_shortcut_of(settings: &Settings) -> Option<String> {
crate::config::options::resolve(settings, None)
.paste_keys
.first()
.map(|key| key.to_string())
}
fn paste_support(settings: &Settings) -> ClientToServerMsg {
ClientToServerMsg::Clipboa... |
rust_dataset_chunk_517010 | rust_dataset.txt | 517,010 | 512 | if let Some(recorder) = recorder.as_mut() {
if let Err(e) = recorder.record(&msg) {
served.failure = Some(e.context("failed to record a message from the session"));
break;
}
}
match served.handle(msg) {
Ok(Flow::Continue) => {}... |
rust_dataset_chunk_517011 | rust_dataset.txt | 517,011 | 512 | (e) = send(sender, ClientToServerMsg::FontFamilies { families }) {
report!(
"the installed fonts could not be listed for the settings: {}",
e
);
}
}
Served {
sender,
geometry,
role,
... |
rust_dataset_chunk_517012 | rust_dataset.txt | 517,012 | 512 | nowledges_frames() {
match zellij_utils::structured_render::decode(&frame) {
Ok(view) => send(
self.sender,
ClientToServerMsg::RenderFrameAck {
seq: view.header().seq,
},
)?,
E... |
rust_dataset_chunk_517013 | rust_dataset.txt | 517,013 | 512 | .settings, self.theme_mode).paints;
}
fn refresh_paste_shortcut(&mut self) {
if self.can_paste && self.paste_shortcut != Some(paste_shortcut_of(&self.settings)) {
self.paste_shortcut = Some(paste_shortcut_of(&self.settings));
let _ = send(self.sender, paste_support(&self.setting... |
rust_dataset_chunk_517014 | rust_dataset.txt | 517,014 | 512 | witch_to) = switch_to {
return Ending::Switched(switch_to.clone());
}
match exit_reason {
Some(reason) => Ending::Exited(reason.clone()),
None => Ending::Lost,
}
}
#[cfg_attr(windows, path = "client_loop/console_events.rs")]
#[cfg_attr(not(windows), path = "client_loop/signals.rs")]... |
rust_dataset_chunk_517015 | rust_dataset.txt | 517,015 | 512 | (name);
true
}
}
fn background_query() -> ServerToClientMsg {
ServerToClientMsg::ForwardQueryToHost {
token: 1,
query_bytes: b"\x1b]11;?\x1b\\".to_vec(),
resolve_async: false,
}
}
fn answered_background(replies: &[ClientToServerMs... |
rust_dataset_chunk_517016 | rust_dataset.txt | 517,016 | 512 | {
name: "renamed".to_owned(),
});
side.send(background_query());
});
assert_eq!(sink.renames, vec!["renamed".to_owned()]);
}
#[test]
fn a_theme_mode_change_reaches_the_window_and_the_colors_a_pane_is_told() {
let mut options = options();
... |
rust_dataset_chunk_517017 | rust_dataset.txt | 517,017 | 512 | #[test]
fn the_installed_fonts_are_listed_to_the_session_once_attached() {
let families = vec!["Iosevka Term".to_owned(), "JetBrains Mono".to_owned()];
let mut options = options();
options.font_families = Some(families.clone());
let (_sink, replies) = driven(options, |_side| {});... |
rust_dataset_chunk_517018 | rust_dataset.txt | 517,018 | 512 | .unwrap();
let outcome = run(connection, options()).unwrap();
assert_eq!(outcome.render_count, 1);
assert_eq!(outcome.exit_reason, Some(ExitReason::NormalDetached));
let replies = &server.finish()[HANDSHAKE_MESSAGES..];
assert_eq!(
replies,
&[
... |
rust_dataset_chunk_517019 | rust_dataset.txt | 517,019 | 512 | let server = FakeServer::spawn(|side| {
side.expect(HANDSHAKE_MESSAGES);
side.send(ServerToClientMsg::ForwardQueryToHost {
token: 7,
query_bytes: b"\x1b]52;c;?\x1b\\".to_vec(),
resolve_async: true,
});
side.send(Serv... |
rust_dataset_chunk_517020 | rust_dataset.txt | 517,020 | 512 | let mut clipboard = crate::input::clipboard::Clipboard::in_memory();
clipboard.set("copied");
let mut options = options();
options.clipboard = Some(std::sync::Arc::new(std::sync::Mutex::new(clipboard)));
options.allow_remote_clipboard_read = allow_remote_clipboard_read;
... |
rust_dataset_chunk_517021 | rust_dataset.txt | 517,021 | 512 | \x1b\\".to_vec();
assert_eq!(clipboard_reply_over(false, false), copied);
assert!(!clipboard_reply_over(true, false)
.windows(b"Y29waWVk".len())
.any(|w| w == b"Y29waWVk"));
assert_eq!(clipboard_reply_over(true, true), copied);
}
#[test]
fn a_server_that_only... |
rust_dataset_chunk_517022 | rust_dataset.txt | 517,022 | 512 | server.path,
"window-test",
geometry(),
Capabilities::default(),
)
.unwrap();
let outcome = run(connection, options()).unwrap();
assert_eq!(outcome.render_count, 1);
assert_eq!(outcome.exit_reason, None);
server.finish();
}
fn... |
rust_dataset_chunk_517023 | rust_dataset.txt | 517,023 | 512 | test]
fn the_window_is_told_when_the_server_is_too_old_to_draw_for_it() {
let ending = ending_for(
LoopOptions {
structured_grace: Duration::ZERO,
..options()
},
|side| {
side.send(ServerToClientMsg::Render {
... |
rust_dataset_chunk_517024 | rust_dataset.txt | 517,024 | 512 | SIGTERM};
use signal_hook::iterator::Signals;
std::thread::spawn(move || {
let mut signals = match Signals::new([SIGINT, SIGTERM]) {
Ok(signals) => signals,
Err(e) => {
report!("failed to install signal handler: {}", e);
return;
},
... |
rust_dataset_chunk_517025 | rust_dataset.txt | 517,025 | 512 | , PartialEq, Eq)]
pub struct Capabilities {
pub local_media: bool,
pub paints: Paints,
}
impl Default for Capabilities {
fn default() -> Self {
Self {
local_media: true,
paints: Paints::default(),
}
}
}
pub trait MessageSink: Send + Sync {
fn send_msg(&self,... |
rust_dataset_chunk_517026 | rust_dataset.txt | 517,026 | 512 | from the name; sessions from before ids are named after the session itself.
pub fn socket_path(session_name: &str) -> Result<PathBuf> {
let path = zellij_utils::consts::session_socket_path(session_name);
checked_socket_path(path)
}
/// The socket for a new session: registers the session under a fresh id and n... |
rust_dataset_chunk_517027 | rust_dataset.txt | 517,027 | 512 | {
supported: true,
row_shifts: false,
}],
};
for msg in declarations {
sender
.send_client_msg(msg)
.map_err(|e| anyhow!("failed to send capability message: {:?}", e))?;
}
Ok(Connection {
sender: Arc::new(IpcSink(Mutex::new(sender... |
rust_dataset_chunk_517028 | rust_dataset.txt | 517,028 | 512 | impl FnMut() -> std::io::Result<T>,
) -> std::io::Result<T> {
loop {
match attempt() {
Ok(value) => return Ok(value),
Err(e) => {
if Instant::now() >= deadline {
return Err(e);
}
thread::sleep(CONNECT_RETRY_INTERVAL... |
rust_dataset_chunk_517029 | rust_dataset.txt | 517,029 | 512 | _force_close) {
(Role::Participant, OnForceClose::Quit) => send(
sender,
ClientToServerMsg::Action {
action: on_force_close.into(),
terminal_id: None,
client_id: None,
is_cli_client: false,
},
),
... |
rust_dataset_chunk_517030 | rust_dataset.txt | 517,030 | 512 | &CliArgs::default(),
&Options::default(),
geometry.size(),
crate::session::spawn::advertised_host_terminal_env(),
None,
None,
None,
)
.message
}
fn attach_message(geometry: Geometry) -> ClientToServerMsg {
... |
rust_dataset_chunk_517031 | rust_dataset.txt | 517,031 | 512 | (ZELLIJ_SOCK_MAX_LENGTH);
assert!(socket_path(&long_name).is_err());
}
#[test]
fn socket_path_joins_the_contract_versioned_socket_dir() {
let path = socket_path("window-test").unwrap();
assert!(path.starts_with(&*zellij_utils::consts::ZELLIJ_SOCK_DIR));
assert_eq!(path.file_... |
rust_dataset_chunk_517032 | rust_dataset.txt | 517,032 | 512 | }
#[test]
fn a_resurrection_starts_the_session_from_the_layout_it_left_behind() {
let layout_path = session_layout_cache_file_name("window-test");
let info = ClientInfo::Resurrect(
"window-test".to_owned(),
layout_path.clone(),
false,
Some(Pat... |
rust_dataset_chunk_517033 | rust_dataset.txt | 517,033 | 512 | );
let received = server.finish();
match &received[0] {
ClientToServerMsg::FirstClientConnected {
cli_assets,
is_web_client,
} => {
assert_eq!(cli_assets.cwd, Some(PathBuf::from("/tmp/project")));
assert_eq!(cli_ass... |
rust_dataset_chunk_517034 | rust_dataset.txt | 517,034 | 512 | pixel_dimensions: next.pixel_dimensions()
},
]
);
}
#[test]
fn a_cell_metric_change_alone_sends_only_the_pixel_dimensions() {
let server = FakeServer::spawn(|side| side.expect(9));
let connection = attach_at(&server.path, test_geometry()).unwrap();
... |
rust_dataset_chunk_517035 | rust_dataset.txt | 517,035 | 512 | ().unwrap(),
ClientToServerMsg::Key { key, .. } if key.bare_key == BareKey::Esc
),
"got {:?}",
received.last()
);
}
#[test]
fn detach_is_requested_as_a_typed_action() {
let server = FakeServer::spawn(|side| side.expect(9));
let con... |
rust_dataset_chunk_517036 | rust_dataset.txt | 517,036 | 512 | -terminal/src/session/fixture.rs ---
use serde::{Deserialize, Serialize};
use zellij_utils::ipc::ServerToClientMsg;
pub const FIXTURE_FORMAT_VERSION: u32 = 1;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct Header {
pub format_version: u32,
pub contract_version: usize,
pub session: S... |
rust_dataset_chunk_517037 | rust_dataset.txt | 517,037 | 512 | Query::DefaultForeground => {
format!("\x1b]10;{}", xparse_color(paints.foreground)).into_bytes()
},
Query::DefaultBackground => {
format!("\x1b]11;{}", xparse_color(paints.background)).into_bytes()
},
Query::PaletteRegister(index) => {
format!... |
rust_dataset_chunk_517038 | rust_dataset.txt | 517,038 | 512 | answer(query, geometry(), &Paints::default(), None)
}
#[test]
fn the_text_area_size_is_answered_in_pixels() {
assert_eq!(answered(b"\x1b[14t"), b"\x1b[4;800;1200t");
}
#[test]
fn the_cell_size_is_answered_from_the_measured_font_metrics() {
assert_eq!(answered(b"\x1b[16t"), b"\... |
rust_dataset_chunk_517039 | rust_dataset.txt | 517,039 | 512 | 1b]11;?\x07"),
b"\x1b]11;rgb:0000/0000/0000\x07"
);
assert_eq!(
answered(b"\x1b]4;0;?\x07"),
b"\x1b]4;0;rgb:0000/0000/0000\x07"
);
}
#[test]
fn the_answers_agree_with_the_palette_seeded_at_attach() {
for index in 0u8..=255 {
le... |
rust_dataset_chunk_517040 | rust_dataset.txt | 517,040 | 512 | ::Clipboard::in_memory();
clipboard.set("copied");
let handle = Arc::new(Mutex::new(clipboard));
assert_eq!(
answer(
b"\x1b]52;c;?\x1b\\",
geometry(),
&Paints::default(),
Some(&handle)
),
b"\x1b]5... |
rust_dataset_chunk_517041 | rust_dataset.txt | 517,041 | 512 | _count: usize,
}
impl Recorder {
pub fn create(path: &Path, session: &str, geometry: Geometry) -> Result<Self> {
if let Some(parent) = path.parent() {
if !parent.as_os_str().is_empty() {
std::fs::create_dir_all(parent)
.with_context(|| format!("failed to crea... |
rust_dataset_chunk_517042 | rust_dataset.txt | 517,042 | 512 | _width: 10,
cell_height: 20,
}
}
fn record_all(msgs: &[ServerToClientMsg]) -> (TempDir, Vec<Value>) {
let dir = TempDir::new().unwrap();
let path = dir.path().join("nested").join("fixture.jsonl");
let mut recorder = Recorder::create(&path, "window-test", geometry()).... |
rust_dataset_chunk_517043 | rust_dataset.txt | 517,043 | 512 | _round_trip_byte_for_byte() {
let content = "\u{1b}[?25l\u{1b}[1;31mRED\u{1b}[m \u{1b}]8;;\u{1b}\\ \u{9b}odd\u{7f}";
let msgs = vec![ServerToClientMsg::Render {
content: content.to_owned(),
}];
let (_dir, records) = record_all(&msgs);
let decoded: ServerToClientMsg = ... |
rust_dataset_chunk_517044 | rust_dataset.txt | 517,044 | 512 | ";
pub const ADVERTISED_TERM_PROGRAM: &str = "zellij";
const SOCK_DIR_PERMISSIONS: u32 = 0o700;
pub const LAUNCHING_SESSION_VARS: [&str; 4] = [
ZELLIJ_ENV_KEY,
SESSION_NAME_ENV_KEY,
SESSION_ID_ENV_KEY,
"ZELLIJ_PANE_ID",
];
pub const FOREIGN_TERMINAL_VARS: [&str; 22] = [
"TERM_PROGRAM",
"TERM_... |
rust_dataset_chunk_517045 | rust_dataset.txt | 517,045 | 512 | env::vars_os()
.filter_map(|(name, value)| Some((name.into_string().ok()?, value.into_string().ok()?)))
.filter(|(name, _)| !belongs_to_the_launch(name))
.collect()
}
pub fn inherit_launcher_env(launch: &mut ServerLaunch, launcher: &BTreeMap<String, String>) {
if launcher.is_empty() {
... |
rust_dataset_chunk_517046 | rust_dataset.txt | 517,046 | 512 | > {
std::env::current_exe()
.map(PathBuf::into_os_string)
.context("failed to locate this executable, which is also the session server")
}
pub fn server_command(
program: OsString,
socket_path: &Path,
session_name: &str,
cwd: &Path,
) -> ServerLaunch {
let mut launch = ServerLau... |
rust_dataset_chunk_517047 | rust_dataset.txt | 517,047 | 512 | zellij_client::spawn_server_with(launch).map_err(|e| {
anyhow!(
"{:?} could not be run or exited early, so the session server did not start: {}",
launch.program,
e
)
})
}
#[cfg(test)]
mod tests {
use super::*;
fn command() -> ServerLaunch {
s... |
rust_dataset_chunk_517048 | rust_dataset.txt | 517,048 | 512 | ".to_owned()),
(SESSION_ID_ENV_KEY.to_owned(), "launching".to_owned()),
]);
inherit_launcher_env(&mut launch, &launcher);
assert_eq!(
launch.env.keys().map(String::as_str).collect::<Vec<_>>(),
vec![
"COLORTERM",
"PROJECT",
... |
rust_dataset_chunk_517049 | rust_dataset.txt | 517,049 | 512 | #[test]
fn a_server_started_for_a_launch_gets_the_launcher_environment_instead_of_the_app_one() {
let mut launch = command();
let launcher = BTreeMap::from([
("PROJECT".to_owned(), "api".to_owned()),
("TERM".to_owned(), "dumb".to_owned()),
(
SESSI... |
rust_dataset_chunk_517050 | rust_dataset.txt | 517,050 | 512 | _TERMINAL".to_owned(), "1".to_owned()),
])
);
}
#[test]
fn the_advertised_environment_asks_the_session_for_the_richer_notification_protocol() {
use zellij_server::notifications::NotificationProtocol;
use zellij_utils::input::options::HostNotificationProtocol;
as... |
rust_dataset_chunk_517051 | rust_dataset.txt | 517,051 | 512 | .unwrap_err()
.to_string();
assert!(err.contains("did not start"), "{}", err);
}
}
--- FILE: zellij/zellij-terminal/src/session/terminal_request.rs ---
use std::path::{Path, PathBuf};
use std::time::{Duration, Instant};
use anyhow::{anyhow, bail, Result};
use zellij_utils::app_control::{
... |
rust_dataset_chunk_517052 | rust_dataset.txt | 517,052 | 512 | == TerminalRequests::ExistingSession {
if let Some(session) = focused_session() {
match open_tab(&session, waited) {
Ok(pane) => {
let raise = OpenWindowRequest {
session: Some(session.clone()),
create: false,
... |
rust_dataset_chunk_517053 | rust_dataset.txt | 517,053 | 512 | session_answers(name, Duration::from_millis(500)) {
return true;
}
std::thread::sleep(POLL);
}
false
}
fn send_and_collect(session: &str, action: Action) -> Result<Vec<String>> {
let mut link = SessionLink::open(session).map_err(|e| anyhow!("{}", e))?;
link.send(cli_message... |
rust_dataset_chunk_517054 | rust_dataset.txt | 517,054 | 512 | true,
show_geometry: false,
show_all: false,
output_json: true,
},
)?;
let text = lines.join("\n");
let parsed: serde_json::Value = serde_json::from_str(&text)
.map_err(|e| anyhow!("the pane list could not be read: {}", e))?;
Ok(parsed.as_array().clon... |
rust_dataset_chunk_517055 | rust_dataset.txt | 517,055 | 512 | if !hold {
let _ = send_and_collect(
session,
Action::CloseFocusByPaneId {
pane_id: PaneId::Terminal(pane),
},
);
}
code
}
fn exit_code_of(session: &str, pane: u32) -> Result<i32> {
let mut link = SessionLink::open(session).map_err(|e| an... |
rust_dataset_chunk_517056 | rust_dataset.txt | 517,056 | 512 | a shell pane is never mistaken for the command"
);
}
}
--- FILE: zellij/zellij-terminal/src/testing/adversarial.rs ---
use zellij_server::panes::terminal_character::{
AnsiCode, AnsiStyledUnderline, CharacterStyles, NamedColor, RESET_STYLES,
};
pub const NAMED_COLORS: [NamedColor; 16] = [
NamedCol... |
rust_dataset_chunk_517057 | rust_dataset.txt | 517,057 | 512 | ::Undercurl),
("dotted-underline", AnsiStyledUnderline::Underdotted),
("dashed-underline", AnsiStyledUnderline::Underdashed),
] {
styles.push((
name.to_owned(),
base().underline(Some(AnsiCode::Underline(Some(variant)))),
));
}
styles.push((
"e... |
rust_dataset_chunk_517058 | rust_dataset.txt | 517,058 | 512 | ::NamedColor(NamedColor::BrightMagenta)),
("indexed", AnsiCode::ColorIndex(208)),
("rgb", AnsiCode::RgbCode((9, 8, 7))),
] {
styles.push((
format!("underline-color-{}", name),
base()
.underline(Some(AnsiCode::Underline(Some(
AnsiSty... |
rust_dataset_chunk_517059 | rust_dataset.txt | 517,059 | 512 | last_row = rows - 1;
let last_col = cols - 1;
vec![
(
"wide-char-then-narrow-over-its-tail".to_owned(),
format!("{}\u{4f60}{}x", goto(0, 0), goto(0, 1)),
),
(
"wide-char-then-narrow-over-its-head".to_owned(),
format!("{}\u{4f60}{}x", goto(... |
rust_dataset_chunk_517060 | rust_dataset.txt | 517,060 | 512 | b}[?25h", goto(0, 0)),
),
(
"control-bytes-embedded-in-a-chunk".to_owned(),
format!("{}a\u{7}b\u{0}c", goto(0, 0)),
),
(
"every-cell-of-every-row-is-written".to_owned(),
(0..rows)
.map(|row| format!("{}{}", goto(row, 0), "\u... |
rust_dataset_chunk_517061 | rust_dataset.txt | 517,061 | 512 | \u{1b}[2@\u{1b}[1;1H\u{1b}[1P".to_owned(),
),
("a-repeated-character".to_owned(), "z\u{1b}[40b".to_owned()),
]
}
pub fn application_attribute_streams() -> Vec<(String, String)> {
let mut streams = vec![
("bold".to_owned(), "\u{1b}[1m".to_owned()),
("dim".to_owned(), "\u{1b}[2m".... |
rust_dataset_chunk_517062 | rust_dataset.txt | 517,062 | 512 | bg-rgb".to_owned(), "\u{1b}[48;2;9;8;7m".to_owned()),
(
"underline-color-indexed".to_owned(),
"\u{1b}[4:3m\u{1b}[58:5:208m".to_owned(),
),
(
"underline-color-rgb".to_owned(),
"\u{1b}[4:3m\u{1b}[58:2::1:2:3m".to_owned(),
),
];
for (_... |
rust_dataset_chunk_517063 | rust_dataset.txt | 517,063 | 512 | ("\n")
);
}
#[test]
fn every_single_attribute_agrees() {
let styles = attribute_styles();
assert_agrees("attributes", ROWS, COLS, &styled_stream(&styles, COLS));
}
#[test]
fn every_color_form_agrees() {
for chunk in color_styles().chunks(ROWS) {
asse... |
rust_dataset_chunk_517064 | rust_dataset.txt | 517,064 | 512 | divergences.len(), 1);
assert_eq!(divergences[0].what, format!("cell 0,{}", COLS - 1));
assert!(divergences[0].actual.contains("LeadingSpacer"));
}
#[test]
fn a_stream_truncated_mid_sequence_and_resumed_agrees() {
let stream = format!("{}\u{1b}[1;31mred", goto(0, 0));
for sp... |
rust_dataset_chunk_517065 | rust_dataset.txt | 517,065 | 512 | 0].attrs.contains("blink-fast"),
"a fast-blink-only cell reaches the terminal still blinking"
);
assert_eq!(reference.project().cells[0][0].attrs.len(), 1);
let both = sgr(&base()
.blink_fast(Some(AnsiCode::On))
.blink_slow(Some(AnsiCode::On)));
let s... |
rust_dataset_chunk_517066 | rust_dataset.txt | 517,066 | 512 | ?}", mode);
}
}
#[test]
fn a_zwj_chain_longer_than_a_group_is_split_and_still_reaches_the_wire() {
let chain = vec!["\u{1f468}"; 40].join("\u{200d}");
let buffer = assert_grid_reaches_the_wire("zwj chain", 4, 100, &chain);
let mut longest = 0;
let mut run = 0;
... |
rust_dataset_chunk_517067 | rust_dataset.txt | 517,067 | 512 | seed ^= seed >> 7;
seed ^= seed << 17;
seed
};
let mut stream = String::new();
for row in 0..rows {
stream.push_str(&goto(row, 0));
for col in 0..cols {
stream.push(char::from(b'a' + (col % 26) as u8));
for _ in 0..... |
rust_dataset_chunk_517068 | rust_dataset.txt | 517,068 | 512 | ")
.join("fixtures")
}
pub fn stream_corpus() -> Result<Vec<PathBuf>> {
let dir = streams_dir();
let mut streams = Vec::new();
for entry in fs::read_dir(&dir).with_context(|| format!("reading {}", dir.display()))? {
let path = entry?.path();
if !path.is_file() {
continue... |
rust_dataset_chunk_517069 | rust_dataset.txt | 517,069 | 512 | (piece);
if let Some(frame) = emitter.frame() {
frames.push(frame);
}
}
if let Some(frame) = emitter.frame() {
frames.push(frame);
}
frames
}
pub fn window_of(frames: &[String], rows: usize, cols: usize) -> VteTerminal {
let mut state = VteTerminal::new(rows, col... |
rust_dataset_chunk_517070 | rust_dataset.txt | 517,070 | 512 | what, divergences.len())];
for divergence in divergences.iter().take(12) {
lines.push(divergence.describe());
}
if divergences.len() > 12 {
lines.push(format!("... and {} more", divergences.len() - 12));
}
lines.join("\n")
}
pub fn disagreement(reference: &Projection, state: &VteTe... |
rust_dataset_chunk_517071 | rust_dataset.txt | 517,071 | 512 | unwrap().to_str().unwrap(),
&divergences,
));
}
}
assert!(failures.is_empty(), "{}", failures.join("\n\n"));
}
#[test]
fn every_application_stream_round_trips_through_the_wire() {
let mut failures = Vec::new();
for path in stre... |
rust_dataset_chunk_517072 | rust_dataset.txt | 517,072 | 512 | (e) => failures.push(format!("{} frame {}: {}", name, index, e)),
}
}
}
assert!(failures.is_empty(), "{}", failures.join("\n"));
}
#[test]
fn a_payload_split_at_any_byte_boundary_agrees_with_the_reference() {
let bytes = fs::read(streams_dir().join("vttes... |
rust_dataset_chunk_517073 | rust_dataset.txt | 517,073 | 512 | }\u{e49}\u{e33} \u{1100}\u{1161}\u{11a8} \u{ff76}\u{ff9e} x\u{ad}y \u{17d8}|";
fn cluster_streams() -> Vec<(&'static str, String)> {
vec![
("default mode", format!("{}\r\n", CLUSTER_SAMPLES)),
("mode 2027", format!("\u{1b}[?2027h{}\r\n", CLUSTER_SAMPLES)),
]
}
#[tes... |
rust_dataset_chunk_517074 | rust_dataset.txt | 517,074 | 512 | _CHUNK);
let expected = reference_of(&frames, ROWS, COLS).project();
assert!(disagreement(&expected, &window_of(&frames, ROWS, COLS)).is_empty());
let joined = frames.concat();
let bytes = joined.as_bytes();
for split in (1..bytes.len()).filter(|split| joined.is_char_boundary(*sp... |
rust_dataset_chunk_517075 | rust_dataset.txt | 517,075 | 512 | testing::projection::DEFAULT_COLOR {
continue;
}
let kind = if color.starts_with('#') {
"rgb"
} else if color.starts_with("idx") {
"indexed"
... |
rust_dataset_chunk_517076 | rust_dataset.txt | 517,076 | 512 | ScreenBuffer,
seen: &mut BTreeSet<String>,
) {
if buffer.cluster_count() > 0 {
seen.insert("cluster record".to_owned());
}
let size = buffer.size();
for row in 0..size.rows {
for col in 0..size.cols {
if buffer.is_group_continuation(row... |
rust_dataset_chunk_517077 | rust_dataset.txt | 517,077 | 512 | );
if !against_alacritty.is_empty() {
failures.push(report(&format!("{} (alacritty)", name), &against_alacritty));
}
}
}
assert!(failures.is_empty(), "{}", failures.join("\n\n"));
}
#[test]
fn no_stream_wraps_a_line_in_the_wind... |
rust_dataset_chunk_517078 | rust_dataset.txt | 517,078 | 512 | si, frame)
},
};
self.ansi.advance(ansi.as_bytes());
self.alacritty.apply(&ansi);
let view = zellij_utils::structured_render::decode(&frame)
.expect("the server emitted a frame its own decoder rejects");
... |
rust_dataset_chunk_517079 | rust_dataset.txt | 517,079 | 512 | if split == 0 { bytes.len() / 2 } else { split };
let mut reflow = Reflow::new(uses_grapheme_mode(&bytes));
let (before, after) = bytes.split_at(resize_after.min(bytes.len()));
reflow.feed(before);
reflow.resize(rows, cols);
... |
rust_dataset_chunk_517080 | rust_dataset.txt | 517,080 | 512 | = VteTerminal::new(STREAM_ROWS, STREAM_COLS);
alacritty.apply_bytes(&bytes);
let stored = emitter.scrollback_len();
if stored != alacritty.history_len() {
failures.push(format!(
"{} scrolled {} rows out of the grid and {} out of alacritty, with n... |
rust_dataset_chunk_517081 | rust_dataset.txt | 517,081 | 512 | can only make \
the grid's scrollback the longer of the two",
name, grid, alacritty
));
}
},
(false, true) | (true, true) => {},
(false, false) => unexplained.push(format... |
rust_dataset_chunk_517082 | rust_dataset.txt | 517,082 | 512 | &mut crate::emulation::screen_buffer::ScreenBuffer,
) {
while let Some((_, frame)) = emitter.dialects() {
let frame = match frame {
zellij_server::output::RenderPayload::Frame(frame) => frame,
other => panic!("the structured dialect came out as {:?}", other),
... |
rust_dataset_chunk_517083 | rust_dataset.txt | 517,083 | 512 | (projections: impl Iterator<Item = Projection>) -> (BTreeSet<String>, usize) {
let mut attributes = BTreeSet::new();
let mut colors = BTreeSet::new();
for projection in projections {
for row in &projection.cells {
for cell in row {
for attr in &cel... |
rust_dataset_chunk_517084 | rust_dataset.txt | 517,084 | 512 | colors",
fixture_colors
);
}
#[test]
fn the_recorded_blink_capture_reaches_the_window_as_blinking_cells() {
let state = recorded_state(&fixtures_dir().join("blink.jsonl"));
assert!(state.has_blinking_cells());
let projection = crate::testing::equivalence::proje... |
rust_dataset_chunk_517085 | rust_dataset.txt | 517,085 | 512 | (), 2, "both modes print the accent line");
for (row, col) in accents {
assert_eq!(projection.cells[row][col + VALUE].text, "e\u{301}");
}
let families = labels_at(&projection, "FAMILY:");
assert_eq!(families.len(), 2, "both modes print the family line");
let (row, c... |
rust_dataset_chunk_517086 | rust_dataset.txt | 517,086 | 512 | }
fn cells_of<'a>(
projection: &'a Projection,
label: &str,
) -> Vec<&'a crate::testing::projection::Cell> {
for row in &projection.cells {
let text: String = row.iter().map(|cell| cell.text.as_str()).collect();
if let Some(at) = text.find(label) {
... |
rust_dataset_chunk_517087 | rust_dataset.txt | 517,087 | 512 | link on the nine cells of the word it wraps"
);
}
#[test]
fn a_hyperlink_round_trips_through_every_model() {
const URI: &str = "https://example.com/one";
let stream = format!(
"\u{1b}]8;id=1;{}\u{1b}\\linked\u{1b}]8;;\u{1b}\\ plain",
URI
);
... |
rust_dataset_chunk_517088 | rust_dataset.txt | 517,088 | 512 | .frame().into_iter().collect::<Vec<_>>();
let reference = reference_of(&frames, STREAM_ROWS, STREAM_COLS);
let divergences = compare(&emitter.project(), &reference.project());
if !divergences.is_empty() {
failures.push(report(&name, &divergences));
}
... |
rust_dataset_chunk_517089 | rust_dataset.txt | 517,089 | 512 | positions every chunk absolutely and must never \
rely on the client's autowrap",
path.display(),
wrapped
);
}
}
mod retention {
use super::*;
use crate::emulation::color::Paints;
use crate::emulation::damage::Damage;... |
rust_dataset_chunk_517090 | rust_dataset.txt | 517,090 | 512 | &mut self,
state: &TerminalState,
retained: &mut RetainedScene,
step: usize,
) {
match step % 5 {
0 => {},
1 => {
self.phase = match self.phase {
Blink... |
rust_dataset_chunk_517091 | rust_dataset.txt | 517,091 | 512 | None
}
fn cache() -> GlyphCache {
GlyphCache::new(FontStack::embedded(DEFAULT_FONT_SIZE).expect("no embedded font"))
}
fn walk(name: &str, rows: usize, cols: usize, frames: &[Vec<u8>]) -> Vec<String> {
let mut state = TerminalState::new(rows, cols);
... |
rust_dataset_chunk_517092 | rust_dataset.txt | 517,092 | 512 | usize) -> String {
format!(
"the {} diverge, {} retained against {} rebuilt",
what, retained, rebuilt
)
}
#[test]
fn every_recorded_fixture_retains_what_a_rebuild_would_produce() {
let mut failures = Vec::new();
fo... |
rust_dataset_chunk_517093 | rust_dataset.txt | 517,093 | 512 | SOR_SHAPE_DEFAULT,
];
fn random_cell(rng: &mut Rng) -> WireCell {
let mut attrs = 0u16;
for _ in 0..rng.below(3) {
attrs |= rng.pick(&ATTRS);
}
attrs |= (rng.below(6) as u16) << 8;
WireCell {
ch: rng.pick(&GLYPH... |
rust_dataset_chunk_517094 | rust_dataset.txt | 517,094 | 512 | *cols = 4 + rng.below(12);
}
let full = reshape || rng.chance(6);
let mut builder = FrameBuilder::new(*cols as u16, *rows as u16, seq);
builder.set_full_repaint(full);
if !full && rng.chance(10) {
builder.set_clear(true);
}
... |
rust_dataset_chunk_517095 | rust_dataset.txt | 517,095 | 512 | + rng.below(6), 8 + rng.below(12));
let mut frames = vec![{
let mut builder = FrameBuilder::new(cols as u16, rows as u16, 0);
builder.set_full_repaint(true);
builder.finish()
}];
for seq in 1..=60u64 {
... |
rust_dataset_chunk_517096 | rust_dataset.txt | 517,096 | 512 | WireCell, occupancy: Occupancy) -> Self {
Self {
fg: color(cell.fg, "Foreground"),
bg: color(cell.bg, "Background"),
underline_color: match WireColor::unpack(cell.underline_color) {
WireColor::Default => None,
_ => Some(color(cell.underline_co... |
rust_dataset_chunk_517097 | rust_dataset.txt | 517,097 | 512 | );
}
dumped
}
fn image_lines(state: &TerminalState) -> Vec<String> {
let graphics = state.graphics();
let mut lines = Vec::new();
for id in graphics.resident_ids() {
let Some(image) = graphics.image(id) else {
continue;
};
lines.push(format!(
"image... |
rust_dataset_chunk_517098 | rust_dataset.txt | 517,098 | 512 | {
lines.push(format!(
"row {}: cols {}-{} {}",
row,
run_start,
col - 1,
run_style.describe()
));
}
run_start = col;
if let Some(style) = style {
... |
rust_dataset_chunk_517099 | rust_dataset.txt | 517,099 | 512 | ED_UNDERLINE"),
UNDERLINE_DASHED => Some("DASHED_UNDERLINE"),
_ => None,
}
}
#[cfg(test)]
mod tests {
use super::*;
use zellij_utils::structured_render::{FrameBuilder, CURSOR_SHAPE_UNDERLINE};
fn state_of(rows: usize, cols: usize, paint: impl FnOnce(&mut FrameBuilder)) -> TerminalState... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.