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_516400
rust_dataset.txt
516,400
512
)])); } fn kitty_records(frame: &DeliveredFrame) -> (bool, usize, usize) { use zellij_utils::structured_render::GraphicsRecord; let cleared = frame .graphics .iter() .any(|record| matches!(record, GraphicsRecord::Clear)); let residencies = frame .graphics .iter() ...
rust_dataset_chunk_516401
rust_dataset.txt
516,401
512
!(repaint.full_repaint); let (cleared, residencies, placements) = kitty_records(&repaint); assert!( residencies > 0 && placements > 0, "a full repaint wipes the client's images, so they must be sent again (cleared: {}), got {:?}", cleared, repaint.graphics ); } fn screen_wit...
rust_dataset_chunk_516402
rust_dataset.txt
516,402
512
let (mut screen, plugin_receiver) = screen_with_session_card(61); assert!(screen.popup_to_floating_pane(61, None)); let tab = screen.get_active_tab(client_id).unwrap(); assert!(!tab.has_popup_for_client(client_id)); assert!(tab.are_floating_panes_visible()); assert!(tab.get_pane_with_id(PaneId::Plu...
rust_dataset_chunk_516403
rust_dataset.txt
516,403
512
, _)| match instruction { PluginInstruction::KeybindPipe { name, plugin_and_client_id: Some((target, _)), .. } if target == plugin_id => Some(name), _ => None, }) .collect() } #[test] fn f9_focuses_an_unfocused_session_...
rust_dataset_chunk_516404
rust_dataset.txt
516,404
512
_geometry(121, 20); assert_eq!((x, y, width, height), (15, 2, 90, 15)); assert_eq!( loaded, vec![( Some(true), Some(true), Some(crate::screen::popups::SESSION_MANAGER_ROLE.to_owned()), Some( zellij_utils::data::FloatingPaneCoordinat...
rust_dataset_chunk_516405
rust_dataset.txt
516,405
512
Default::default()), ("other".to_owned(), busy), ], )); let told: Vec<GlobalAttention> = plugin_receiver .try_iter() .filter_map(|(instruction, _)| match instruction { PluginInstruction::GlobalAttentionUpdate(global) => Some(global), _ => None, ...
rust_dataset_chunk_516406
rust_dataset.txt
516,406
512
Job, ErrorContext)> { let (to_background_jobs, background_jobs_receiver): ChannelWithContext< crate::background_jobs::BackgroundJob, > = channels::unbounded(); screen.bus.senders.to_background_jobs = Some(SenderWithContext::new(to_background_jobs)); background_jobs_receiver } fn command_submitt...
rust_dataset_chunk_516407
rust_dataset.txt
516,407
512
assert_eq!( command_submitted_reports(&plugin_receiver, &background_jobs_receiver), (0, 0) ); screen.set_popup_focused(66, false); while plugin_receiver.try_recv().is_ok() {} screen.terminal_input_submitted(client_id); assert!(screen.terminal_command_submitted); assert_eq!( ...
rust_dataset_chunk_516408
rust_dataset.txt
516,408
512
1].active); assert!(focused .tabs .iter() .all(|tab| tab.panes.iter().all(|pane| pane.contents.is_none()))); assert!(focused.contents.contains("second pane text")); assert!(screen.get_active_tab(client_id).is_ok()); } #[test] fn typing_a_pane_name_with_clusters_and_backspace_removes...
rust_dataset_chunk_516409
rust_dataset.txt
516,409
512
_new_screen(size, true, true); let client_id = 1; new_tab(&mut screen, 1, 0); screen .update_active_tab_name("\0".as_bytes().to_vec(), client_id) .unwrap(); for c in "x\u{1F1E9}\u{1F1EA}".chars() { screen .update_active_tab_name(c.to_string().into_bytes(), client_id) ...
rust_dataset_chunk_516410
rust_dataset.txt
516,410
512
screen.render(None).expect("TEST"); let blocked = crate::attention::program_status::parse( &[b"7501", b"state=blocked:kind=permission"], false, ) .expect("TEST"); for tab in screen.tabs.values_mut() { if tab.has_terminal_pid(1) { tab.pending_pane_signals.push(( ...
rust_dataset_chunk_516411
rust_dataset.txt
516,411
512
3, new_tab_id); screen.render(None).expect("TEST"); screen.process_attention(); let new_tab = screen.tabs.get(&new_tab_id).expect("TEST"); assert!( !screen.tab_attention(new_tab).muted, "a freshly opened tab is reported as muted" ); } #[test] fn a_session_preview_with_an_anchor_inc...
rust_dataset_chunk_516412
rust_dataset.txt
516,412
512
_recv().is_ok() {} Harness { screen, plugin_receiver, } } fn shown_name(screen: &Screen, client_id: ClientId) -> Option<String> { screen .mode_info .get(&client_id) .and_then(|mode_info| mode_info.session_name.clone()) } ...
rust_dataset_chunk_516413
rust_dataset.txt
516,413
512
(), Some("zellij-test")); h.screen .change_mode(InputMode::Session, Some(InputMode::Normal), 1) .expect("TEST"); assert_eq!(h.screen.session_name, "zellij-test"); assert_eq!(shown_name(&h.screen, 1).as_deref(), Some("zellij-test")); assert!(prompts(&h).is_empty())...
rust_dataset_chunk_516414
rust_dataset.txt
516,414
512
let mut h = harness(); h.screen .change_mode(InputMode::RenameSession, Some(InputMode::Normal), 1) .expect("TEST"); h.screen .change_mode(InputMode::Normal, Some(InputMode::Normal), 1) .expect("TEST"); assert_eq!(h.screen.session_name, "zellij-tes...
rust_dataset_chunk_516415
rust_dataset.txt
516,415
512
.links().entries { self.links.insert(entry.id, entry.uri); } let clusters = view.clusters(); let mut written = 0; for (record, cells) in view.rows() { written += 1; for (offset, cell) in cells.iter().enumerate() { let at = record.y as u...
rust_dataset_chunk_516416
rust_dataset.txt
516,416
512
_str(&format!("plain line {}\r\n", i)), 1 => stream.push_str(&format!( "\u{1b}[31mred\u{1b}[0m and \u{1b}[1;44mbold {}\u{1b}[m\r\n", i )), 2 => stream.push_str(&format!("{} {}\r\n", "long ".repeat(12), i)), 3 => stream.push_str("漢字한국어カナ mix...
rust_dataset_chunk_516417
rust_dataset.txt
516,417
512
, client_id) { expected.apply(&frame); } assert!(shifted_frames > 0, "the client was never sent a row shift"); assert!( smallest_frame < size.rows, "a shifted frame must not resend every row" ); assert_eq!(client.screen(), expected.screen()); } fn session_events_for( me...
rust_dataset_chunk_516418
rust_dataset.txt
516,418
512
screen.subscribe_to_events(100, events_filter(false)); screen.log_and_report_session_state().unwrap(); screen.log_and_report_session_state().unwrap(); assert!(session_events_for(&messages, 100).is_empty()); } #[test] fn events_new_tab_emits_tab_created_and_pane_opened() { let size = Size { cols: 8...
rust_dataset_chunk_516419
rust_dataset.txt
516,419
512
clone(); assert_eq!(events[pane_closed.unwrap()]["tab_id"], closed_tab_id); } #[test] fn events_type_filter_is_applied() { let size = Size { cols: 80, rows: 20 }; let (mut screen, messages) = create_new_screen_with_message_capture(size); new_tab(&mut screen, 1, 0); screen.subscribe_to_events( ...
rust_dataset_chunk_516420
rust_dataset.txt
516,420
512
let previous_name = screen.session_name.clone(); screen.session_name = "renamed-session".to_owned(); screen.log_and_report_session_state().unwrap(); let events = session_events_for(&messages, 100); assert_eq!(event_names(&events), vec!["session_renamed"]); assert_eq!(events[0]["name"], "renamed...
rust_dataset_chunk_516421
rust_dataset.txt
516,421
512
!["session_ending"] ); let msgs = messages.lock().unwrap(); assert!(matches!( msgs.get(&100).unwrap().last(), Some(ServerToClientMsg::Exit { exit_reason: ExitReason::Normal }) )); drop(msgs); assert!(screen.event_subscribers.is_empty()); } #[test] fn events_m...
rust_dataset_chunk_516422
rust_dataset.txt
516,422
512
_layout.children_split_direction = SplitDirection::Vertical; initial_layout.children = (0..pane_count) .map(|_| TiledPaneLayout::default()) .collect(); let received_background_jobs = mock_screen.received_background_jobs.clone(); let screen_thread = mock_screen.run(Some(initial_layout), vec![...
rust_dataset_chunk_516423
rust_dataset.txt
516,423
512
_title_in_report(job, marker_terminal_id).as_deref() == Some(REPORT_MARKER) }) .count() - 1; let events = session_events_for(&mock_screen.os_input.server_to_client_messages, 100) .into_iter() .filter(|e| { e["event"] != "session_ending" && !(e["eve...
rust_dataset_chunk_516424
rust_dataset.txt
516,424
512
{ let run = run_with_event_listener( 2, vec![ScreenInstruction::TogglePaneEmbedOrEjectForPaneId( PaneId::Terminal(0), )], ); assert_eq!(run.reports_during_instructions, 1); assert!(event_names(&run.events).contains(&"pane_floating_changed".to_owned())); } #[test] fn...
rust_dataset_chunk_516425
rust_dataset.txt
516,425
512
], ); assert_eq!(run.reports_during_instructions, 0); assert!(run.events.is_empty(), "{:?}", run.events); } #[test] fn undoing_the_active_pane_rename_reports_only_when_the_title_changes() { let run = run_with_event_listener( 2, vec![ ScreenInstruction::UndoRenamePane...
rust_dataset_chunk_516426
rust_dataset.txt
516,426
512
); assert!(run.reports_during_instructions >= 2); assert!(event_names(&run.events).contains(&"pane_exited".to_owned())); } #[test] fn ordinary_writes_and_pastes_to_a_pane_do_not_report() { let run = run_with_event_listener( 2, vec![ ScreenInstruction::WriteToPaneId(b"ls\r".t...
rust_dataset_chunk_516427
rust_dataset.txt
516,427
512
enum Event { Print(char), Execute(u8), Hook(Vec<Vec<u16>>, usize, Vec<u8>, bool, char), Put(u8), Unhook, Osc(Vec<Vec<u8>>, bool), Csi(Vec<Vec<u16>>, usize, Vec<u8>, bool, char), Esc(Vec<u8>, bool, u8), } #[derive(Default)] struct Ours(Vec<Event>); fn groups_of(parameters: &crate::vt_pa...
rust_dataset_chunk_516428
rust_dataset.txt
516,428
512
0 << 17; self.0 } fn below(&mut self, n: usize) -> usize { (self.next() % n as u64) as usize } } fn random_stream(rng: &mut Rng, len: usize) -> Vec<u8> { let pieces: &[&[u8]] = &[ b"\x1b", b"[", b"]", b"P", b"X", b"^", b"_", ...
rust_dataset_chunk_516429
rust_dataset.txt
516,429
512
Vec<Event> { let mut ours = Ours::default(); let mut at = 0; for &end in splits.iter().chain(std::iter::once(&bytes.len())) { parser.feed(&mut ours, &bytes[at..end]); at = end; } ours.0 } fn feed_ours(bytes: &[u8], splits: &[usize]) -> Vec<Event> { feed_with(crate::vt_parser::P...
rust_dataset_chunk_516430
rust_dataset.txt
516,430
512
Digest::new(); add_events(&mut digest, events); digest.hex() } fn check_self_consistent(bytes: &[u8], rng: &mut Rng, label: &str) -> Vec<Event> { let whole = feed_ours(bytes, &[]); let mut anywhere = vec![]; let mut at = 0; while at < bytes.len() { at += 1 + rng.below(8); if at...
rust_dataset_chunk_516431
rust_dataset.txt
516,431
512
"\x1bP ", b"\x1bP1<", b"\x1bPq", b"\x1b]", b"\x1b]0;a", b"\x1bX", b"\xe6", b"\xe6\xbc", b"\xf0\x9f\x91", ]; let mut rng = Rng(42); let mut lines = vec![]; for prefix in prefixes { let mut digest = Digest::new(); for byte in ...
rust_dataset_chunk_516432
rust_dataset.txt
516,432
512
{} {}", name, digest_of(&events))); } golden::check("vt_parser_limits", &lines); } #[test] fn recorded_terminal_sessions_match_their_golden() { let mut rng = Rng(99); let mut lines = vec![]; for (name, bytes) in recorded_sessions() { let events = check_self_consistent(&bytes, &mut rng, &nam...
rust_dataset_chunk_516433
rust_dataset.txt
516,433
512
} } #[test] fn stopping_early_matches_its_golden() { let mut rng = Rng(1234); let mut lines = vec![]; let mut digest = Digest::new(); for case in 0..5000 { let len = 1 + rng.below(300); let bytes = random_stream(&mut rng, len); let stop_after = rng.below(6); let mut ours...
rust_dataset_chunk_516434
rust_dataset.txt
516,434
512
.overflowed; }, State::CsiEntry | State::CsiParam | State::CsiIntermediate | State::DcsEntry | State::DcsParam | State::DcsIntermediate => { situation.intermediates = parser.collected_count; situation.ignoring = parser.overflowed; ...
rust_dataset_chunk_516435
rust_dataset.txt
516,435
512
?} then {:#04x}", node.path, byte ); add_events(&mut digest, &ours.0[node.events.len()..]); edges += 1; } let mut parser = node.parser.clone(); let mut ours = Ours(node.events.clone()); parser.feed(&mut o...
rust_dataset_chunk_516436
rust_dataset.txt
516,436
512
|(low, high): (u8, u8)| [low, low + 1, low + (high - low) / 2, high - 1, high]; for lead in 0xe0..=0xf4u8 { for second in edges_of(second_range(lead)) { for third in 0..=255u8 { sequences.push(vec![lead, second, third]); } } } for lead in 0xf0..=0xf4u...
rust_dataset_chunk_516437
rust_dataset.txt
516,437
512
5); let mut lines = vec![]; let mut current: Vec<Vec<u8>> = vec![vec![]]; for length in 0..=6 { let mut digest = Digest::new(); let mut next = vec![]; for parameters in &current { let mut bytes = b"a\x1b[".to_vec(); bytes.extend_from_slice(parameters); ...
rust_dataset_chunk_516438
rust_dataset.txt
516,438
512
_eq!( feed_ours(bytes, &[split]), expected, "{:?} split at {}", label, split ); } assert_eq!( feed_with(crate::vt_parser::Parser::without_shortcuts(), bytes, &[]), expected, "{:?} without shortcuts", label );...
rust_dataset_chunk_516439
rust_dataset.txt
516,439
512
')], ); expect(b"\x1b[4:3m", &[csi(&[&[4, 3]], &[], false, 'm')]); } #[test] fn parameter_values_saturate_at_65535() { expect( b"\x1b[99999;65536m", &[csi(&[&[65535], &[65535]], &[], false, 'm')], ); } #[test] fn a_thirty_third_parameter_marks_the_sequence_overflowed() { let number...
rust_dataset_chunk_516440
rust_dataset.txt
516,440
512
ignores_the_sequence() { expect(b"\x1b[ 1pX", &text("X")); } #[test] fn controls_inside_a_csi_sequence_run_without_ending_it() { expect( b"\x1b[1\n2H", &[Event::Execute(b'\n'), csi(&[&[12]], &[], false, 'H')], ); } #[test] fn delete_inside_a_csi_sequence_is_ignored() { expect(b"\x1b[1\...
rust_dataset_chunk_516441
rust_dataset.txt
516,441
512
let numbers: Vec<String> = (0..20).map(|number| number.to_string()).collect(); let bytes = format!("\x1b]{}\x07", numbers.join(";")); let fields: Vec<&[u8]> = numbers[..16].iter().map(|field| field.as_bytes()).collect(); expect(bytes.as_bytes(), &[osc(&fields, true)]); } #[test] fn an_osc_string_drops_...
rust_dataset_chunk_516442
rust_dataset.txt
516,442
512
false, 'q'), Event::Unhook, esc(b"", false, b'\\'), ], ); } #[test] fn sos_pm_and_apc_strings_are_ignored() { for introducer in [b'X', b'^', b'_'] { let bytes = [&[0x1b, introducer][..], b"abc\x07\x1b\\X"].concat(); expect(&bytes, &[esc(b"", false, b'\\'), Event...
rust_dataset_chunk_516443
rust_dataset.txt
516,443
512
Ours::default(); parser.feed(&mut ours, b"a\xe6\xbc"); parser.feed(&mut ours, b"\xa2b"); assert_eq!(ours.0, text("a漢b")); } #[test] fn feeding_until_paused_stops_right_after_the_pausing_sequence() { let mut ours = StopOurs(Ours::default(), 1); let used = crate::vt_parser::Parser::new().feed_until_...
rust_dataset_chunk_516444
rust_dataset.txt
516,444
512
str) { self.print_str(text); } fn sgr(&mut self, parameter_bytes: &[u8]) { let parameters = Parameters::from_parameter_bytes(parameter_bytes); self.csi_dispatch(&Sequence::new(&parameters, &[], false, b'm')); } fn execute(&mut self, _control: u8) {} fn csi_dispatch(&mut se...
rust_dataset_chunk_516445
rust_dataset.txt
516,445
512
= 0; self.open_group = 0; } #[inline(always)] pub(crate) fn end_group(&mut self, value: u16) { self.continue_group(value); self.seal_group(); } #[inline(always)] pub(crate) fn seal_group(&mut self) { if self.open_group > 0 { self.group_lengths[self....
rust_dataset_chunk_516446
rust_dataset.txt
516,446
512
(Clone, Copy, Debug, Default, PartialEq, Eq)] enum State { #[default] Ground, Escape, EscapeIntermediate, CsiEntry, CsiParam, CsiIntermediate, CsiIgnore, DcsEntry, DcsParam, DcsIntermediate, DcsPassthrough, DcsIgnore, OscString, IgnoredString, } #[derive(Clon...
rust_dataset_chunk_516447
rust_dataset.txt
516,447
512
let width = utf8_width(lead); let mut unit = [0u8; 4]; let mut filled = self.carry_len; unit[..filled].copy_from_slice(&self.carry[..filled]); let mut taken = 0; while filled < width { let Some(&byte) = bytes.get(taken) else { self.carry[..fill...
rust_dataset_chunk_516448
rust_dataset.txt
516,448
512
[]; } while !remaining.is_empty() { let failure = str::from_utf8(remaining).err(); let valid_len = failure.map_or(remaining.len(), |failure| failure.valid_up_to()); dispatch_text( handler, unsafe { str::from_utf8_unchecked(&remaining[.....
rust_dataset_chunk_516449
rust_dataset.txt
516,449
512
, byte: u8) { match self.parameters.at_limit() { true => self.overflowed = true, false => self.number = accumulate(self.number, byte), } } #[inline(always)] fn parameter(&mut self) { match self.parameters.at_limit() { true => self.overflowed = tru...
rust_dataset_chunk_516450
rust_dataset.txt
516,450
512
) in fields.iter_mut().zip(self.osc.split(|&byte| byte == b';')) { *slot = field; count += 1; } handler.osc_end(&fields[..count], ended_by_bell); } #[inline(always)] fn step<H: Handler>(&mut self, handler: &mut H, byte: u8) { match self.state { St...
rust_dataset_chunk_516451
rust_dataset.txt
516,451
512
.subparameter(); self.state = State::CsiParam; }, b';' => { self.parameter(); self.state = State::CsiParam; }, 0x3c..=0x3f => { self.collect(byte); self.sta...
rust_dataset_chunk_516452
rust_dataset.txt
516,452
512
.hook(handler, byte), _ => {}, }, State::DcsParam => match byte { 0x20..=0x2f => { self.collect(byte); self.state = State::DcsIntermediate; }, b'0'..=b'9' => self.digit(byte), ...
rust_dataset_chunk_516453
rust_dataset.txt
516,453
512
=> { handler.unhook(); self.state = State::Ground; }, 0x7f => {}, 0x00..=0x7e => handler.put(byte), _ => {}, } } } fn utf8_width(lead: u8) -> usize { match lead { 0xc2..=0xdf => 2, 0xe0..=0xef => 3, ...
rust_dataset_chunk_516454
rust_dataset.txt
516,454
512
= 0x0101_0101_0101_0101; const HIGHS: u64 = 0x8080_8080_8080_8080; #[inline(always)] fn below_space_lanes(word: u64) -> u64 { word.wrapping_sub(ONES * 0x20) & !word } #[inline(always)] fn matching_lanes(word: u64, byte: u8) -> u64 { let matched = word ^ (ONES * byte as u64); matched.wrapping_sub(ONES) & ...
rust_dataset_chunk_516455
rust_dataset.txt
516,455
512
0xc2 => match bytes.get(at + 1) { Some(&next @ 0x80..=0x9f) => Some((next, 2)), _ => None, }, _ => None, }; match control { Some((code, length)) => { if run_start < at { handler.print_str(...
rust_dataset_chunk_516456
rust_dataset.txt
516,456
512
_to, write_reply, AppReply, AppRequest, }; use zellij_utils::consts::{APP_CONTROL_SOCKET_NAME, APP_LOCK_FILE_NAME}; use crate::app::control::ipc::{self, Listeners}; #[cfg_attr(windows, path = "instance/windows.rs")] #[cfg_attr(not(windows), path = "instance/unix.rs")] mod os; pub const HANDOFF_WAIT: Duration = D...
rust_dataset_chunk_516457
rust_dataset.txt
516,457
512
::Done) => wait_for_release(dir, wait), Ok(AppReply::Refused(reason)) => bail!("the older Zellij app did not close: {}", reason), Ok(other) => bail!( "the older Zellij app answered {:?} instead of closing", other ), Err(e) => bail!("the older Zellij app could not ...
rust_dataset_chunk_516458
rust_dataset.txt
516,458
512
, } = self; let guard = os::Guard::new(&control); spawn_answering(listeners, handle.clone())?; guard.start(&control, handle)?; Ok(Holder { _lock, control, guard, }) } } pub(crate) fn spawn_answering(listeners: Listeners, handle: Ha...
rust_dataset_chunk_516459
rust_dataset.txt
516,459
512
unwrap() { Claim::Handed(reply) => assert_eq!(reply, AppReply::Done), Claim::Primary(_) => panic!("a second instance must not start"), } assert_eq!( received.recv_timeout(Duration::from_secs(2)).unwrap(), wanted ); } #[test] fn a_panel...
rust_dataset_chunk_516460
rust_dataset.txt
516,460
512
socket"); }, Claim::Handed(_) => panic!("a dead app cannot take a request"), } } #[cfg(unix)] #[test] fn a_control_socket_replaced_by_another_process_is_made_again() { let dir = tempfile::TempDir::new().unwrap(); let instance = match claim(dir.path(), &r...
rust_dataset_chunk_516461
rust_dataset.txt
516,461
512
is running"); for (reported, older) in [ (None, false), (Some(zellij_utils::consts::VERSION), false), (Some("999.0.0"), false), (Some("0.0.1"), true), ] { let (holder, _) = serving(dir.path(), reported); assert_eq!( ...
rust_dataset_chunk_516462
rust_dataset.txt
516,462
512
create(true) .truncate(false) .write(true) .open(dir.path().join(APP_LOCK_FILE_NAME)) .unwrap(); held.lock().unwrap(); let started = Instant::now(); assert!(claim(dir.path(), &request(), Duration::from_millis(300)).is_err()); assert!(starte...
rust_dataset_chunk_516463
rust_dataset.txt
516,463
512
mut watch = match watch.lock() { Ok(watch) => watch, Err(poisoned) => poisoned.into_inner(), }; if watch.stopped { return; } let current = socket_identity(&control); if current.is_some() && current == watch.iden...
rust_dataset_chunk_516464
rust_dataset.txt
516,464
512
} /// Each connection that comes in, with the stream its answer goes back on. pub fn connections(self) -> impl Iterator<Item = (Stream, Stream)> { os::connections(self.listener, self.replies) } /// Each connection that comes in, with its own reply stream where the platform needs one. p...
rust_dataset_chunk_516465
rust_dataset.txt
516,465
512
pipe_pairs; pub struct Replies(Listener); impl Replies { pub fn bind(path: &Path) -> Result<Self> { zellij_utils::consts::ipc_bind_reply(path) .map(Replies) .with_context(|| format!("failed to listen on {}-reply", path.display())) } } /// A connection's request and reply pipes...
rust_dataset_chunk_516466
rust_dataset.txt
516,466
512
default() }) } pub fn detach_request() -> AppRequest { AppRequest::ShowPopup(PopupView::Quit) } fn pane_of(pane_id: Option<(u32, bool)>) -> Option<PaneId> { pane_id.map(|(id, plugin)| { if plugin { PaneId::Plugin(id) } else { PaneId::Terminal(id) } }) } ...
rust_dataset_chunk_516467
rust_dataset.txt
516,467
512
: Handler = Arc::new(handle); spawn_answering(listeners, handle)?; Ok(listening) } enum Asked { Answered(AppReply), Gone, Silent, } fn ask(socket: &Path, request: &AppRequest) -> Asked { let Ok((mut stream, mut reply_stream)) = ipc::connect(socket) else { return Asked::Gone; }; ...
rust_dataset_chunk_516468
rust_dataset.txt
516,468
512
, pane_id: Option<(u32, bool)>) -> bool { windows_in(dir) .into_iter() .find(|(_, window)| window.session.as_deref() == Some(session)) .map(|(socket, _)| { matches!( ask(&socket, &raise_request(session, pane_id)), Asked::Answered(AppReply::Done) ...
rust_dataset_chunk_516469
rust_dataset.txt
516,469
512
(), detach_request() ); drop(listening); assert!(windows_in(&windows).is_empty()); assert_eq!(std::fs::read_dir(&windows).unwrap().count(), 0); } #[cfg(unix)] #[test] fn a_socket_left_by_a_window_that_is_gone_is_removed_by_the_scan() { let dir = tempf...
rust_dataset_chunk_516470
rust_dataset.txt
516,470
512
<Watcher> { let (jobs, received) = channel(); let details = Arc::new(AtomicBool::new(details)); let live = Arc::new(Mutex::new(BTreeSet::new())); let listener = match AttentionListener::bind(&sock_dir, jobs.clone()) { Ok(listener) => Some(listener), Err(e) => { ...
rust_dataset_chunk_516471
rust_dataset.txt
516,471
512
_poll = Instant::now() + FOLDER_POLL; self.publish(&post); } else if now >= next_poll { let listed = self.listing(); if listed != self.listed { let added: Vec<String> = listed.difference(&self.listed).cloned().collect(); ...
rust_dataset_chunk_516472
rust_dataset.txt
516,472
512
{ let global = GlobalAttention::build( "", sessions .iter() .map(|(name, attention)| (name.clone(), attention.clone())) .collect(), ); let global = if details { global } else { global.without_command_text() }; let last_used = s...
rust_dataset_chunk_516473
rust_dataset.txt
516,473
512
_utils::consts::app_dir_in(sock_dir); zellij_utils::consts::prepare_private_dir(&app_dir) .with_context(|| format!("failed to create {}", app_dir.display()))?; let path = app_dir.join(zellij_utils::consts::APP_ATTENTION_SOCKET_NAME); if path.exists() { let _ = ipc::remove...
rust_dataset_chunk_516474
rust_dataset.txt
516,474
512
::push_session_attention_to; #[test] fn a_pushed_change_reaches_the_app_through_its_socket() { let dir = tempfile::TempDir::new().unwrap(); let (jobs, received) = channel(); let _listener = AttentionListener::bind(dir.path(), jobs).unwrap(); let socket = zellij_utils::consts::ap...
rust_dataset_chunk_516475
rust_dataset.txt
516,475
512
()); assert!(pull(&["zellij-terminal-no-such-session".to_owned()], true).is_empty()); } } --- FILE: zellij/zellij-terminal/src/app/desktop/bundle.rs --- #[cfg(target_os = "macos")] pub fn running_bundle_identifier() -> Option<String> { let bundle = objc2_foundation::NSBundle::mainBundle(); bundle....
rust_dataset_chunk_516476
rust_dataset.txt
516,476
512
()); self.write(&message); } fn write(&self, message: &Message) { let serial = { let mut serial = self.serial.lock().unwrap(); *serial += 1; *serial }; let _ = self .writer .lock() .unwrap() .wri...
rust_dataset_chunk_516477
rust_dataset.txt
516,477
512
super::BUS_PATH, BUS_SERVICE, "NameAcquired", vec![Value::str(":1.5")], ); acquired.sender = Some(BUS_SERVICE.to_owned()); self.write(&acquired); self.write(&Message::reply_to(...
rust_dataset_chunk_516478
rust_dataset.txt
516,478
512
(); std::thread::spawn(move || { for stream in listener.incoming() { let Ok(stream) = stream else { return; }; let served = accepting.clone(); std::thread::spawn(move || served.serve(stream)); } }...
rust_dataset_chunk_516479
rust_dataset.txt
516,479
512
let serial = self.next_serial(); let (sender, receiver) = std::sync::mpsc::channel(); self.shared.pending.lock().unwrap().insert(serial, sender); let _ = writer.lock().unwrap().write_all(&call.encode(serial)); let reply = receiver .recv_timeout(Duration::from_secs(5))...
rust_dataset_chunk_516480
rust_dataset.txt
516,480
512
GetId") => Some(vec![Value::str("0123456789abcdef")]), (WATCHER_SERVICE, "RegisterStatusNotifierItem") | (WATCHER_SERVICE, "RegisterStatusNotifierHost") => Some(vec![]), (super::PROPERTIES, "Get") if call.path.as_deref() == Some("/StatusNotifierWatcher") => ...
rust_dataset_chunk_516481
rust_dataset.txt
516,481
512
header = [0u8; 16]; if reader.read_exact(&mut header).is_err() { break; } let Ok(total) = Message::needed(&header) else { break; }; let mut bytes = header.to_vec(); bytes.resize(total, 0); if reader.read...
rust_dataset_chunk_516482
rust_dataset.txt
516,482
512
, Write}; use std::os::linux::net::SocketAddrExt; use std::os::unix::fs::MetadataExt; use std::os::unix::net::{SocketAddr, UnixStream}; use std::sync::atomic::{AtomicU32, Ordering}; use std::sync::mpsc::{channel, Sender}; use std::sync::{Arc, Mutex}; use std::time::Duration; use anyhow::{anyhow, bail, Result}; use su...
rust_dataset_chunk_516483
rust_dataset.txt
516,483
512
anyhow!("the bus writer is poisoned"))?; writer.write_all(&bytes)?; Ok(serial) } pub fn call(&self, message: Message, timeout: Duration) -> Result<Message> { let serial = self.next_serial(); let (sender, receiver) = channel(); self.pending .lock() ...
rust_dataset_chunk_516484
rust_dataset.txt
516,484
512
&str) -> bool { self.call( Message::call( BUS_SERVICE, BUS_PATH, BUS_SERVICE, "NameHasOwner", vec![Value::str(name)], ), Duration::from_secs(2), ) .ok() .and_then(|answer|...
rust_dataset_chunk_516485
rust_dataset.txt
516,485
512
_bytes())?; UnixStream::connect_addr(&address)? }, None => { let runtime = std::env::var("XDG_RUNTIME_DIR") .map_err(|_| anyhow!("no session bus address is known"))?; UnixStream::connect(format!("{}/bus", runtime))? }, }; Ok(stream) } ...
rust_dataset_chunk_516486
rust_dataset.txt
516,486
512
MethodReturn), 3 => Some(Kind::Error), 4 => Some(Kind::Signal), _ => None, } } } const FIELD_PATH: u8 = 1; const FIELD_INTERFACE: u8 = 2; const FIELD_MEMBER: u8 = 3; const FIELD_ERROR_NAME: u8 = 4; const FIELD_REPLY_SERIAL: u8 = 5; const FIELD_DESTINATION: u8 = 6; const ...
rust_dataset_chunk_516487
rust_dataset.txt
516,487
512
Return) } } pub fn error_to(call: &Message, name: &str, text: &str) -> Self { Message { reply_serial: Some(call.serial), destination: call.sender.clone(), error_name: Some(name.to_owned()), body: vec![Value::str(text)], ..Message::blan...
rust_dataset_chunk_516488
rust_dataset.txt
516,488
512
8; 16]) -> Result<usize, DecodeError> { let big_endian = match header[0] { b'l' => false, b'B' => true, _ => return Err(bad("a message with an unknown byte order")), }; let word = |bytes: &[u8]| { let word = [bytes[0], bytes[1], bytes[2], bytes[3]]...
rust_dataset_chunk_516489
rust_dataset.txt
516,489
512
); match *code { FIELD_PATH => message.path = text, FIELD_INTERFACE => message.interface = text, FIELD_MEMBER => message.member = text, FIELD_ERROR_NAME => message.error_name = text, FIELD_REPLY_SERIAL => message.reply_serial = ...
rust_dataset_chunk_516490
rust_dataset.txt
516,490
512
Bus, NOTIFICATIONS}; use super::*; use std::os::unix::net::UnixStream; use std::time::Duration; #[test] fn the_fake_session_bus_serves_every_connection_and_records_their_calls() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("bus"); let fake = FakeSessionBus::listen(&path); let fi...
rust_dataset_chunk_516491
rust_dataset.txt
516,491
512
Message::decode(&bytes).unwrap() } #[test] fn a_call_with_every_kind_of_value_survives_encoding() { let body = vec![ Value::str("zellij"), Value::U32(7), Value::Bool(true), Value::I32(-3), Value::I64(-9_000_000_000), Value::U64(9_000_000_000), Value::Doub...
rust_dataset_chunk_516492
rust_dataset.txt
516,492
512
!(reply.destination.as_deref(), Some(":1.9")); let error = roundtrip(&Message::error_to(&call, "a.b.Failed", "no")); assert_eq!(error.kind, Kind::Error); assert_eq!(error.error_name.as_deref(), Some("a.b.Failed")); assert_eq!(error.body, vec![Value::str("no")]); } #[test] fn a_signal_names_its_interfac...
rust_dataset_chunk_516493
rust_dataset.txt
516,493
512
_body("s", &[200, 0, 0, 0, b'a'], false).is_err()); let mut header = [0u8; 16]; header[0] = b'l'; header[4..8].copy_from_slice(&u32::MAX.to_le_bytes()); assert!(Message::needed(&header).is_err()); } #[test] fn a_bus_address_is_read_for_its_socket() { assert_eq!( bus_socket("unix:path=/run/u...
rust_dataset_chunk_516494
rust_dataset.txt
516,494
512
collect(), ) } pub fn bytes(bytes: &[u8]) -> Value { Value::Array( "y".to_owned(), bytes.iter().map(|b| Value::Byte(*b)).collect(), ) } pub fn dict(entries: Vec<(&str, Value)>) -> Value { Value::Array( "{sv}".to_owned(), e...
rust_dataset_chunk_516495
rust_dataset.txt
516,495
512
self { Value::I32(v) => Some(*v), Value::Variant(inner) => inner.as_i32(), _ => None, } } pub fn as_bool(&self) -> Option<bool> { match self { Value::Bool(v) => Some(*v), Value::Variant(inner) => inner.as_bool(), _ => None...
rust_dataset_chunk_516496
rust_dataset.txt
516,496
512
::I16, b'q' => Type::U16, b'i' => Type::I32, b'u' => Type::U32, b'x' => Type::I64, b't' => Type::U64, b'd' => Type::Double, b's' => Type::Str, b'o' => Type::Path, b'g' => Type::Sig, b'h' => Type::Unix...
rust_dataset_chunk_516497
rust_dataset.txt
516,497
512
.and_then(|types| types.first().map(Type::alignment)) .unwrap_or(1) } #[derive(Debug, Default)] pub struct Writer { pub(super) bytes: Vec<u8>, } impl Writer { pub fn new() -> Self { Writer::default() } pub fn into_bytes(self) -> Vec<u8> { self.bytes } pub(super) fn a...
rust_dataset_chunk_516498
rust_dataset.txt
516,498
512
=> self.raw_signature(v), Value::Array(element, items) => { self.align(4); let length_at = self.bytes.len(); self.bytes.extend_from_slice(&0u32.to_le_bytes()); self.align(alignment_of_signature(element)); let start = self.bytes...
rust_dataset_chunk_516499
rust_dataset.txt
516,499
512
.fixed::<4>()?)) } pub(super) fn string(&mut self) -> Result<String, DecodeError> { let length = self.u32()? as usize; let text = self.take(length)?; let text = std::str::from_utf8(text) .map_err(|_| bad("a string that is not UTF-8"))? .to_owned(); self.t...