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_513300 | rust_dataset.txt | 513,300 | 512 | width_terminator(character: char) -> bool {
matches!(
character,
' ' | '、'
| '。'
| '《'
| '》'
| '「'
| '」'
| '『'
| '』'
| '【'
| '】'
| '〔'
| '〕'
| '‘'
... |
rust_dataset_chunk_513301 | rust_dataset.txt | 513,301 | 512 | = url
.strip_prefix("http://")
.or_else(|| url.strip_prefix("https://"))
{
return !after_protocol.is_empty() && after_protocol.contains('.');
}
if let Some(after_protocol) = url.strip_prefix("ftp://") {
return !after_protocol.is_empty();
}
if let Some(after_colon) = ... |
rust_dataset_chunk_513302 | rust_dataset.txt | 513,302 | 512 | _y)| (start..end).contains(&(*cursor_y as isize)))
.map(|(cursor_x, cursor_y)| {
cells
.iter()
.position(|cell| cell.y == cursor_y as isize && cell.index >= cursor_x)
.unwrap_or(cells.len())
});
let deferred = li... |
rust_dataset_chunk_513303 | rust_dataset.txt | 513,303 | 512 | row| row.columns.get(cell.index))
.and_then(|character| character.styles.link_anchor)
.filter(|anchor| matches!(anchor, LinkAnchor::Start(_)))
}
fn linked_exactly(
lines_above: &VecDeque<Row>,
viewport: &VecDeque<Row>,
cells: &[Cell],
kept: usize,
previous: Option<LinkAnchor>,
) -> ... |
rust_dataset_chunk_513304 | rust_dataset.txt | 513,304 | 512 | | styles.link_anchor = Some(anchor));
last_update = Some((before, character.styles.clone()));
},
}
}
}
fn mark_end(
lines_above: &mut VecDeque<Row>,
viewport: &mut VecDeque<Row>,
cells: &[Cell],
after: usize,
) {
let (y, index) = match cells.get(after) {
... |
rust_dataset_chunk_513305 | rust_dataset.txt | 513,305 | 512 | ize> = (0..viewport.len() as isize).collect();
link_urls_in_lines(lines_above, viewport, &changed, cursor, link_handler);
}
fn uris(link_handler: &LinkHandler) -> Vec<String> {
let mut uris: Vec<String> = link_handler
.links()
.values()
.map(|link| link.uri.c... |
rust_dataset_chunk_513306 | rust_dataset.txt | 513,306 | 512 | _start(&marked[26]));
assert_eq!(marked[27], Some(LinkAnchor::End));
}
#[test]
fn each_terminator_ends_a_url() {
for terminator in [
' ', '\t', '"', '\'', '<', '>', '(', ')', '[', ']', '{', '}', '⏎',
] {
let text = format!("http://example.com{}rest", terminat... |
rust_dataset_chunk_513307 | rust_dataset.txt | 513,307 | 512 | (
"\u{ff08}https://example.com/a\u{ff09}rest",
"https://example.com/a",
),
] {
let mut viewport = screen(&[(text, true)], 60);
let mut handler = LinkHandler::new();
link_all(&mut VecDeque::new(), &mut viewport, None, &mut handler);... |
rust_dataset_chunk_513308 | rust_dataset.txt | 513,308 | 512 | ://example.com/rest".to_owned()]);
assert!(anchors(&lines_above[0]).iter().all(is_start));
assert!(anchors(&viewport[0])[..8].iter().all(is_start));
}
#[test]
fn a_url_the_cursor_may_still_extend_is_left_for_later() {
let mut viewport = screen(&[("https://example.com", true)], 19);
... |
rust_dataset_chunk_513309 | rust_dataset.txt | 513,309 | 512 | [0].columns[0].styles.clone();
link_all(&mut VecDeque::new(), &mut viewport, None, &mut handler);
let marked = anchors(&viewport[0]);
assert_ne!(marked[0], first);
assert!(marked[..22].iter().all(|anchor| *anchor == marked[0]));
assert_eq!(marked[22], Some(LinkAnchor::End));
... |
rust_dataset_chunk_513310 | rust_dataset.txt | 513,310 | 512 | 0]);
assert_ne!(marked[0], marked[21]);
}
#[test]
fn the_end_marker_does_not_clobber_a_link_that_follows() {
let url = "https://example.com";
let mut viewport = screen(&[(&format!("{} ", url), true)], 40);
let mut handler = LinkHandler::new();
let neighbour = handler... |
rust_dataset_chunk_513311 | rust_dataset.txt | 513,311 | 512 | [url.len()].styles.link_anchor,
Some(LinkAnchor::End)
);
}
#[test]
fn helper_rules() {
assert_eq!(trim_trailing_punctuation("http://a.com..."), "http://a.com");
assert_eq!(trim_trailing_punctuation("http://a.com"), "http://a.com");
assert!(is_valid_url("https://s... |
rust_dataset_chunk_513312 | rust_dataset.txt | 513,312 | 512 | > {
self.scaled_px.map(|size| ScaledImageKey {
source: self.source_rect,
size,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct KittyReplyData {
pub image_id: Option<u32>,
pub image_number: Option<u32>,
pub placement_id: Option<u32>,
pub quiet: u8,
... |
rust_dataset_chunk_513313 | rust_dataset.txt | 513,313 | 512 | previous_cell_size = *character_cell_size.borrow();
KittyGrid {
character_cell_size,
kitty_image_store,
image_ids: HashMap::new(),
image_numbers: HashMap::new(),
placements: Vec::new(),
next_synthetic_image_id: u32::MAX,
front_... |
rust_dataset_chunk_513314 | rust_dataset.txt | 513,314 | 512 | _numbers.values_mut() {
ids.retain(|id| *id != pane_image_id);
}
self.image_numbers.retain(|_, ids| !ids.is_empty());
}
pub fn transmit(
&mut self,
command: &KittyCommand,
image: DecodedImage,
) -> Result<u32, KittyError> {
let pane_image_id = if c... |
rust_dataset_chunk_513315 | rust_dataset.txt | 513,315 | 512 | ids.last())
.ok_or_else(|| enoent(command, "unknown image number"))?
} else {
return Err(enoent(command, "no image id specified"));
};
let internal = *self
.image_ids
.get(&pane_image_id)
.ok_or_else(|| enoent(command, "unknown ima... |
rust_dataset_chunk_513316 | rust_dataset.txt | 513,316 | 512 | =
match (command.columns as usize, command.rows as usize) {
(0, 0) => (
source_w,
source_h,
ceil_div(source_w + off_x, cell.width),
ceil_div(source_h + off_y, cell.height),
false,
... |
rust_dataset_chunk_513317 | rust_dataset.txt | 513,317 | 512 | })
.unwrap_or(false);
if !fits {
return Err(einval(command, "placement too large"));
}
let scaled_bytes = {
let store = self.kitty_image_store.borrow();
let image = store
.get(internal)
... |
rust_dataset_chunk_513318 | rust_dataset.txt | 513,318 | 512 | });
self.kitty_image_store
.borrow_mut()
.add_placement_ref(internal);
Ok(dest_cells)
}
pub fn delete(
&mut self,
command: &KittyCommand,
cursor_cell: (usize, usize),
viewport_cells: (usize, usize),
scrollback_rows: usize,
... |
rust_dataset_chunk_513319 | rust_dataset.txt | 513,319 | 512 | (la_px + (source_y as usize - 1) * cell_h)
}
};
let matches_placement = |placement: &KittyPlacement| -> bool {
match lower {
'a' => placement
.display_rect
.intersecting_rect(&probe_rect(
0,
... |
rust_dataset_chunk_513320 | rust_dataset.txt | 513,320 | 512 | placement.image_id <= command.source_y
},
_ => false,
}
};
{
let mut store = self.kitty_image_store.borrow_mut();
let mut kept = Vec::with_capacity(self.placements.len());
for placement in self.placements.drain(..) {
... |
rust_dataset_chunk_513321 | rust_dataset.txt | 513,321 | 512 | _shifted(&mut self, row_delta: isize) {
self.rows_below_the_viewport =
self.rows_below_the_viewport
.map(|frame| KittyRowsBelowTheViewport {
first_row: std::cmp::max(0, frame.first_row as isize + row_delta) as usize,
total_rows: std::cmp::max(0... |
rust_dataset_chunk_513322 | rust_dataset.txt | 513,322 | 512 | _rect.height as isize <= 0 {
store.free(placement.internal_id);
} else {
kept.push(placement);
}
}
self.placements = kept;
}
}
pub fn merge_rows_into_line_start(&mut self, line_start_row: usize, merged_row_co... |
rust_dataset_chunk_513323 | rust_dataset.txt | 513,323 | 512 | placement.display_rect.y += split_px;
}
}
}
}
pub fn has_placement_anchored_to_first_canonical_line(&self) -> bool {
self.placements
.iter()
.any(|placement| placement.vertical_anchor.canonical_line == 0)
}
pub fn drop_first_canonical_... |
rust_dataset_chunk_513324 | rust_dataset.txt | 513,324 | 512 | _region_top && new_bottom <= shifted_region_top)
{
store.free(placement.internal_id);
continue;
}
if !preserve_above_region_top && new_top < shifted_region_top {
let cut = (shifted_region_top - new_top) as usize;... |
rust_dataset_chunk_513325 | rust_dataset.txt | 513,325 | 512 | {
placement.display_rect.x = (placement.display_rect.x
/ previous_cell_size.width)
* character_cell_size.width;
placement.display_rect.y = (placement.display_rect.y
/ previous_cell_size.height as isize)
... |
rust_dataset_chunk_513326 | rust_dataset.txt | 513,326 | 512 | store = self.kitty_image_store.borrow_mut();
let mut kept = Vec::with_capacity(self.placements.len());
for placement in self.placements.drain(..) {
let screen_relative_top_row =
(placement.display_rect.y - scrollback_top).div_euclid(cell_height);
let dest_rows = ... |
rust_dataset_chunk_513327 | rust_dataset.txt | 513,327 | 512 | ,
)
})
.collect(),
None => vec![],
}
}
pub fn viewport_kitty_chunks(
&self,
viewport_height: usize,
scrollback_size_in_lines: usize,
viewport_width_in_cells: usize,
viewport_x_offset: usize,
v... |
rust_dataset_chunk_513328 | rust_dataset.txt | 513,328 | 512 | ) as usize;
let image_cell_distance_from_changed_rect_top =
image_cell_distance_from_scrollback_top
.saturating_sub(line_index + scrollback_size_in_lines);
let cell_y =
viewport_y_offset + line_index + i... |
rust_dataset_chunk_513329 | rust_dataset.txt | 513,329 | 512 | let row_end = std::cmp::min(row_start + w * 4, (row * src_w + src_w) * 4);
out.extend_from_slice(&src[row_start..row_end]);
}
out
}
pub fn scale_rgba(src: &[u8], src_w: usize, src_h: usize, dst_w: usize, dst_h: usize) -> Vec<u8> {
let mut out = Vec::with_capacity(dst_w * dst_h * 4);
if ... |
rust_dataset_chunk_513330 | rust_dataset.txt | 513,330 | 512 | - tx) * p00 + tx * p10) + ty * ((1.0 - tx) * p01 + tx * p11);
out.push(value.round().max(0.0).min(255.0) as u8);
}
}
}
out
}
#[cfg(test)]
#[path = "./unit/grid_state_tests.rs"]
mod grid_state_tests;
--- FILE: zellij/zellij-server/src/panes/kitty_graphics/interceptor.rs --... |
rust_dataset_chunk_513331 | rust_dataset.txt | 513,331 | 512 | ::Ground => match byte {
0x1b => {
self.state = State::Esc;
InterceptorResult::Swallow
},
b => InterceptorResult::Forward(ForwardBytes::one(b)),
},
State::Esc => match byte {
0x5f => {
... |
rust_dataset_chunk_513332 | rust_dataset.txt | 513,332 | 512 | mem::take(&mut self.buffer))
}
},
0x18 | 0x1a => {
self.state = State::Ground;
self.buffer.clear();
self.overflowed = false;
InterceptorResult::Forward(ForwardBytes::one(byte))
},
b => {
... |
rust_dataset_chunk_513333 | rust_dataset.txt | 513,333 | 512 | pub const MAX_DECODED_BYTES: usize = 104_857_600;
pub const MAX_DIMENSION: u32 = 10_000;
const MAX_ENCODED_PAYLOAD_BYTES: usize = MAX_DECODED_BYTES / 3 * 4 + 4;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum KittyAction {
Transmit,
TransmitAndDisplay,
Display,
Delete,
Query,
}
#[derive(Debu... |
rust_dataset_chunk_513334 | rust_dataset.txt | 513,334 | 512 | u32,
pub source_h: u32,
pub columns: u32,
pub rows: u32,
pub cell_offset_x: u32,
pub cell_offset_y: u32,
pub z_index: i32,
pub quiet: u8,
pub suppress_cursor_movement: bool,
pub delete_specifier: Option<char>,
pub image: Option<DecodedImage>,
}
impl Default for KittyCommand {
... |
rust_dataset_chunk_513335 | rust_dataset.txt | 513,335 | 512 | CommandParser { pending: None }
}
pub fn parse(&mut self, raw: &[u8]) -> Option<Result<KittyCommand, KittyError>> {
let (control, payload) = split_control_payload(raw);
if self.pending.is_some() {
let pairs = match tokenize(control) {
Ok(pairs) => pairs,
... |
rust_dataset_chunk_513336 | rust_dataset.txt | 513,336 | 512 | Err(err) => return Some(Err(err)),
};
match command.action {
KittyAction::Delete | KittyAction::Display => Some(Ok(command)),
KittyAction::Transmit | KittyAction::TransmitAndDisplay | KittyAction::Query => {
if command.more_chunks {
self.pendi... |
rust_dataset_chunk_513337 | rust_dataset.txt | 513,337 | 512 | _pos + 1..];
match key {
b"q" => {
if let Some(q @ 0..=2) = parse_u32(value) {
echo.quiet = q as u8;
}
},
b"i" => echo.image_id = parse_u32(value).or(echo.image_id),
b"I" => echo.i... |
rust_dataset_chunk_513338 | rust_dataset.txt | 513,338 | 512 | ' => KittyMedium::File,
b't' => KittyMedium::TempFile,
b's' => {
return Err(echo.error(
KittyErrorCode::Enotsupported,
"shared memory transfer is not supported",
));
... |
rust_dataset_chunk_513339 | rust_dataset.txt | 513,339 | 512 | 'p'")
})?);
},
b"x" => {
command.source_x = parse_u32(value).ok_or_else(|| {
echo.error(KittyErrorCode::Einval, "invalid value for key 'x'")
})?;
},
b"y" => {
command.source_y = parse_u32... |
rust_dataset_chunk_513340 | rust_dataset.txt | 513,340 | 512 | ,
_ => {
return Err(echo.error(KittyErrorCode::Einval, "invalid value for key 'C'"));
},
};
},
b"d" => {
if value.len() != 1 || !b"aAiInNcCpPqQxXyYzZrR".contains(&value[0]) {
retur... |
rust_dataset_chunk_513341 | rust_dataset.txt | 513,341 | 512 | (
path: &Path,
file_len: u64,
command: &KittyCommand,
echo: &EchoFields,
) -> Result<Vec<u8>, KittyError> {
let start = command.data_offset.unwrap_or(0) as u64;
if start > file_len {
return Err(echo.error(KittyErrorCode::Ebadf, "could not read file"));
}
let available = file_len ... |
rust_dataset_chunk_513342 | rust_dataset.txt | 513,342 | 512 | ) {
Some(resolved) => {
let deletable = is_deletable_temp_file(&resolved);
(resolved, deletable)
},
None => (requested_path, false),
}
} else {
(requested_path, false)
... |
rust_dataset_chunk_513343 | rust_dataset.txt | 513,343 | 512 | (echo.error(
KittyErrorCode::Enodata,
"insufficient image data for dimensions",
));
}
let mut data = data;
data.truncate(expected as usize);
data.shrink_to_fit();
DecodedImage {
bytes: dat... |
rust_dataset_chunk_513344 | rust_dataset.txt | 513,344 | 512 | rgba
},
png::ColorType::GrayscaleAlpha => {
let mut rgba = Vec::with_capacity(buf.len() * 2);
for pixel in buf.chunks_exact(2) {
rgba.extend_from_slice(&[pixel[0], pixel[0], pixel[0], pixel[1]]);
}
rgba
},
_ => r... |
rust_dataset_chunk_513345 | rust_dataset.txt | 513,345 | 512 | b"OK",
))
}
pub fn format_kitty_error(error: &KittyError) -> Option<Vec<u8>> {
if error.quiet >= 2 {
return None;
}
Some(wrap(
keys(error.image_id, error.image_number, error.placement_id),
format!("{}:{}", error.code.as_str(), error.message).as_bytes(),
))
}
--- FI... |
rust_dataset_chunk_513346 | rust_dataset.txt | 513,346 | 512 | mut self) -> u64 {
let uid = self.next_placement_uid;
self.next_placement_uid += 1;
uid
}
pub fn store_image(&mut self, image: DecodedImage) -> Result<InternalImageId, KittyError> {
let (rgba, width, height) = Self::normalize_to_rgba(image);
let size = rgba.len();
... |
rust_dataset_chunk_513347 | rust_dataset.txt | 513,347 | 512 | lru_stamp = self.bump_lru();
if let Some(stored) = self.images.get_mut(&id) {
stored.refcount += 1;
stored.lru_stamp = lru_stamp;
}
}
pub fn remove_placement_ref(&mut self, id: InternalImageId) {
if let Some(stored) = self.images.get_mut(&id) {
stored... |
rust_dataset_chunk_513348 | rust_dataset.txt | 513,348 | 512 | )
.map(|old| old.len())
.unwrap_or(0);
stored
.base64_cache
.retain(|(cached_variant, _), _| *cached_variant != Some(key));
stored.lru_stamp = lru_stamp;
Some((old_len, new_len))
}... |
rust_dataset_chunk_513349 | rust_dataset.txt | 513,349 | 512 | ()
.map(|bytes| bytes.len())
.sum::<usize>()
}
fn remove_entry(&mut self, id: InternalImageId) {
if let Some(stored) = self.images.remove(&id) {
self.total_bytes -= Self::stored_image_bytes(&stored);
}
}
fn evict_to_fit(&mut self, incoming_byte... |
rust_dataset_chunk_513350 | rust_dataset.txt | 513,350 | 512 | flat_map(|value| rgba_pixel(*value).to_vec())
.collect()
}
fn test_grid() -> KittyGrid {
KittyGrid::new(
Rc::new(RefCell::new(Some(SizeInPixels {
width: 10,
height: 20,
}))),
Rc::new(RefCell::new(KittyImageStore::default())),
)
}
fn test_placement(y: isi... |
rust_dataset_chunk_513351 | rust_dataset.txt | 513,351 | 512 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
let out = crop_rgba(&src, 4, 4, 1, 1, 2, 2);
assert_eq!(out, raster(&[5, 6, 9, 10]));
}
#[test]
fn changed_chunks_for_placement_straddling_changed_rect() {
let mut grid = test_grid();
grid.placements.push(test_placement(30, 40));
let mut changed... |
rust_dataset_chunk_513352 | rust_dataset.txt | 513,352 | 512 | let chunk = &chunks[0];
assert_eq!(chunk.cell_x, 0);
assert_eq!(chunk.cell_y, 0);
assert_eq!(chunk.source_px_x, 0);
assert_eq!(chunk.source_px_y, 20);
assert_eq!(chunk.source_px_width, 20);
assert_eq!(chunk.source_px_height, 40);
}
#[test]
fn changed_chunks_shift_cell_coordinates_by_viewpor... |
rust_dataset_chunk_513353 | rust_dataset.txt | 513,353 | 512 | _eq!(chunk.source_px_y, 20);
assert_eq!(chunk.source_px_height, 20);
assert_eq!(chunk.scaled_image.unwrap().size, (20, 40));
}
#[test]
fn changed_chunks_propagate_emit_offsets_of_clipped_placement() {
let mut grid = test_grid();
let mut placement = test_placement(100, 20);
placement.emit_y = 20;
... |
rust_dataset_chunk_513354 | rust_dataset.txt | 513,354 | 512 | (), 3);
assert_eq!(grid.placements[0].display_rect.y, 0);
assert_eq!(grid.placements[1].display_rect.y, 60);
assert_eq!(grid.placements[1].display_rect.height, 40);
assert_eq!(grid.placements[2].display_rect.y, 180);
}
#[test]
fn region_scroll_inner_region_moves_inside_and_clips_straddler() {
let m... |
rust_dataset_chunk_513355 | rust_dataset.txt | 513,355 | 512 | 20));
grid.apply_region_scroll(0, 80, -20, 0, 0, false);
assert_eq!(grid.placements.len(), 0);
}
fn transmitted(
grid: &mut KittyGrid,
width: u32,
height: u32,
) -> (u32, super::super::store::InternalImageId) {
let command = KittyCommand {
image_id: Some(1),
pixel_width: Some(wi... |
rust_dataset_chunk_513356 | rust_dataset.txt | 513,356 | 512 | its_from_the_origin_of_its_cropped_variant() {
let mut grid = test_grid();
let (pane_image_id, internal) = transmitted(&mut grid, 64, 64);
let command = KittyCommand {
image_id: Some(1),
source_x: 8,
source_y: 10,
source_w: 16,
source_h: 20,
columns: 2,
... |
rust_dataset_chunk_513357 | rust_dataset.txt | 513,357 | 512 | ed(),
sequence.final_char(),
);
let params: Vec<Vec<u16>> = sequence.parameters().iter().map(|p| p.to_vec()).collect();
self.events.push(format!(
"hook({:?},{:?},{},{:?})",
params, intermediates, ignore, action
));
}
fn put(&mut self, byte: u8)... |
rust_dataset_chunk_513358 | rust_dataset.txt | 513,358 | 512 | : usize) -> (Vec<Vec<u8>>, RecordingPerformer) {
let mut interceptor = KittyApcInterceptor::new();
let mut parser = crate::vt_parser::Parser::new();
let mut performer = RecordingPerformer::default();
let mut captured = Vec::new();
for chunk in input.chunks(chunk_size) {
feed(
&mu... |
rust_dataset_chunk_513359 | rust_dataset.txt | 513,359 | 512 | itty_streams_pass_through_byte_identically() {
let inputs: Vec<&[u8]> = vec![
b"\x1b_Xsome payload\x1b\\after",
b"\x1bPq#0;2;0;0;0#0~~@@vv@@~~@@~~$#1!14@\x1b\\",
"h\u{e9}llo\u{2192}".as_bytes(),
b"\x1b]0;t\x07",
];
for input in inputs {
let (captured, performer) = run... |
rust_dataset_chunk_513360 | rust_dataset.txt | 513,360 | 512 | usize::MAX);
assert!(captured.is_empty());
assert_eq!(
performer.events,
vec!["print('O')".to_string(), "print('K')".to_string()]
);
}
#[test]
fn can_and_sub_abort_capture_and_match_bare_vte() {
for abort_byte in [0x18u8, 0x1au8] {
let input = vec![0x1b, b'_', b'G', b'a', abort... |
rust_dataset_chunk_513361 | rust_dataset.txt | 513,361 | 512 | _size,
style,
0,
String::new(),
Rc::new(RefCell::new(LinkHandler::new())),
Rc::new(RefCell::new(None)),
sixel_image_store,
Rc::new(RefCell::new(KittyImageStore::default())),
terminal_emulator_colors,
terminal_emulator_color_codes,
None,
... |
rust_dataset_chunk_513362 | rust_dataset.txt | 513,362 | 512 | #[test]
fn scanning_ahead_to_the_next_escape_matches_the_byte_at_a_time_machine() {
let cases: Vec<Vec<u8>> = vec![
b"".to_vec(),
b"plain text with no escapes at all".to_vec(),
b"\x1b".to_vec(),
b"\x1b\x1b\x1b".to_vec(),
b"text\x1b".to_vec(),
b"\x1b[31mcoloured\x1b[m"... |
rust_dataset_chunk_513363 | rust_dataset.txt | 513,363 | 512 | x52,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x08, 0x06, 0x00, 0x00, 0x00, 0x72, 0xb6, 0x0d,
0x24, 0x00, 0x00, 0x00, 0x12, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0x63, 0xf8, 0xcf, 0xc0, 0xf0,
0x1f, 0x0c, 0x81, 0x34, 0x18, 0x00, 0x00, 0x49, 0xc8, 0x09, 0xf7, 0x03, 0xd9, 0x64, 0xf1, 0x00,
0x00, 0x00,... |
rust_dataset_chunk_513364 | rust_dataset.txt | 513,364 | 512 | _fields() {
let command = parse_control_data(b"q=2,a=T,z=-1,C=1,f=24,s=2,v=2,m=1").unwrap();
assert_eq!(command.quiet, 2);
assert_eq!(command.action, KittyAction::TransmitAndDisplay);
assert_eq!(command.z_index, -1);
assert!(command.suppress_cursor_movement);
assert_eq!(command.format, KittyForm... |
rust_dataset_chunk_513365 | rust_dataset.txt | 513,365 | 512 | _eq!(image.height, 2);
assert!(!command.more_chunks);
assert_eq!(command.image_id, Some(7));
assert!(!parser.has_pending());
}
#[test]
fn delete_between_chunks_aborts_upload_and_returns_the_delete() {
let raster = raster_12_bytes();
let full_b64 = b64(&raster);
let chunk_one = &full_b64[..8];
... |
rust_dataset_chunk_513366 | rust_dataset.txt | 513,366 | 512 | _png_format_is_einval() {
let mut parser = KittyCommandParser::new();
let err = parse_one(&mut parser, &raw_cmd("a=T,f=100", b"this is not a png")).unwrap_err();
assert_eq!(err.code, KittyErrorCode::Einval);
}
#[test]
fn raw_payload_with_insufficient_bytes_is_enodata() {
let mut parser = KittyCommandPa... |
rust_dataset_chunk_513367 | rust_dataset.txt | 513,367 | 512 | ..=10).collect::<Vec<u8>>()).unwrap();
let mut parser = KittyCommandParser::new();
let command = parse_one(
&mut parser,
&raw_cmd(
"a=T,t=f,f=24,s=1,v=1,O=4,S=3",
path.to_str().unwrap().as_bytes(),
),
)
.unwrap();
assert_eq!(command.data_offset, Some(4... |
rust_dataset_chunk_513368 | rust_dataset.txt | 513,368 | 512 | ).unwrap_err();
assert_eq!(err.code, KittyErrorCode::Enotsupported);
}
}
#[test]
fn oversized_dimensions_are_einval() {
let mut parser = KittyCommandParser::new();
let err = parse_one(&mut parser, b"a=T,f=24,s=10001,v=1;AAAA").unwrap_err();
assert_eq!(err.code, KittyErrorCode::Einval);
let ... |
rust_dataset_chunk_513369 | rust_dataset.txt | 513,369 | 512 | command.image.unwrap().bytes, raster);
assert!(!path.exists());
}
#[test]
fn temp_file_medium_outside_temp_dir_is_not_deleted() {
let raster = raster_12_bytes();
let dir = tempfile::Builder::new()
.prefix("kitty-parser-test")
.tempdir_in(env!("CARGO_MANIFEST_DIR"))
.unwrap();
le... |
rust_dataset_chunk_513370 | rust_dataset.txt | 513,370 | 512 | =T,t=f,f=24,s=2,v=2,O=64,S=12",
path.to_str().unwrap().as_bytes(),
),
)
.unwrap();
assert_eq!(command.image.unwrap().bytes, raster_12_bytes());
}
#[test]
fn file_medium_offset_beyond_eof_is_ebadf() {
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("small.bin")... |
rust_dataset_chunk_513371 | rust_dataset.txt | 513,371 | 512 | fn temp_file_path_escaping_temp_dir_is_not_deleted() {
let raster = raster_12_bytes();
let dir = tempfile::Builder::new()
.prefix("kitty-parser-test")
.tempdir_in(env!("CARGO_MANIFEST_DIR"))
.unwrap();
let path = dir.path().join("tty-graphics-protocol-victim.bin");
std::fs::write... |
rust_dataset_chunk_513372 | rust_dataset.txt | 513,372 | 512 | store = KittyImageStore::default();
let id_a = store.store_image(rgba_image(2, 2)).unwrap();
let id_b = store.store_image(rgba_image(2, 2)).unwrap();
assert!(id_b > id_a);
assert_eq!(id_b, id_a + 1);
assert_eq!(store.image_count(), 2);
assert_eq!(store.total_bytes(), 32);
}
#[test]
fn lru_zero... |
rust_dataset_chunk_513373 | rust_dataset.txt | 513,373 | 512 | .get(id_c).is_some());
assert_eq!(store.total_bytes(), 800);
}
#[test]
fn single_image_exceeding_quota_is_refused_with_einval_and_store_unchanged() {
let mut store = KittyImageStore::with_quota(1000);
let id_a = store.store_image(rgba_image(10, 10)).unwrap();
let result = store.store_image(rgba_image(2... |
rust_dataset_chunk_513374 | rust_dataset.txt | 513,374 | 512 | _scaled_variant(id_a, second, vec![0; 60]);
store.add_scaled_variant(id_a, first, vec![0; 100]);
assert_eq!(store.total_bytes(), 640);
assert_eq!(store.scaled_variant(id_a, first).unwrap().len(), 100);
store.free(id_a);
assert_eq!(store.total_bytes(), 80);
store.free(id_b);
assert_eq!(store.... |
rust_dataset_chunk_513375 | rust_dataset.txt | 513,375 | 512 | id = store
.store_image(DecodedImage {
bytes: (1..=12).collect(),
width: 2,
height: 2,
format: KittyFormat::Rgb24,
})
.unwrap();
let image = store.get(id).unwrap();
assert_eq!(
image.rgba,
vec![1, 2, 3, 255, 4, 5, 6, 255, 7... |
rust_dataset_chunk_513376 | rust_dataset.txt | 513,376 | 512 | (self.link_index);
self.links.insert(self.link_index, Link { id, uri });
self.link_index += 1;
anchor
})
} else {
// there is no link, so consider it a link end
Some(LinkAnchor::End)
}
}
pub fn new_link_from_url... |
rust_dataset_chunk_513377 | rust_dataset.txt | 513,377 | 512 | = link_handler.dispatch_osc8(¶ms);
match anchor {
Some(LinkAnchor::Start(link_id)) => {
let link = link_handler.links.get(&link_id).expect("link was not some");
assert_eq!(link.id, Some("test".to_string()));
assert_eq!(link.uri, uri);
... |
rust_dataset_chunk_513378 | rust_dataset.txt | 513,378 | 512 | zellij_utils::graphemes::{self, display_width};
use crate::output::CharacterChunk;
use crate::panes::terminal_character::{
AnsiCode, RcCharacterStyles, TerminalCharacter, RESET_STYLES,
};
#[derive(Debug, Clone, Default)]
pub struct GuestModalShortcuts {
pub zoom: Vec<String>,
pub ascend: Vec<String>,
... |
rust_dataset_chunk_513379 | rust_dataset.txt | 513,379 | 512 | (cell);
used += width;
}
}
}
while used < block_end {
characters.push(TerminalCharacter::new_singlewidth_styled(
' ',
block_fill.clone(),
));
used += 1;
}
while used < columns {
characters.push(TerminalCharacter:... |
rust_dataset_chunk_513380 | rust_dataset.txt | 513,380 | 512 | {
words.push(("+".to_string(), fill_styles.clone()));
}
words.push((format!("<{}>", key), keycode_styles.clone()));
}
words
}
fn guest_modal_text_words(text: &str, styles: RcCharacterStyles) -> Vec<GuestModalSegment> {
text.split_whitespace()
.map(|word| (word.to_string... |
rust_dataset_chunk_513381 | rust_dataset.txt | 513,381 | 512 | for row in 0..rows {
chunks.push(guest_modal_empty_row(
columns,
content_x,
content_y + row,
fill_styles.clone(),
));
}
let layout = guest_modal_layout(
columns,
rows,
&styles,
session_name,
selected,
... |
rust_dataset_chunk_513382 | rust_dataset.txt | 513,382 | 512 | Code::from(base_declaration.background)))
.bold(Some(AnsiCode::On))
.into();
let option_title: RcCharacterStyles = RESET_STYLES
.foreground(Some(AnsiCode::from(base_declaration.emphasis_1)))
.background(Some(AnsiCode::from(base_declaration.background)))
.bold(Some(AnsiCode::O... |
rust_dataset_chunk_513383 | rust_dataset.txt | 513,383 | 512 | styles.keycode.clone()),
(" dismiss".to_string(), styles.fill.clone()),
];
let block_width = guest_modal_row_width(&fallback).min(columns);
let left_pad = center_modal_pad(block_width, columns);
GuestModalLayout {
rows: vec![GuestModalRow {
segments: fallback,
bl... |
rust_dataset_chunk_513384 | rust_dataset.txt | 513,384 | 512 | _width(option_title));
}
let block_width = block_width.min(columns);
let mut rows_content: Vec<GuestModalRow> = Vec::new();
let mut option_row_ranges: Vec<std::ops::Range<usize>> = Vec::new();
rows_content.push(GuestModalRow {
segments: title,
block_fill: styles.fill.clone(),
})... |
rust_dataset_chunk_513385 | rust_dataset.txt | 513,385 | 512 | (),
block_fill: styles.fill.clone(),
});
rows_content.push(GuestModalRow {
segments: hint_segments,
block_fill: styles.fill.clone(),
});
let block_height = rows_content.len();
if rows < block_height {
return guest_modal_fallback_layout(columns, rows, styles, session_... |
rust_dataset_chunk_513386 | rust_dataset.txt | 513,386 | 512 | use crate::tab::{AdjustedInput, Pane};
use crate::ui::{
loading_indication::LoadingIndication,
pane_boundaries_frame::{FrameParams, PaneFrame},
};
use crate::vt_parser;
use crate::ClientId;
use std::cell::RefCell;
use std::rc::Rc;
use zellij_utils::data::PaneContents;
use zellij_utils::data::{
BareKey, Bord... |
rust_dataset_chunk_513387 | rust_dataset.txt | 513,387 | 512 | {
pub pid: u32,
pub should_render: HashMap<ClientId, bool>,
pub selectable: bool,
pub geom: PaneGeom,
pub geom_override: Option<PaneGeom>,
pub content_offset: Offset,
pub send_plugin_instructions: SenderWithContext<PluginInstruction>,
pub active_at: Instant,
pub pane_title: String,
... |
rust_dataset_chunk_513388 | rust_dataset.txt | 513,388 | 512 | <Run>,
debug: bool,
arrow_fonts: bool,
styled_underlines: bool,
) -> Self {
let loading_indication = LoadingIndication::new(title.clone()).with_colors(style.colors);
let initial_loading_message = loading_indication.to_string();
let mut plugin = PluginPane {
... |
rust_dataset_chunk_513389 | rust_dataset.txt | 513,389 | 512 | self.content_offset.left
}
fn get_content_y(&self) -> usize {
self.y() + self.content_offset.top
}
fn get_content_columns(&self) -> usize {
// content columns might differ from the pane's columns if the pane has a frame
// in that case they would be 2 less
self.cols()
... |
rust_dataset_chunk_513390 | rust_dataset.txt | 513,390 | 512 | }
})
} else {
None
}
}
fn adjust_input_to_terminal(
&mut self,
key_with_modifier: &Option<KeyWithModifier>,
mut raw_input_bytes: Vec<u8>,
_raw_input_bytes_are_kitty: bool,
client_id: Option<ClientId>,
) -... |
rust_dataset_chunk_513391 | rust_dataset.txt | 513,391 | 512 | PastedText(pasted_text),
)]));
},
Err(e) => {
log::error!("Failed to convert pasted bytes as utf8 {:?}", e);
},
}
}
None
} else if let Some(pasted_text) = self.... |
rust_dataset_chunk_513392 | rust_dataset.txt | 513,392 | 512 | ImageChunk>,
)>,
> {
if client_id.is_none() {
return Ok(None);
}
if let Some(client_id) = client_id {
if self.should_render.get(&client_id).copied().unwrap_or(false) {
let content_x = self.get_content_x();
let content_y = self.g... |
rust_dataset_chunk_513393 | rust_dataset.txt | 513,393 | 512 | _color_override, _text)) = self.pane_frame_color_override.as_ref() {
frame.override_color(*frame_color_override);
}
let res = match self.frame.get(&client_id) {
// TODO: use and_then or something?
Some(last_frame) => {
if &frame != last_frame || is_pi... |
rust_dataset_chunk_513394 | rust_dataset.txt | 513,394 | 512 | _percent() {
self.geom.rows.set_percent(p + percent);
self.resize_grids();
self.set_should_render(true);
}
}
fn reduce_width(&mut self, percent: f64) {
if let Some(p) = self.geom.cols.as_percent() {
self.geom.cols.set_percent(p - percent);
... |
rust_dataset_chunk_513395 | rust_dataset.txt | 513,395 | 512 | {
self.send_plugin_instructions
.send(PluginInstruction::Update(vec![(
Some(self.pid),
Some(client_id),
Event::Mouse(Mouse::ScrollDown(count)),
)]))
.unwrap();
}
fn scroll_left(&mut self, count: usize, client_id: Client... |
rust_dataset_chunk_513396 | rust_dataset.txt | 513,396 | 512 | Update(vec![(
Some(self.pid),
Some(client_id),
Event::Mouse(Mouse::DoubleClick(position.line.0, position.column.0)),
)]))
.unwrap();
}
fn update_selection(&mut self, position: &Position, client_id: ClientId) {
if self.supports_mouse... |
rust_dataset_chunk_513397 | rust_dataset.txt | 513,397 | 512 | self) -> Offset {
self.content_offset
}
fn store_pane_name(&mut self) {
if self.pane_name != self.prev_pane_name {
self.prev_pane_name = self.pane_name.clone()
}
}
fn load_pane_name(&mut self) {
if self.pane_name != self.prev_pane_name {
self.pane... |
rust_dataset_chunk_513398 | rust_dataset.txt | 513,398 | 512 | we should only clear the highlight for this client
self.pane_frame_color_override = None;
}
fn frame_color_override(&self) -> Option<PaletteColor> {
self.pane_frame_color_override
.as_ref()
.map(|(color, _text)| *color)
}
fn invoked_with(&self) -> &Option<Run> {
... |
rust_dataset_chunk_513399 | rust_dataset.txt | 513,399 | 512 | grid.update_theme(theme.clone());
}
}
fn update_arrow_fonts(&mut self, should_support_arrow_fonts: bool) {
self.arrow_fonts = should_support_arrow_fonts;
for grid in self.grids.values_mut() {
grid.update_arrow_fonts(should_support_arrow_fonts);
}
s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.