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_516500
rust_dataset.txt
516,500
512
.ok_or_else(|| bad("an array longer than its message"))?; let mut items = vec![]; while self.at < end { items.push(self.value(element, depth + 1)?); } Value::Array(signature_of(element), items) }, ...
rust_dataset_chunk_516501
rust_dataset.txt
516,501
512
body: &[u8], big_endian: bool, ) -> Result<Vec<Value>, DecodeError> { let types = Type::parse_all(signature)?; let mut reader = Reader { bytes: body, at: 0, big_endian, }; let mut values = vec![]; for kind in &types { values.push(reader.value(kind, 0)?); }...
rust_dataset_chunk_516502
rust_dataset.txt
516,502
512
gba { fn blank(width: u32, height: u32) -> Self { Rgba { width, height, pixels: vec![0; (width * height * 4) as usize], } } #[cfg(test)] pub fn pixel(&self, x: u32, y: u32) -> [u8; 4] { let at = ((y * self.width + x) * 4) as usize; [ ...
rust_dataset_chunk_516503
rust_dataset.txt
516,503
512
[pixel[2], pixel[1], pixel[0], pixel[3]]); } out } } fn hexagon_contains(x: f32, y: f32, radius: f32) -> bool { let (dx, dy) = ((x - 0.5).abs(), (y - 0.5).abs()); let half_width = radius * 0.866_025_4; if dx > half_width { return false; } dy <= radius - dx * 0.577_350_3 ...
rust_dataset_chunk_516504
rust_dataset.txt
516,504
512
, 0.33) && !prompt_contains(x, y); ring || inner } #[derive(Debug, Clone, Copy, PartialEq)] struct PillShape { x: f32, y: f32, width: f32, height: f32, scale: u32, } impl PillShape { fn contains(&self, x: f32, y: f32, grow: f32) -> bool { let radius = self.height / 2.0 + grow; ...
rust_dataset_chunk_516505
rust_dataset.txt
516,505
512
0b111], '1' => [0b010, 0b110, 0b010, 0b010, 0b111], '2' => [0b111, 0b001, 0b111, 0b100, 0b111], '3' => [0b111, 0b001, 0b111, 0b001, 0b111], '4' => [0b101, 0b101, 0b111, 0b001, 0b001], '5' => [0b111, 0b100, 0b111, 0b001, 0b111], '6' => [0b111, 0b100, 0b111, 0b101, 0b111], ...
rust_dataset_chunk_516506
rust_dataset.txt
516,506
512
= left + index as u32 * 4 * scale; for (row, bits) in glyph(ch).iter().enumerate() { for column in 0..3u32 { if bits & (0b100 >> column) == 0 { continue; } for dy in 0..scale { for dx in 0..scale { ...
rust_dataset_chunk_516507
rust_dataset.txt
516,507
512
(sx as f32 + 0.5) * step; let py = y as f32 + (sy as f32 + 0.5) * step; if let Some(shape) = &shape { if shape.contains(px, py, 0.0) { pill += 1; continue; } ...
rust_dataset_chunk_516508
rust_dataset.txt
516,508
512
.clone())); image } } #[cfg(test)] mod tests { use super::*; fn calm() -> TrayLook { TrayLook { pill: None, dimmed: false, } } fn with_pill(status: AttentionStatus, count: usize) -> TrayLook { TrayLook { pill: Some(crate::app::po...
rust_dataset_chunk_516509
rust_dataset.txt
516,509
512
ATTENTION_COLOR)); let done = render(32, &with_pill(AttentionStatus::Done, 1), LIGHT_INK); assert!(has_color(&done, DONE_COLOR)); let working = render(32, &with_pill(AttentionStatus::Working, 1), LIGHT_INK); assert!(has_color(&working, WORKING_COLOR)); } #[test] fn below_tw...
rust_dataset_chunk_516510
rust_dataset.txt
516,510
512
K); assert_eq!(cache.entries.len(), 2); } #[test] fn argb_and_bgra_reorder_the_channels() { let mut image = Rgba::blank(1, 1); image.pixels = vec![1, 2, 3, 4]; assert_eq!(image.to_argb_big_endian(), vec![4, 1, 2, 3]); assert_eq!(image.to_bgra(), vec![3, 2, 1, 4]); ...
rust_dataset_chunk_516511
rust_dataset.txt
516,511
512
opened with the app (Open With, a Dock drop, //! `open -a`). use std::path::Path; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::OnceLock; use objc2::runtime::{AnyObject, Imp, Sel}; use objc2::sel; use objc2_foundation::{NSArray, NSURL}; use zellij_utils::app_control::AppRequest; use crate::app::desk...
rust_dataset_chunk_516512
rust_dataset.txt
516,512
512
= url.isFileURL().then(|| url.path()).flatten() else { continue; }; let path = path.to_string(); OPENED.store(true, Ordering::Relaxed); let request = opened_request(Path::new(&path), opener.shell.as_deref()); if !opener .poster .post(crate::ap...
rust_dataset_chunk_516513
rust_dataset.txt
516,513
512
.remove(&id); } self.tokens.remove(&number); Some(id) } } pub struct Freedesktop { bus: Bus, ids: Arc<Mutex<Ids>>, markup: bool, } fn on_signal(message: &Message, ids: &Mutex<Ids>, events: &Events) { if message.kind != Kind::Signal || message.interface.as_deref() != Some(SE...
rust_dataset_chunk_516514
rust_dataset.txt
516,514
512
new(Mutex::new(Ids::default())); let handler_ids = ids.clone(); let bus = connect(Box::new(move |_bus| { Box::new(move |message: Message| on_signal(&message, &handler_ids, &events)) }))?; bus.add_match(&match_rule(SERVICE, None))?; let capabilities = bus ....
rust_dataset_chunk_516515
rust_dataset.txt
516,515
512
Byte(1)), ]), Value::I32(-1), ], ) } impl Sink for Freedesktop { fn show(&mut self, id: &NotifyId, content: &Content) { let replaces = self .ids .lock() .ok() .and_then(|ids| ids.by_id.get(id).copied()) .unwrap_...
rust_dataset_chunk_516516
rust_dataset.txt
516,516
512
_the_default_action_reports_the_item_with_its_activation_token() { let ids = Mutex::new(Ids::default()); ids.lock().unwrap().remember(&id(), 7); let (events, seen) = recorded(); on_signal( &signal("ActivationToken", vec![Value::U32(7), Value::str("tok")]), &ids, ...
rust_dataset_chunk_516517
rust_dataset.txt
516,517
512
_reports_a_click() { let (ours, theirs) = std::os::unix::net::UnixStream::pair().unwrap(); let server = crate::app::desktop::dbus::fake::FakeBus::serve(theirs, |call, bus| { if call.is(SERVICE, "GetCapabilities") { return Some(vec![Value::strings(["body", "body-markup", "acti...
rust_dataset_chunk_516518
rust_dataset.txt
516,518
512
assert_eq!( notifies[1].body[1], Value::U32(41), "the second show replaces the first" ); let closes: Vec<&Message> = calls .iter() .filter(|c| c.is(SERVICE, "CloseNotification")) .collect(); assert_eq!(closes.len(), ...
rust_dataset_chunk_516519
rust_dataset.txt
516,519
512
UNUserNotificationCenterDelegate for Delegate { #[unsafe(method(userNotificationCenter:willPresentNotification:withCompletionHandler:))] fn will_present( &self, _center: &UNUserNotificationCenter, _notification: &UNNotification, completion_handler: &block...
rust_dataset_chunk_516520
rust_dataset.txt
516,520
512
)); body.setBody(&NSString::from_str(&content.body)); body.setThreadIdentifier(&NSString::from_str(thread)); let request = UNNotificationRequest::requestWithIdentifier_content_trigger( &NSString::from_str(identifier), &body, None, ); self.cente...
rust_dataset_chunk_516521
rust_dataset.txt
516,521
512
-> Notifier { Notifier::spawn_with(move || open(events)) } pub fn spawn_with(open: impl FnOnce() -> Option<Box<dyn Sink>> + Send + 'static) -> Notifier { let (ops, received) = channel::<Op>(); let _ = std::thread::Builder::new() .name("app_notifier".to_owned()) ...
rust_dataset_chunk_516522
rust_dataset.txt
516,522
512
events: Events) -> Option<Box<dyn Sink>> { None } #[cfg_attr(not(any(target_os = "linux", windows, test)), allow(dead_code))] pub fn escape_markup(text: &str) -> String { let mut out = String::with_capacity(text.len()); for ch in text.chars() { match ch { '&' => out.push_str("&amp;"), ...
rust_dataset_chunk_516523
rust_dataset.txt
516,523
512
#[test] fn commands_reach_the_sink_in_order_on_its_own_thread() { let recorder = Recorder::default(); let sink = recorder.clone(); let notifier = Notifier::spawn_with(move || Some(Box::new(sink) as Box<dyn Sink>)); let id = NotifyId::Item(ItemKey { session: "b".to_own...
rust_dataset_chunk_516524
rust_dataset.txt
516,524
512
) } pub fn toast_xml(content: &Content) -> String { format!( "<toast><visual><binding template=\"ToastGeneric\"><text>{}</text><text>{}</text></binding></visual></toast>", escape_markup(&content.title), escape_markup(&content.body) ) } fn app_notifier() -> Result<(ToastNotifier, HSTRIN...
rust_dataset_chunk_516525
rust_dataset.txt
516,525
512
ToastNotification, id: &NotifyId) -> Result<()> { let events = self.events.clone(); let clicked = id.clone(); toast.Activated(&TypedEventHandler::<ToastNotification, IInspectable>::new( move |_: Ref<ToastNotification>, _: Ref<IInspectable>| { events(SinkEvent::Clicked...
rust_dataset_chunk_516526
rust_dataset.txt
516,526
512
::TimedOut), "a toast that times out still waits in the notification centre" ); assert!( !dismissed_by_user(ToastDismissalReason::ApplicationHidden), "a toast the app withdrew is not the user's doing" ); } } --- FILE: zellij/zellij-terminal/src/app/deskt...
rust_dataset_chunk_516527
rust_dataset.txt
516,527
512
(); if !wants_tray && !wants_notifications { return; } let _ = std::thread::Builder::new() .name("app_services".to_owned()) .spawn(move || { std::thread::sleep(std::time::Duration::from_secs(3)); let Ok(bus) = crate::app::desktop::dbus::Bus::session(|_| Box::n...
rust_dataset_chunk_516528
rust_dataset.txt
516,528
512
policy turns off Windows notifications, so desktop notifications cannot \ appear." .to_owned(), ), _ => None, } } #[cfg(not(any(target_os = "linux", windows)))] pub fn check_soon(_attention: &AttentionConfig) {} #[cfg(test)] mod tests { use super::*; #[test] ...
rust_dataset_chunk_516529
rust_dataset.txt
516,529
512
MenuBar"; pub const ITEM_INTERFACE: &str = "org.kde.StatusNotifierItem"; pub const MENU_INTERFACE: &str = "com.canonical.dbusmenu"; pub const WATCHER_SERVICE: &str = "org.kde.StatusNotifierWatcher"; pub const WATCHER_PATH: &str = "/StatusNotifierWatcher"; pub const NEUTRAL_INK: [u8; 3] = [168, 168, 168]; const CALL_TIM...
rust_dataset_chunk_516530
rust_dataset.txt
516,530
512
(dial: Dial, events: TrayEvents, state: &TrayState) -> StatusNotifier { let mut cache = IconCache::default(); let shared = Arc::new(Mutex::new(Shared { tooltip: state.tooltip.clone(), pixmaps: pixmaps(&mut cache, state), menu: state.menu, revision: 1, ...
rust_dataset_chunk_516531
rust_dataset.txt
516,531
512
"no tray host is running (on GNOME, install the AppIndicator and KStatusNotifierItem \ extension); notifications still work" ); } bus.call( Message::call( WATCHER_SERVICE, WATCHER_PATH, WATCHER_SERVICE, "RegisterStatusNotifierItem", ...
rust_dataset_chunk_516532
rust_dataset.txt
516,532
512
Drop for StatusNotifier { fn drop(&mut self) { if let Some(bus) = self.bus.take() { bus.shutdown(); } } } fn handle( bus: &Bus, message: &Message, shared: &Mutex<Shared>, events: &TrayEvents, service: &str, ) { if message.kind == Kind::Signal { if me...
rust_dataset_chunk_516533
rust_dataset.txt
516,533
512
"{sv}".to_owned(), item_properties(&shared) .into_iter() .map(|(name, value)| { Value::DictEntry(Box::new(Value::str(name)), Box::new(Value::variant(value))) }) .collect(), )])), (ITEM_PATH, PROPE...
rust_dataset_chunk_516534
rust_dataset.txt
516,534
512
::U32(shared.revision), menu_layout(&entries, parent), ])) }, (MENU_PATH, MENU_INTERFACE, "GetGroupProperties") => { let entries = menu(&shared.menu); let ids: Vec<i32> = message .body .first() .map(|ids|...
rust_dataset_chunk_516535
rust_dataset.txt
516,535
512
shared.menu; drop(shared); if let Some(group) = message.body.first() { for event in group.items() { let parts = event.items(); let id = parts.first().and_then(Value::as_i32).unwrap_or(-1); let kind = parts.get(1).and_th...
rust_dataset_chunk_516536
rust_dataset.txt
516,536
512
("Menu", Value::Path(MENU_PATH.to_owned())), ] } fn menu_properties() -> Vec<(&'static str, Value)> { vec![ ("Version", Value::U32(3)), ("TextDirection", Value::str("ltr")), ("Status", Value::str("normal")), ("IconThemePath", Value::Array("s".to_owned(), vec![])), ] ...
rust_dataset_chunk_516537
rust_dataset.txt
516,537
512
.map(|item| Value::variant(subtree(item))) .collect(), ), MenuEntry::Item { id, .. } | MenuEntry::Separator { id } => { node(*id, entry_properties(entry), vec![]) }, } } pub fn menu_layout(entries: &[MenuEntry], parent: i32) -> Value { if parent != 0 { ...
rust_dataset_chunk_516538
rust_dataset.txt
516,538
512
interface name=\"com.canonical.dbusmenu\">\ <method name=\"GetLayout\"><arg type=\"i\" direction=\"in\"/><arg type=\"i\" direction=\"in\"/><arg type=\"as\" direction=\"in\"/><arg type=\"u\" direction=\"out\"/><arg type=\"(ia{sv}av)\" direction=\"out\"/></method>\ <method name=\"GetGroupPropert...
rust_dataset_chunk_516539
rust_dataset.txt
516,539
512
arg type=\"s\" direction=\"in\"/><arg type=\"v\" direction=\"out\"/></method>\ <method name=\"GetAll\"><arg type=\"s\" direction=\"in\"/><arg type=\"a{{sv}}\" direction=\"out\"/></method></interface>\ {}</node>", body ) } #[cfg(test)] mod tests { use super::*; use crate::app::desk...
rust_dataset_chunk_516540
rust_dataset.txt
516,540
512
(key, value) if key.as_str() == Some("IconPixmap") => Some(value), _ => None, }) .unwrap(); let sizes: Vec<i32> = pixmaps .items() .iter() .map(|p| p.items()[0].as_i32().unwrap()) .collect(); assert_eq!(sizes, vec![1...
rust_dataset_chunk_516541
rust_dataset.txt
516,541
512
fn the_menu_layout_nests_submenus_and_has_the_dbusmenu_shape() { let layout = menu_layout(&menu(&MenuState::default()), 0); assert_eq!(layout.signature(), "(ia{sv}av)"); let children = layout.items()[2].items(); assert_eq!(children.len(), 12); let pause = children[6].items(); ...
rust_dataset_chunk_516542
rust_dataset.txt
516,542
512
IconCache::default(); let calm = tray_state(&Default::default(), MenuState::default()); let mut attention = calm.clone(); attention.look = TrayLook { pill: Some(Pill { status: AttentionStatus::NeedsYou, color: [255, 140, 0], count: 2, ...
rust_dataset_chunk_516543
rust_dataset.txt
516,543
512
), vec![ "Hello".to_owned(), "RequestName".to_owned(), "AddMatch".to_owned(), "NameHasOwner".to_owned(), "RegisterStatusNotifierItem".to_owned() ] ); assert_eq!(calls[1].body[0].as_str(), Some(tray.se...
rust_dataset_chunk_516544
rust_dataset.txt
516,544
512
dbus::BUS_PATH, BUS_SERVICE, "NameOwnerChanged", vec![ Value::str(WATCHER_SERVICE), Value::str(":1.9"), Value::str(owner), ], ) }; bus.signal(owner_changed("")); ...
rust_dataset_chunk_516545
rust_dataset.txt
516,545
512
std::mem::transmute::<Handler, Imp>(handler), c"B@:@B", ) } } extern "C-unwind" fn should_handle_reopen( _this: &AnyObject, _cmd: Sel, _app: &AnyObject, has_visible_windows: Bool, ) -> Bool { let any_minimized = MainThreadMarker::new() .map(|mtm| { NSApp...
rust_dataset_chunk_516546
rust_dataset.txt
516,546
512
app::policy::model::{MenuState, TrayLook, TrayState}; const POINTS: f64 = 18.0; const PIXELS: u32 = 36; pub struct HandlerIvars { events: TrayEvents, item: RefCell<Option<Retained<NSStatusItem>>>, menu: Cell<MenuState>, } define_class!( #[unsafe(super(NSObject))] #[thread_kind = MainThreadOnly] ...
rust_dataset_chunk_516547
rust_dataset.txt
516,547
512
if let Some(button) = item.button(mtm) { unsafe { button.performClick(None) }; } item.setMenu(None); } } fn build_menu(mtm: MainThreadMarker, entries: &[MenuEntry], handler: &Handler) -> Retained<NSMenu> { let menu = NSMenu::new(mtm); menu.setAutoenablesItems(false); ...
rust_dataset_chunk_516548
rust_dataset.txt
516,548
512
= Some(item.clone()); let button = item .button(mtm) .ok_or_else(|| anyhow!("the status item has no button"))?; unsafe { button.setTarget(Some(&handler)); button.setAction(Some(sel!(clicked:))); } button.sendActionOn(NSEventMask::LeftMouse...
rust_dataset_chunk_516549
rust_dataset.txt
516,549
512
.state = state.clone(); self.handler.ivars().menu.set(state.menu); self.draw(false); if let Some(button) = self.item.button(self.mtm) { button.setToolTip(Some(&NSString::from_str(&state.tooltip))); } } fn set_visible(&mut self, visible: bool) { self.item.setV...
rust_dataset_chunk_516550
rust_dataset.txt
516,550
512
action: MainAction, } const fn ours(title: &'static str, tag: isize, key: &'static str) -> Option<MainItem> { Some(MainItem { title, key, with_option: false, alternate: false, action: MainAction::Ours(tag), }) } const fn standard( title: &'static str, selector:...
rust_dataset_chunk_516551
rust_dataset.txt
516,551
512
) => Sel::register(name), }; let menu_item = unsafe { NSMenuItem::initWithTitle_action_keyEquivalent( NSMenuItem::alloc(mtm), &NSString::from_str(item.title), Some(selector), &NSString::from_str(item.key), ) }; if item.with_option { ...
rust_dataset_chunk_516552
rust_dataset.txt
516,552
512
test] fn the_main_menu_has_the_standard_macos_items() { let layout: Vec<(&str, Vec<Option<(&str, &str, bool)>>)> = MAIN_MENU .iter() .map(|(menu, items)| { ( *menu, items .iter() ....
rust_dataset_chunk_516553
rust_dataset.txt
516,553
512
while Option is held, as in Finder" ); assert_eq!( action("Close Window"), Some(MainAction::Standard(c"performClose:")), "Cmd+W goes the way of the close button" ); assert_eq!( action("Minimize"), Some(MainAction::Standard(c"pe...
rust_dataset_chunk_516554
rust_dataset.txt
516,554
512
allow(dead_code)] #[derive(Debug, Clone, Copy, PartialEq)] pub enum Anchor { Below { x: f64, y: f64 }, Above { x: f64, y: f64 }, At { x: f64, y: f64 }, } #[derive(Debug, Clone, PartialEq, Eq)] pub enum MenuEntry { Item { id: i32, label: &'static str, action: MenuAction, ...
rust_dataset_chunk_516555
rust_dataset.txt
516,555
512
base, "Default", MenuAction::BadgeColor(*status, None), chosen.is_none(), )]; items.extend( BADGE_PALETTE .iter() .enumerate() .map(|(offset, (name, colour)...
rust_dataset_chunk_516556
rust_dataset.txt
516,556
512
label: "Pause notifications", items: vec![ item(51, "1 hour", MenuAction::PauseHour, true), item(52, "Until tomorrow", MenuAction::PauseUntilTomorrow, true), item(53, "Resume", MenuAction::Resume, paused), ], ...
rust_dataset_chunk_516557
rust_dataset.txt
516,557
512
} } #[cfg(windows)] pub fn open(events: TrayEvents, state: &TrayState) -> Option<Box<dyn Tray>> { match windows::NotifyIcon::open(events, state) { Ok(tray) => Some(Box::new(tray)), Err(e) => { report!("the notification-area icon could not be created: {:#}", e); None ...
rust_dataset_chunk_516558
rust_dataset.txt
516,558
512
"Quit Zellij and stop all sessions…", ] ); assert_eq!(find_action(&menu(&calm), 53), None); assert_eq!(find_action(&menu(&paused), 53), Some(MenuAction::Resume)); assert_eq!( find_action(&menu(&calm), 62), Some(MenuAction::HidePermanently) ); ...
rust_dataset_chunk_516559
rust_dataset.txt
516,559
512
Some(false), "quiet does not"); assert_eq!( find_action(&entries, 225), Some(MenuAction::ToggleBadge(AttentionStatus::NewOutput)) ); assert_eq!(checked(&entries, 2310), Some(false)); assert_eq!(checked(&entries, 2315), Some(true), "failed is purple"); ass...
rust_dataset_chunk_516560
rust_dataset.txt
516,560
512
::WindowsAndMessaging::{ AppendMenuW, CreateIconIndirect, CreatePopupMenu, CreateWindowExW, DefWindowProcW, DestroyIcon, DestroyMenu, DestroyWindow, GetCursorPos, GetWindowLongPtrW, PostMessageW, RegisterClassExW, RegisterWindowMessageW, SetForegroundWindow, SetWindowLongPtrW, TrackPopupMenu, GWLP_USERDATA,...
rust_dataset_chunk_516561
rust_dataset.txt
516,561
512
== 0 && value == 1 } fn icon_size() -> u32 { let size = unsafe { GetSystemMetricsForDpi(SM_CXSMICON, GetDpiForSystem()) }; if size > 0 { size as u32 } else { 16 } } fn make_icon(image: &crate::app::desktop::icon::Rgba) -> HICON { unsafe { let mut header: BITMAPINFO = std::...
rust_dataset_chunk_516562
rust_dataset.txt
516,562
512
: &str) { let encoded: Vec<u16> = tip.encode_utf16().take(127).collect(); data.szTip = [0; 128]; data.szTip[..encoded.len()].copy_from_slice(&encoded); } #[derive(Debug, Clone, Copy, PartialEq, Eq)] enum Callback { Activate, Menu, Ignore, } /// A click, and Enter or Space on the focused icon, ...
rust_dataset_chunk_516563
rust_dataset.txt
516,563
512
token: None, }); }, Callback::Menu => { state.cursor.set(Some((x, y))); show_menu(hwnd, state, x, y); }, Callback::Ignore => {}, } return 0; } unsafe { DefWindowProcW(hwnd, message, wparam, lparam) }...
rust_dataset_chunk_516564
rust_dataset.txt
516,564
512
std::mem::zeroed() }; window_class.cbSize = std::mem::size_of::<WNDCLASSEXW>() as u32; window_class.lpfnWndProc = Some(window_proc); window_class.hInstance = instance; window_class.lpszClassName = class.as_ptr(); unsafe { RegisterClassExW(&window_class) }; // A hidden to...
rust_dataset_chunk_516565
rust_dataset.txt
516,565
512
} } impl Tray for NotifyIcon { fn update(&mut self, state: &TrayState) { self.state.menu.set(state.menu); let size = icon_size(); let light = light_taskbar(); let key = (state.look.clone(), size, light); if self.look.as_ref() != Some(&key) { let ink = if light {...
rust_dataset_chunk_516566
rust_dataset.txt
516,566
512
: self.state.menu.get(), }); } } } } pub fn work_area(x: i32, y: i32) -> Option<(f64, f64, f64, f64)> { unsafe { let monitor = MonitorFromPoint(POINT { x, y }, MONITOR_DEFAULTTONEAREST); let mut info: MONITORINFO = std::mem::zeroed(); info.cbSize = st...
rust_dataset_chunk_516567
rust_dataset.txt
516,567
512
data::PaneId; use zellij_utils::input::attention::AttentionConfig; use zellij_utils::input::config::Config; use crate::app::control::watcher::{Snapshot, Watcher}; use crate::app::desktop::notifier::{Notifier, SinkEvent}; use crate::app::desktop::tray::{MenuAction, Tray, TrayEvent}; use crate::app::policy::engine::{Eng...
rust_dataset_chunk_516568
rust_dataset.txt
516,568
512
if !request.create && request.command.is_empty() && request.remote_url().is_none() => { ( AppReply::Done, vec![Intent::RouteRequest { request, token: None, ...
rust_dataset_chunk_516569
rust_dataset.txt
516,569
512
: {}", e); AttentionConfig::default() }, } } pub fn watch_config(path: PathBuf, post: impl Fn(AttentionConfig) + Send + 'static) { let _ = std::thread::Builder::new() .name("app_config".to_owned()) .spawn(move || { let modified = |path: &Path| std::fs::metadata(p...
rust_dataset_chunk_516570
rust_dataset.txt
516,570
512
&Config::default())?; if let Some(parent) = path.parent() { std::fs::create_dir_all(parent).map_err(|e| e.to_string())?; } std::fs::write(path, written).map_err(|e| e.to_string()) } pub fn tomorrow() -> SystemTime { use chrono::{Duration as ChronoDuration, Local, TimeZone}; let now = Local...
rust_dataset_chunk_516571
rust_dataset.txt
516,571
512
() { #[cfg(target_os = "macos")] tray::install_reopen_handler(events.clone()); self._main_menu = tray::install_main_menu(events); } self.apply_tray_visibility(); } fn paused(&self) -> bool { self.paused_until .map(|until| SystemTime::now()...
rust_dataset_chunk_516572
rust_dataset.txt
516,572
512
); self.refresh_tray(); } fn apply_tray_visibility(&mut self) { let visible = self.tray_visible(); if visible && self.tray.is_none() { if let Some(events) = self.tray_events.clone() { let state = self.tray_state(); self.tray = tray::open(event...
rust_dataset_chunk_516573
rust_dataset.txt
516,573
512
, }], TrayEvent::Menu(action) => self .on_menu(action, now) .into_iter() .map(|intent| self.adjust_intent(intent)) .collect(), } } fn on_menu(&mut self, action: MenuAction, now: Instant) -> Vec<Intent> { mat...
rust_dataset_chunk_516574
rust_dataset.txt
516,574
512
Action::ToggleBadge(status) => { use zellij_utils::input::config_settings::badge_setting_key; let on = !self.config.tray_badge().includes(status); self.config.tray_badge.set(status, Some(on)); self.save(badge_setting_key(status), Some(on.to_string())); ...
rust_dataset_chunk_516575
rust_dataset.txt
516,575
512
deadline(&self) -> Option<Instant> { let pause = self.paused_until.map(|until| { let left = until .duration_since(SystemTime::now()) .unwrap_or(Duration::ZERO); Instant::now() + left }); let appearance = self.tray.as_ref().map(|_| self.nex...
rust_dataset_chunk_516576
rust_dataset.txt
516,576
512
in names .into_iter() .filter(|name| !zellij_utils::consts::is_app_socket_name(name)) { if let Err(e) = zellij_utils::session_link::detach_all_clients(&name) { report!("the clients of {} could not be detached: {}", name, e); ...
rust_dataset_chunk_516577
rust_dataset.txt
516,577
512
), NotifyId::Group(session) => format!("group//{}", session), } } #[cfg_attr(not(any(target_os = "macos", test)), allow(dead_code))] pub fn decode(text: &str) -> Option<NotifyId> { let mut parts = text.splitn(3, '/'); let kind = parts.next()?; let pane = parts.ne...
rust_dataset_chunk_516578
rust_dataset.txt
516,578
512
= item.text(); let body = if details && !text.is_empty() { text } else { format!("{} {}", title, verb(status)) }; Content { title, body } } fn verb(status: AttentionStatus) -> &'static str { match status { AttentionStatus::NeedsYou => "needs you", AttentionStatus::F...
rust_dataset_chunk_516579
rust_dataset.txt
516,579
512
![]; } self.reconcile(now) } pub fn set_policy(&mut self, policy: Policy, now: Instant) -> Vec<Command> { self.policy = policy; self.reconcile(now) } pub fn tick(&mut self, now: Instant) -> Vec<Command> { self.reconcile(now) } pub fn next_deadline(&self...
rust_dataset_chunk_516580
rust_dataset.txt
516,580
512
} else { break; } } } fn gone_now(&self, key: &ItemKey) -> bool { !self.present.contains(key) || self.seen.contains(key) } fn withdraw_gone(&mut self, now: Instant, commands: &mut Vec<Command>) { let shown: Vec<ItemKey> = self.shown.keys(...
rust_dataset_chunk_516581
rust_dataset.txt
516,581
512
self.quiet.keys().cloned().collect(); for key in quiet { let Some(next) = self.current.get(&key).cloned() else { continue; }; let previous = self.quiet.get(&key); if previous.map(|p| p.status) != Some(next.status) { self.quiet.remo...
rust_dataset_chunk_516582
rust_dataset.txt
516,582
512
)); }, } } } fn flush_due(&mut self, now: Instant, commands: &mut Vec<Command>) { if self.policy.quiet() { return; } let due: Vec<ItemKey> = self .pending .iter() .filter(|(_, (_, at))| *at <= now) ...
rust_dataset_chunk_516583
rust_dataset.txt
516,583
512
.keys() .filter(|key| key.session == session) .cloned() .collect(); for key in individually { if let Some(eligible) = self.shown.remove(&key) { self.vanishing.remove(&key); commands.push(Command::Withdraw { ...
rust_dataset_chunk_516584
rust_dataset.txt
516,584
512
: &[Command]) -> Vec<NotifyId> { commands .iter() .filter_map(|c| match c { Command::Show { id, .. } => Some(id.clone()), _ => None, }) .collect() } fn withdraws(commands: &[Command]) -> Vec<NotifyId> { commands ...
rust_dataset_chunk_516585
rust_dataset.txt
516,585
512
.is_empty()); } #[test] fn a_changed_item_replaces_its_notification_instead_of_stacking() { let now = Instant::now(); let mut engine = started(now); engine.update(&blocked("first"), policy(), now); engine.tick(now + FIRST_SHOW_DELAY); let changed = engine.update(&bl...
rust_dataset_chunk_516586
rust_dataset.txt
516,586
512
.tick(now + FIRST_SHOW_DELAY); let working = global(vec![("b", vec![item(1, AttentionStatus::Working, "", 10)])]); let t = now + Duration::from_secs(3); assert!(engine.update(&working, policy(), t).is_empty()); assert!(engine .update(&blocked("x"), policy(), t + Duration::fro...
rust_dataset_chunk_516587
rust_dataset.txt
516,587
512
_least_the_threshold() { let now = Instant::now(); let mut engine = started(now); engine.update(&global(vec![("b", vec![])]), policy(), now); let finished = global(vec![( "b", vec![ ran(item(1, AttentionStatus::Done, "", 10), 10_000), ...
rust_dataset_chunk_516588
rust_dataset.txt
516,588
512
(5)).is_empty()); assert!(engine .set_policy(policy(), now + Duration::from_secs(6)) .is_empty()); assert!(engine.tick(now + Duration::from_secs(9)).is_empty()); let next = global(vec![( "b", vec![item(1, AttentionStatus::Failed, "boom", 10)], ...
rust_dataset_chunk_516589
rust_dataset.txt
516,589
512
other => panic!("{:?}", other), } let fewer = global(vec![( "api", vec![item(1, AttentionStatus::NeedsYou, "a", 10)], )]); let commands = engine.update(&fewer, policy(), now + Duration::from_secs(3)); assert!( commands.is_empty(), ...
rust_dataset_chunk_516590
rust_dataset.txt
516,590
512
let failed = global(vec![("b", vec![item(1, AttentionStatus::Failed, "x", 10)])]); engine.update(&failed, policy(), now + Duration::from_secs(4)); assert_eq!( shows(&engine.tick(now + Duration::from_secs(6))), vec![key("b", 1)] ); } #[test] fn a_dismi...
rust_dataset_chunk_516591
rust_dataset.txt
516,591
512
); assert_eq!( target_of(&key("api", 1), &crowd), ("api".to_owned(), Some(PaneId::Terminal(1))) ); } } --- FILE: zellij/zellij-terminal/src/app/policy/model.rs --- use zellij_utils::attention::{AttentionStatus, GlobalAttention}; use zellij_utils::input::attention::{...
rust_dataset_chunk_516592
rust_dataset.txt
516,592
512
| badge.statuses.includes(**status)) .find_map(|status| { let count = count_of(global, *status); (count > 0).then(|| Pill { status: *status, color: badge.color(*status), count, }) }) } #[derive(Debug, Clone, PartialEq, ...
rust_dataset_chunk_516593
rust_dataset.txt
516,593
512
{} quiet", global.counts.quiet)); } if badge.includes(AttentionStatus::NewOutput) && global.counts.new_output > 0 { parts.push(format!("{} with new output", global.counts.new_output)); } parts.push(format!("{} running", global.running())); if paused { parts.push("notifications paused...
rust_dataset_chunk_516594
rust_dataset.txt
516,594
512
(p.status, p.count)) } #[test] fn the_pill_mirrors_the_top_status_the_badge_shows() { let badge = BadgeSettings::default(); let calm = global(vec![( "a", vec![ item(3, AttentionStatus::Quiet, "", 1), item(4, AttentionStatus::NewOutput...
rust_dataset_chunk_516595
rust_dataset.txt
516,595
512
)]); assert_eq!(pill(&only_muted, &badge), None); } #[test] fn the_badge_skips_turned_off_statuses_and_uses_chosen_colours() { let mixed = global(vec![( "a", vec![ item(1, AttentionStatus::NeedsYou, "", 1), item(2, AttentionStatus::Qu...
rust_dataset_chunk_516596
rust_dataset.txt
516,596
512
state.tooltip, "Zellij"); } #[test] fn the_tooltip_counts_what_needs_you_and_what_runs() { let global = global(vec![ ( "a", vec![ item(1, AttentionStatus::NeedsYou, "", 1), item(2, AttentionStatus::NeedsYou, "", 1),...
rust_dataset_chunk_516597
rust_dataset.txt
516,597
512
Id>) -> Option<(u32, bool)> { pane.map(|pane| match pane { PaneId::Terminal(id) => (id, false), PaneId::Plugin(id) => (id, true), }) } #[cfg(test)] mod tests { use super::*; fn window(key: u64, session: &str, focused_at: u64) -> AttachedWindow { AttachedWindow { key...
rust_dataset_chunk_516598
rust_dataset.txt
516,598
512
(PaneId::Plugin(2))), Some((2, true))); assert_eq!(pane_focus(None), None); } } --- FILE: zellij/zellij-terminal/src/app/policy/state.rs --- use std::path::{Path, PathBuf}; use anyhow::{Context, Result}; use serde::{Deserialize, Serialize}; use zellij_utils::consts::ZELLIJ_CACHE_DIR; const FILE_NAME: &s...
rust_dataset_chunk_516599
rust_dataset.txt
516,599
512
it explained closing: {:#}", e ); } } Some(CLOSE_NOTICE) } } #[cfg(test)] mod tests { use super::*; #[test] fn the_close_notice_is_given_once_and_remembered_across_launches() { let dir = tempfile::TempDir::new().unwrap(); ...