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_519800 | rust_dataset.txt | 519,800 | 512 | _KIND_PLACEMENT: u8 = 1;
const GRAPHICS_KIND_DELETE_IMAGE: u8 = 2;
const GRAPHICS_KIND_DELETE_PLACEMENT: u8 = 3;
const GRAPHICS_KIND_CLEAR: u8 = 4;
const GRAPHICS_KIND_SIXEL: u8 = 5;
const RECORD_KIND_GEOMETRY: u8 = 6;
const RECORD_KIND_LINKS: u8 = 7;
const RECORD_KIND_SCROLL: u8 = 8;
const RECORD_KIND_CLUSTERS: u8 = 9... |
rust_dataset_chunk_519801 | rust_dataset.txt | 519,801 | 512 | 1 << 1;
const COLOR_DEFAULT: u32 = 0;
const COLOR_TAG_DEFAULT: u8 = 0;
const COLOR_TAG_NAMED: u8 = 1;
const COLOR_TAG_INDEXED: u8 = 2;
const COLOR_TAG_RGB: u8 = 3;
pub const ATTR_BOLD: u16 = 1 << 0;
pub const ATTR_DIM: u16 = 1 << 1;
pub const ATTR_ITALIC: u16 = 1 << 2;
pub const ATTR_REVERSE: u16 = 1 << 3;
pub const ... |
rust_dataset_chunk_519802 | rust_dataset.txt | 519,802 | 512 | for WireCell {
fn default() -> Self {
Self::BLANK
}
}
impl WireCell {
pub const BLANK: WireCell = WireCell {
ch: ' ' as u32,
fg: COLOR_DEFAULT,
bg: COLOR_DEFAULT,
underline_color: COLOR_DEFAULT,
attrs: 0,
width: 1,
link: LINK_NONE,
};
... |
rust_dataset_chunk_519803 | rust_dataset.txt | 519,803 | 512 | , b1, b2, b3, u0, u1, u2, u3, a0, a1, self.width,
self.link,
]
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum WireColor {
Default,
Named(u8),
Indexed(u8),
Rgb(u8, u8, u8),
}
impl WireColor {
pub fn pack(self) -> u32 {
match self {
WireColor::D... |
rust_dataset_chunk_519804 | rust_dataset.txt | 519,804 | 512 | Medium::SharedFile),
_ => None,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum GraphicsRecord {
Residency {
id: u64,
width: u32,
height: u32,
format: u32,
medium: GraphicsMedium,
byte_len: u32,
data: Vec<u8>,
},
Placemen... |
rust_dataset_chunk_519805 | rust_dataset.txt | 519,805 | 512 | => GRAPHICS_KIND_DELETE_PLACEMENT,
GraphicsRecord::Clear => GRAPHICS_KIND_CLEAR,
GraphicsRecord::SixelChunk { .. } => GRAPHICS_KIND_SIXEL,
}
}
fn medium(&self) -> u8 {
match self {
GraphicsRecord::Residency { medium, .. } => medium.encode(),
_ =>... |
rust_dataset_chunk_519806 | rust_dataset.txt | 519,806 | 512 | 0,
] {
put_u32(out, value);
}
out.extend_from_slice(payload);
},
}
}
fn decode(kind: u8, medium: u8, payload: &[u8]) -> Option<Self> {
match kind {
GRAPHICS_KIND_RESIDENCY => {
let data_... |
rust_dataset_chunk_519807 | rust_dataset.txt | 519,807 | 512 | )?,
pixel_width: take_u32(payload, 16)?,
pixel_height: take_u32(payload, 20)?,
payload: payload.get(32..32 + payload_len)?.to_vec(),
})
},
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default... |
rust_dataset_chunk_519808 | rust_dataset.txt | 519,808 | 512 | 32, y as u32);
let left = x < self.content_x() as u32;
let right = x >= self.content_x() as u32 + self.content_cols() as u32;
let above = y < self.content_y() as u32;
let below = y >= self.content_y() as u32 + self.content_rows() as u32;
match (left || right, above || below) {
... |
rust_dataset_chunk_519809 | rust_dataset.txt | 519,809 | 512 | = self
.x
.saturating_add(self.cols)
.saturating_sub(self.right as u16);
let content_bottom = self
.y
.saturating_add(self.rows)
.saturating_sub(self.bottom as u16);
let right = visible_right.saturating_sub(content_right.min(visibl... |
rust_dataset_chunk_519810 | rust_dataset.txt | 519,810 | 512 | PointerKind {
Arrow,
Text,
Hand,
Move,
ColResize,
RowResize,
NwseResize,
NeswResize,
}
#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub struct GeometryRecord {
pub panes: Vec<PaneRect>,
}
impl GeometryRecord {
pub fn pane_at(&self, x: u16, y: u16) -> Option<&PaneRect> {
... |
rust_dataset_chunk_519811 | rust_dataset.txt | 519,811 | 512 | }
return PointerKind::Move;
}
}
let inert = match top {
Some(pane) => pane.under_floating(),
None => self.panes.iter().any(|pane| pane.under_floating()),
};
if inert && !ctrl {
return PointerKind::Arrow;
... |
rust_dataset_chunk_519812 | rust_dataset.txt | 519,812 | 512 | es: self
.panes
.iter()
.filter_map(|pane| pane.clip_to(cols, rows))
.collect(),
}
}
fn encode_payload(&self, out: &mut Vec<u8>) {
out.extend_from_slice(&(self.panes.len() as u16).to_le_bytes());
out.extend_from_slice(&(GEO... |
rust_dataset_chunk_519813 | rust_dataset.txt | 519,813 | 512 | _HEADER_LEN)?;
let entry_count = u16::from_le_bytes([header[0], header[1]]) as usize;
let entry_header_len = u16::from_le_bytes([header[2], header[3]]) as usize;
if entry_header_len < LINK_ENTRY_HEADER_LEN {
return None;
}
let mut at = LINKS_HEADER_LEN;
let mu... |
rust_dataset_chunk_519814 | rust_dataset.txt | 519,814 | 512 | as i32, i16::MAX as i32) as i16,
}),
}
}
fn encode_payload(&self, out: &mut Vec<u8>) {
out.extend_from_slice(&(self.entries.len() as u16).to_le_bytes());
out.extend_from_slice(&(SCROLL_ENTRY_LEN as u16).to_le_bytes());
put_u32(out, 0);
for entry in &self.ent... |
rust_dataset_chunk_519815 | rust_dataset.txt | 519,815 | 512 | rows {
return;
}
let (x, y) = (self.x as usize, self.y as usize);
let (width, height, lines) = (self.cols as usize, self.rows as usize, self.lines as usize);
for row in y..y + height {
let target = row * cols + x;
if row + lines < y + height {
... |
rust_dataset_chunk_519816 | rust_dataset.txt | 519,816 | 512 | at = index.checked_mul(entry_len)?;
let entry = entries.get(at..at.checked_add(entry_len)?)?;
let value = |i: usize| u16::from_le_bytes([entry[2 * i], entry[2 * i + 1]]);
record.entries.push(ShiftEntry {
x: value(0),
y: value(1),
cols:... |
rust_dataset_chunk_519817 | rust_dataset.txt | 519,817 | 512 | {
return None;
}
let mut at = CLUSTERS_HEADER_LEN;
let mut entries: Vec<ClusterEntry> = Vec::with_capacity(entry_count.min(4096));
for _ in 0..entry_count {
let entry_header = payload.get(at..at.checked_add(entry_header_len)?)?;
let id = u16::from_le_... |
rust_dataset_chunk_519818 | rust_dataset.txt | 519,818 | 512 | mem::take(&mut self.record)
}
}
fn record_is_decodable(version: u8, kind: u8, medium: u8, payload: &[u8]) -> bool {
match kind {
RECORD_KIND_CLUSTERS => {
version >= FIRST_VERSION_WITH_CLUSTERS && ClusterRecord::decode(payload).is_some()
},
RECORD_KIND_GEOMETRY => GeometryRe... |
rust_dataset_chunk_519819 | rust_dataset.txt | 519,819 | 512 | , Eq)]
pub enum DecodeError {
TooShort,
UnsupportedVersion(u8),
BadSection,
CellCountMismatch,
RowOutOfRange,
CellsExhausted,
BadGraphicsRecord,
}
impl Display for DecodeError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
DecodeError::TooShort ... |
rust_dataset_chunk_519820 | rust_dataset.txt | 519,820 | 512 | self.push_record(RECORD_KIND_CLUSTERS, GRAPHICS_MEDIUM_INLINE, |out| {
record.encode_payload(out)
});
}
pub fn set_full_repaint(&mut self, full_repaint: bool) {
self.set_flag(FLAG_FULL_REPAINT, full_repaint);
}
pub fn set_clear(&mut self, clear: bool) {
self... |
rust_dataset_chunk_519821 | rust_dataset.txt | 519,821 | 512 | FnOnce(&mut Vec<u8>)) {
let start = self.graphics.len();
self.graphics.push(kind);
self.graphics.push(medium);
self.graphics.extend_from_slice(&0u16.to_le_bytes());
self.graphics.extend_from_slice(&0u32.to_le_bytes());
payload(&mut self.graphics);
let payload_len... |
rust_dataset_chunk_519822 | rust_dataset.txt | 519,822 | 512 | let graphics_offset = align_up(cells_offset + cells_len, 4);
let graphics_len = self.graphics.len();
let sideband_offset = graphics_offset + graphics_len;
let total = sideband_offset + self.sideband.len();
let mut frame = Vec::with_capacity(total);
frame.push(WIRE_VERSIO... |
rust_dataset_chunk_519823 | rust_dataset.txt | 519,823 | 512 | ],
buffer[offset + 1],
buffer[offset + 2],
buffer[offset + 3],
])
};
let version = buffer[0];
if !(OLDEST_WIRE_VERSION..=WIRE_VERSION).contains(&version) {
return Err(DecodeError::UnsupportedVersion(version));
}
let mut seq_bytes = [0u8; 8];
se... |
rust_dataset_chunk_519824 | rust_dataset.txt | 519,824 | 512 | usize;
let sideband_end = sideband_offset
.checked_add(header.sideband_len as usize)
.ok_or(DecodeError::BadSection)?;
if sideband_offset < graphics_end || sideband_end > buffer.len() {
return Err(DecodeError::BadSection);
}
let mut at = graphics_offset;
while at < graphics... |
rust_dataset_chunk_519825 | rust_dataset.txt | 519,825 | 512 | header, buffer };
let mut clusters: Option<ClusterRecord> = None;
let mut at = cells_offset;
while at < cells_end {
let ch = u32::from_le_bytes([buffer[at], buffer[at + 1], buffer[at + 2], buffer[at + 3]]);
if ch >= CLUSTER_CH_BASE {
let record = clusters.get_or_insert_with(|| v... |
rust_dataset_chunk_519826 | rust_dataset.txt | 519,826 | 512 | usize;
let mut geometry = None;
let mut at = start;
while at < end {
let header_end = at + GRAPHICS_RECORD_HEADER_LEN;
let payload_len = u32::from_le_bytes([
self.buffer[at + 4],
self.buffer[at + 5],
self.buffer[at + 6],
... |
rust_dataset_chunk_519827 | rust_dataset.txt | 519,827 | 512 | }
}
at = align_up(payload_end, 4);
}
clusters.entries.sort_by_key(|entry| entry.id);
clusters
}
pub fn shifts(&self) -> ShiftRecord {
let start = self.header.graphics_offset as usize;
let end = start + self.header.graphics_len as usize;
l... |
rust_dataset_chunk_519828 | rust_dataset.txt | 519,828 | 512 | _le_bytes([self.buffer[base], self.buffer[base + 1]]),
x0: u16::from_le_bytes([self.buffer[base + 2], self.buffer[base + 3]]),
len: u16::from_le_bytes([self.buffer[base + 4], self.buffer[base + 5]]),
}
}
pub fn rows(&self) -> RowIter<'_, 'a> {
RowIter {
view:... |
rust_dataset_chunk_519829 | rust_dataset.txt | 519,829 | 512 | attrs: u16::from_le_bytes([chunk[16], chunk[17]]),
width: chunk[18],
link: chunk[19],
}
}
}
pub struct RowIter<'v, 'a> {
view: &'v FrameView<'a>,
index: usize,
cursor: usize,
}
impl<'v, 'a> Iterator for RowIter<'v, 'a> {
type Item = (RowRecord, Vec<WireCell>);
... |
rust_dataset_chunk_519830 | rust_dataset.txt | 519,830 | 512 | return *id;
}
let id = self.cluster_texts.len() as u32;
self.cluster_texts.push(text.to_owned());
self.cluster_ids.insert(text.to_owned(), id);
id
}
pub fn dimensions(&self) -> (usize, usize) {
(self.cols, self.rows)
}
pub fn resize(&mut self, cols: usi... |
rust_dataset_chunk_519831 | rust_dataset.txt | 519,831 | 512 | }
if header.full_repaint() || header.clear() {
self.scroll.entries.clear();
self.cells
.iter_mut()
.for_each(|cell| *cell = WireCell::BLANK);
self.spans.iter_mut().for_each(Vec::clear);
}
let clusters = frame.clusters();... |
rust_dataset_chunk_519832 | rust_dataset.txt | 519,832 | 512 | _CH_BASE {
let text = cluster_texts
.get((cell.ch - CLUSTER_CH_BASE) as usize)
.map(|text| text.as_str())
.unwrap_or(" ");
cell.ch = builder
... |
rust_dataset_chunk_519833 | rust_dataset.txt | 519,833 | 512 |
}
}
fn run(text: &str) -> Vec<WireCell> {
text.chars().map(cell).collect()
}
fn grid(cols: usize, rows: usize, frame: &[u8]) -> Vec<WireCell> {
let view = decode(frame).expect("the frame should decode");
let mut destination = vec![WireCell::BLANK; cols * rows];
... |
rust_dataset_chunk_519834 | rust_dataset.txt | 519,834 | 512 | builder.sideband_mut().extend_from_slice(b"\x1b_Gq=2\x1b\\");
let frame = builder.finish();
let view = decode(&frame).unwrap();
let header = *view.header();
assert_eq!(header.version, WIRE_VERSION);
assert_eq!((header.cols, header.rows), (8, 3));
assert_eq!(header.seq, ... |
rust_dataset_chunk_519835 | rust_dataset.txt | 519,835 | 512 | << UNDERLINE_SHIFT),
width: 2,
link: 17,
};
let mut builder = FrameBuilder::new(4, 1, 1);
builder.push_row(0, 0, &[styled, WireCell::BLANK]);
let frame = builder.finish();
let cells = grid(4, 1, &frame);
assert_eq!(cells[0], styled);
asse... |
rust_dataset_chunk_519836 | rust_dataset.txt | 519,836 | 512 | 4, 1, &frame), 4, 0), " ab");
}
#[test]
fn a_run_outside_the_viewport_is_dropped_entirely() {
let mut builder = FrameBuilder::new(4, 2, 0);
builder.push_row(2, 0, &run("gone"));
builder.push_row(0, 4, &run("gone"));
builder.push_row(0, 0, &[]);
let frame = builder.f... |
rust_dataset_chunk_519837 | rust_dataset.txt | 519,837 | 512 | !(view.geometry().unwrap().panes.len(), 1);
assert!(view.scroll().is_empty());
}
#[test]
fn a_scroll_record_in_a_frame_of_the_previous_wire_version_is_rejected() {
let mut builder = FrameBuilder::new(4, 1, 0);
builder.push_scroll(&scroll(&[(0, 2)]));
let mut frame = builder.... |
rust_dataset_chunk_519838 | rust_dataset.txt | 519,838 | 512 | _past_the_end[36..40].copy_from_slice(&1024u32.to_le_bytes());
assert_eq!(
error_of(&graphics_past_the_end),
Some(DecodeError::BadSection)
);
let mut sideband_past_the_end = frame.clone();
sideband_past_the_end[44..48].copy_from_slice(&1024u32.to_le_bytes());
... |
rust_dataset_chunk_519839 | rust_dataset.txt | 519,839 | 512 | 0), "aabb ");
assert_eq!(text_of(&cells, 6, 1), " zz");
}
#[test]
fn overlapping_and_adjacent_spans_are_unioned_into_one_record() {
let mut overlay = PendingOverlay::new(8, 1);
overlay.merge_row(0, 0, &run("ab"));
overlay.merge_row(0, 2, &run("cd"));
overlay.merg... |
rust_dataset_chunk_519840 | rust_dataset.txt | 519,840 | 512 | (1, 0, &run("two"));
second.set_cursor(CursorState {
x: 5,
y: 1,
shape: CURSOR_SHAPE_UNDERLINE,
visible: true,
});
second.sideband_mut().extend_from_slice(b"BB");
let second = second.finish();
let mut overlay = PendingOverlay::new(... |
rust_dataset_chunk_519841 | rust_dataset.txt | 519,841 | 512 | }
#[test]
fn an_overlay_that_absorbs_a_reshaped_frame_adopts_the_new_dimensions() {
let mut builder = FrameBuilder::new(3, 1, 1);
builder.push_row(0, 0, &run("abc"));
let frame = builder.finish();
let mut overlay = PendingOverlay::new(8, 4);
overlay.merge_row(3, 0, ... |
rust_dataset_chunk_519842 | rust_dataset.txt | 519,842 | 512 | 11,
cell_y: 12,
pixel_x: 13,
pixel_y: 14,
pixel_width: 15,
pixel_height: 16,
payload: b"\x1bP0;1;0q#0;2;100;0;0~\x1b\\".to_vec(),
},
];
let mut builder = FrameBuilder::new(4, 2, 0);
build... |
rust_dataset_chunk_519843 | rust_dataset.txt | 519,843 | 512 | FrameBuilder::new(4, 1, 0);
builder.push_graphics(&GraphicsRecord::DeleteImage { id: 1 });
let mut frame = builder.finish();
let at = decode(&frame).unwrap().header().graphics_offset as usize;
frame[at] = 99;
assert_eq!(error_of(&frame), Some(DecodeError::BadGraphicsRecord));
... |
rust_dataset_chunk_519844 | rust_dataset.txt | 519,844 | 512 | ,
right: 0,
flags: PANE_WANTS_MOUSE,
},
PaneRect {
x: 0,
y: 20,
cols: 80,
rows: 1,
top: 0,
bottom: 0,
left: ... |
rust_dataset_chunk_519845 | rust_dataset.txt | 519,845 | 512 | assert_eq!(hits, vec![45, 46, 47]);
assert!(!floating.pin_button_contains(46, 6));
let tiled = pane(10, 5, 40, 10, 0);
assert!(!tiled.pin_button_contains(46, 5));
}
#[test]
fn only_an_unfocused_popup_leaves_the_rest_of_the_screen_alone() {
let mut record = GeometryRecord {
... |
rust_dataset_chunk_519846 | rust_dataset.txt | 519,846 | 512 | let frame = builder.finish();
assert_eq!(decode(&frame).unwrap().geometry(), None);
}
#[test]
fn an_empty_geometry_record_survives_the_wire_as_an_empty_list() {
let mut builder = FrameBuilder::new(4, 1, 0);
builder.push_geometry(&GeometryRecord::default());
let frame... |
rust_dataset_chunk_519847 | rust_dataset.txt | 519,847 | 512 | !(!framed.content_contains(10, 4));
assert!(framed.content_contains(11, 5));
assert!(framed.content_contains(28, 10));
assert!(!framed.content_contains(29, 10));
assert!(!framed.contains(30, 4));
}
#[test]
fn the_topmost_pane_owns_a_cell_two_panes_share() {
let recor... |
rust_dataset_chunk_519848 | rust_dataset.txt | 519,848 | 512 | , 10, 0),
pane(0, 10, 40, 10, 0),
],
};
let clipped = record.clip_to(30, 10);
assert_eq!(clipped.panes.len(), 2);
assert_eq!(clipped.panes[0].cols, 20);
assert_eq!(clipped.panes[1].cols, 10);
}
#[test]
fn a_later_geometry_record_supersedes... |
rust_dataset_chunk_519849 | rust_dataset.txt | 519,849 | 512 | builder.push_geometry(&record);
let frame = builder.finish();
let mut overlay = PendingOverlay::new(8, 4);
overlay.merge_frame(&decode(&frame).unwrap());
assert!(overlay.is_dirty());
assert_eq!(decode(&overlay.drain(2)).unwrap().geometry(), Some(record));
assert!(!overl... |
rust_dataset_chunk_519850 | rust_dataset.txt | 519,850 | 512 | = builder.finish();
let view = decode(&frame).expect("the frame should decode");
assert_eq!(view.links(), links);
assert_eq!(view.geometry(), Some(geometry));
assert_eq!(view.graphics(), vec![GraphicsRecord::Clear]);
}
#[test]
fn a_frame_without_a_link_table_reports_an_emp... |
rust_dataset_chunk_519851 | rust_dataset.txt | 519,851 | 512 | _LEN + 4) as u16).to_le_bytes());
put_u32(&mut payload, 0);
payload.push(9);
payload.push(0);
payload.extend_from_slice(&(uri.len() as u16).to_le_bytes());
payload.extend_from_slice(&[0xde, 0xad, 0xbe, 0xef]);
payload.extend_from_slice(uri.as_bytes());
let record... |
rust_dataset_chunk_519852 | rust_dataset.txt | 519,852 | 512 | entries: vec![link(1, "https://second")],
});
let mut overlay = PendingOverlay::new(8, 2);
overlay.merge_frame(&decode(&first.finish()).unwrap());
overlay.merge_frame(&decode(&second.finish()).unwrap());
assert!(overlay.is_dirty());
let drained = overlay.drain(3);
... |
rust_dataset_chunk_519853 | rust_dataset.txt | 519,853 | 512 | 2, "https://gone")],
});
let mut second = FrameBuilder::new(8, 2, 2);
second.set_full_repaint(true);
second.push_links(&LinkRecord {
entries: vec![link(1, "https://after")],
});
let mut overlay = PendingOverlay::new(8, 2);
overlay.merge_frame(&decode(... |
rust_dataset_chunk_519854 | rust_dataset.txt | 519,854 | 512 | builder.push_geometry(&GeometryRecord {
panes: vec![pane(0, 0, 8, 2, 0)],
});
builder.push_scroll(&scroll(&[(0, 1)]));
builder.push_links(&LinkRecord {
entries: vec![link(1, "https://example.com")],
});
let frame = builder.finish();
let view = dec... |
rust_dataset_chunk_519855 | rust_dataset.txt | 519,855 | 512 | 1, 5), (2, -1)]));
record.add(2, 1);
assert_eq!(record, scroll(&[(1, 5)]));
record.add(1, 0);
assert_eq!(record, scroll(&[(1, 5)]));
}
fn scroll_frame(seq: u64, entries: &[(u16, i16)]) -> Vec<u8> {
let mut builder = FrameBuilder::new(4, 2, seq);
builder.push_row(... |
rust_dataset_chunk_519856 | rust_dataset.txt | 519,856 | 512 | decode(&reshaped.finish()).unwrap());
overlay.merge_frame(&decode(&scroll_frame(3, &[(0, 1)])).unwrap());
let drained = overlay.drain(4);
let view = decode(&drained).unwrap();
assert!(view.geometry().is_some());
assert!(view.scroll().is_empty());
}
#[test]
fn an_over... |
rust_dataset_chunk_519857 | rust_dataset.txt | 519,857 | 512 | 1F468}\u{200D}", 2, 0);
let family_middle = cluster_cell(&mut builder, "\u{1F469}\u{200D}", 2, ATTR_GROUP_CONTINUE);
let family_tail = WireCell {
ch: '\u{1F467}' as u32,
width: 2,
attrs: ATTR_GROUP_CONTINUE,
..WireCell::BLANK
};
let filler ... |
rust_dataset_chunk_519858 | rust_dataset.txt | 519,858 | 512 | , 1);
let first = builder.cluster("e\u{0301}").unwrap();
let second = builder.cluster("e\u{0301}").unwrap();
let third = builder.cluster("a\u{0301}").unwrap();
assert_eq!(first, second);
assert_ne!(first, third);
let cells: Vec<WireCell> = [first, second, third]
... |
rust_dataset_chunk_519859 | rust_dataset.txt | 519,859 | 512 | | (id, entry.as_slice())).collect();
assert!(ClusterRecord::decode(&graphics_payload_with_clusters(&many)).is_none());
assert_eq!(
ClusterRecord::decode(&graphics_payload_with_clusters(&[(3, b"ok")]))
.unwrap()
.get(3),
Some("ok")
);
}
... |
rust_dataset_chunk_519860 | rust_dataset.txt | 519,860 | 512 | row0.1), vec!["a\u{0301}", "b\u{0301}"]);
assert_eq!(texts(&view, &row1.1), vec!["c\u{0301}", "b\u{0301}"]);
assert_eq!(view.clusters().entries.len(), 3);
}
}
--- FILE: zellij/zellij-utils/src/unit/graphemes_tests.rs ---
use super::*;
const FAMILY: &str = "\u{1F468}\u{200D}\u{1F469}\u{200D}\u{1F4... |
rust_dataset_chunk_519861 | rust_dataset.txt | 519,861 | 512 | E}", 1),
("\u{00AD}", 0),
("\u{17D8}", 3),
];
for (text, width) in cases {
assert_eq!(display_width(text), *width, "text={:?}", text);
}
}
#[test]
fn clusters_keep_sequences_whole() {
let text = format!("a{}{}b", FAMILY, FLAG_DE);
let parts: Vec<(&str, usize)> = clusters(&te... |
rust_dataset_chunk_519862 | rust_dataset.txt | 519,862 | 512 | ={:?}", max, truncated);
}
assert_no_split(&text, &truncated);
}
}
#[test]
fn truncate_middle_never_splits_a_cluster() {
let text = format!("{}{}abcdef{}{}", FAMILY, KSSA, E_ACUTE, FLAG_DE);
for max in 0..14 {
let truncated = truncate_middle(&text, max, "…");
let width = dis... |
rust_dataset_chunk_519863 | rust_dataset.txt | 519,863 | 512 | assert_eq!(next_cluster_end(&text, 1), family_end);
assert_eq!(previous_cluster_start(&text, family_end), 1);
assert_eq!(previous_cluster_start(&text, 1), 0);
}
#[test]
fn strip_control_characters_keeps_clusters() {
let text = format!("a\u{1b}]0;x\u{07}{}\n", FAMILY);
assert_eq!(strip_control_chara... |
rust_dataset_chunk_519864 | rust_dataset.txt | 519,864 | 512 | _keyboard_protocol: false,
}),
ViewerMessage::Input(MirrorInput::Key {
key: KeyWithModifier::new(BareKey::Char('x')).with_ctrl_modifier(),
raw_bytes: vec![24],
is_kitty_keyboard_protocol: true,
}),
ViewerMessage::Input(MirrorInput::Bytes(b"abc".to_vec(... |
rust_dataset_chunk_519865 | rust_dataset.txt | 519,865 | 512 | reason: MirrorClosedReason::PaneNotFound,
detail: "terminal_9".to_owned(),
},
];
for message in messages {
assert_eq!(SourceMessage::decode(&message.encode()), Ok(message));
}
}
#[test]
fn an_empty_or_garbled_message_is_an_error() {
assert_eq!(ViewerMessage::decode(&[]), Er... |
rust_dataset_chunk_519866 | rust_dataset.txt | 519,866 | 512 | [0].x0, records[0].len), (1, 3, 1));
let applied = viewer.apply_frame(&frame.bytes).unwrap();
assert!(!applied.full);
assert_eq!(
applied.changed_rows.into_iter().collect::<Vec<_>>(),
vec![1]
);
assert_eq!(text_of(&viewer, 1), "secXnd");
assert_eq!(viewer, changed);
}
#[test]
fn... |
rust_dataset_chunk_519867 | rust_dataset.txt | 519,867 | 512 | link: None,
};
source.cells[2] = MirrorCell::plain(WireCell {
ch: ' ' as u32,
width: 1,
..WireCell::BLANK
});
source.cells[3] = MirrorCell::plain(WireCell {
ch: '中' as u32,
width: 2,
..WireCell::BLANK
});
source.wants_mouse = true;
let mut enc... |
rust_dataset_chunk_519868 | rust_dataset.txt | 519,868 | 512 | 1, &["5"]);
assert!(pacer.wants_frame(5));
let catch_up = pacer.next_frame(5, &latest).expect("catch-up frame");
assert!(catch_up.full);
assert!(!pacer.has_skipped());
assert_eq!(MirrorScreen::from_frame(&catch_up.bytes).unwrap(), latest);
}
#[test]
fn an_unchanged_pane_is_not_snapshotted_again() {... |
rust_dataset_chunk_519869 | rust_dataset.txt | 519,869 | 512 | &["a"]))
.unwrap();
assert!(!pacer.acknowledge(frame.seq));
assert_eq!(pacer.unacknowledged(), 0);
let next = pacer
.next_frame(2, &screen_with_text(2, 1, &["b"]))
.unwrap();
assert!(!next.full);
}
#[test]
fn a_requested_full_repaint_is_honoured() {
let source = screen_with... |
rust_dataset_chunk_519870 | rust_dataset.txt | 519,870 | 512 | as u16 + 1,
rows: 2
})
);
let frame = FrameBuilder::new(4, MAX_MIRROR_ROWS as u16 + 1, 0).finish();
assert!(MirrorScreen::from_frame(&frame).is_err());
}
#[test]
fn the_pin_lease_is_three_renewal_intervals() {
if std::env::var(MIRROR_PIN_LEASE_ENV_VAR).is_ok() {
return;
... |
rust_dataset_chunk_519871 | rust_dataset.txt | 519,871 | 512 | _KEY = 1 << 12;
}
}
impl Modifiers {
pub fn encode_xterm(self) -> u8 {
let mut number = 0;
if self.contains(Self::SHIFT) {
number |= 1;
}
if self.contains(Self::ALT) {
number |= 2;
}
if self.contains(Self::CTRL) {
number |= 4;
... |
rust_dataset_chunk_519872 | rust_dataset.txt | 519,872 | 512 | ' => '\x11',
'R' | 'r' => '\x12',
'S' | 's' => '\x13',
'T' | 't' => '\x14',
'U' | 'u' => '\x15',
'V' | 'v' => '\x16',
'W' | 'w' => '\x17',
'X' | 'x' => '\x18',
'Y' | 'y' => '\x19',
'Z' | 'z' => '\x1a',
'[' | '3' | '{' => '\x1b',
'\\... |
rust_dataset_chunk_519873 | rust_dataset.txt | 519,873 | 512 | reply emitted by the
/// host terminal (not a keyboard event). This variant is only produced
/// for a deliberately narrow whitelist of final bytes — `t` (pixel
/// dimensions reply), `y` (DECRPM reply), `c` (Primary-DA reply), and
/// `n` (DSR reply). The raw field contains the exact byte sequence of
... |
rust_dataset_chunk_519874 | rust_dataset.txt | 519,874 | 512 | an entry for things that might be possible in this first pass.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum KeyCode {
/// The decoded unicode character
Char(char),
Hyper,
Super,
Meta,
/// Ctrl-break on windows
Cancel,
Backspace,
Tab,
Clear,
Enter,
Shift,... |
rust_dataset_chunk_519875 | rust_dataset.txt | 519,875 | 512 | .is_ascii_lowercase() => KeyCode::Char(c.to_ascii_uppercase()),
_ => self,
}
} else {
self
}
}
/// Return true if the key represents a modifier key.
pub fn is_modifier(self) -> bool {
matches!(
self,
Self::Hyper
... |
rust_dataset_chunk_519876 | rust_dataset.txt | 519,876 | 512 | , mods, &modes)?;
},
Char(c) if mods.contains(Modifiers::CTRL) && modes.modify_other_keys == Some(2) => {
csi_u_encode(&mut buf, c, mods, &modes)?;
},
Char(c) if mods.contains(Modifiers::CTRL) && ctrl_mapping(c).is_some() => {
let c = ctrl... |
rust_dataset_chunk_519877 | rust_dataset.txt | 519,877 | 512 | );
}
}
},
Tab if !mods.is_empty() && modes.modify_other_keys.is_some() => {
csi_u_encode(&mut buf, '\t', mods, &modes)?;
},
Tab => {
if mods.contains(Modifiers::ALT) {
buf.push(0x1b ... |
rust_dataset_chunk_519878 | rust_dataset.txt | 519,878 | 512 | "{}{}", csi_or_ss3, c)?;
}
},
PageUp | PageDown | KeyPadPageUp | KeyPadPageDown | Insert | Delete => {
let c = match key {
Insert => 2,
Delete => 3,
KeyPadPageUp | PageUp => 5,
KeyPa... |
rust_dataset_chunk_519879 | rust_dataset.txt | 519,879 | 512 | 24",
13 => "\x1b[25",
14 => "\x1b[26",
15 => "\x1b[28",
16 => "\x1b[29",
17 => "\x1b[31",
18 => "\x1b[32",
19 => "\x1b[33",
20 =... |
rust_dataset_chunk_519880 | rust_dataset.txt | 519,880 | 512 | term();
if encoded_mods == 0 {
write!(buf, "{}{}", CSI, c)?;
} else {
write!(buf, "{}1;{}{}", CSI, 1 + encoded_mods, c)?;
}
},
Multiply | Add | Separator | Subtract | Divide => {},
// Modifier k... |
rust_dataset_chunk_519881 | rust_dataset.txt | 519,881 | 512 | !(buf, "\x1b[27;{};{}~", 1 + mods.encode_xterm(), c as u32)?;
return Ok(());
},
_ => {},
}
let c = if mods.contains(Modifiers::CTRL) && ctrl_mapping(c).is_some() {
ctrl_mapping(c).unwrap()
} else {
c
};
if mods.contains(Modifiers::ALT) {
buf.push(... |
rust_dataset_chunk_519882 | rust_dataset.txt | 519,882 | 512 | (b'M', 33) => Some(MouseButton::Button2Drag),
(b'M', 34) => Some(MouseButton::Button3Drag),
(b'M', 35) | (b'm', 35) | (b'M', 3) | (b'm', 3) => Some(MouseButton::None),
_ => ::core::option::Option::None,
}
}
impl From<MouseButton> for MouseButtons {
fn from(button: MouseButton) -> Mouse... |
rust_dataset_chunk_519883 | rust_dataset.txt | 519,883 | 512 | let params_str = std::str::from_utf8(&rest[..term_pos]).ok()?;
// Parse three semicolon-separated integers
let mut parts = params_str.splitn(3, ';');
let p0: i64 = parts.next()?.parse().ok()?;
let p1: i64 = parts.next()?.parse().ok()?;
let p2: i64 = parts.next()?.parse().ok()?;
let button ... |
rust_dataset_chunk_519884 | rust_dataset.txt | 519,884 | 512 | <final>` per ECMA-48 §5.4),
/// regardless of whether the final byte is one we have a use for. Used by
/// `process_bytes` to advance past CSI sequences the keymap doesn't
/// recognise — most importantly Kitty keyboard-protocol events
/// `\x1b[<keycode>;<mods>u`. Without this, the keymap returns
/// `Found::NeedData... |
rust_dataset_chunk_519885 | rust_dataset.txt | 519,885 | 512 | , then intermediates (0x20..=0x2F),
// then a final byte (0x40..=0x7E). We only scan up to a reasonable
// length to avoid pathological buffers.
let max_scan = buf.len().min(256);
while i < max_scan {
let b = buf[i];
match b {
// Parameters: digits, `;`, `:`, `?`, `<`, `=`, `... |
rust_dataset_chunk_519886 | rust_dataset.txt | 519,886 | 512 | buf.get(2..i).unwrap_or_default().to_vec();
return Some((InputEvent::OperatingSystemCommand(payload), i + 2));
}
// Bare ESC inside OSC — malformed, but don't consume further
return None;
},
Some(_) => {
i += 1;... |
rust_dataset_chunk_519887 | rust_dataset.txt | 519,887 | 512 | _ => match event.wVirtualKeyCode as i32 {
winuser::VK_CANCEL => KeyCode::Cancel,
winuser::VK_BACK => KeyCode::Backspace,
winuser::VK_TAB => KeyCode::Tab,
winuser::VK_CLEAR => KeyCode::Clear,
winuser::VK_RETURN => KeyCod... |
rust_dataset_chunk_519888 | rust_dataset.txt | 519,888 | 512 | Numpad9,
winuser::VK_MULTIPLY => KeyCode::Multiply,
winuser::VK_ADD => KeyCode::Add,
winuser::VK_SEPARATOR => KeyCode::Separator,
winuser::VK_SUBTRACT => KeyCode::Subtract,
winuser::VK_DECIMAL => KeyCode::Decimal,
... |
rust_dataset_chunk_519889 | rust_dataset.txt | 519,889 | 512 | ::RightMenu,
winuser::VK_BROWSER_BACK => KeyCode::BrowserBack,
winuser::VK_BROWSER_FORWARD => KeyCode::BrowserForward,
winuser::VK_BROWSER_REFRESH => KeyCode::BrowserRefresh,
winuser::VK_BROWSER_STOP => KeyCode::BrowserStop,
... |
rust_dataset_chunk_519890 | rust_dataset.txt | 519,890 | 512 | 8) != 0 {
buttons |= MouseButtons::WHEEL_POSITIVE;
}
} else if (event.dwEventFlags & MOUSE_HWHEELED) != 0 {
buttons |= MouseButtons::HORZ_WHEEL;
if (event.dwButtonState >> 8) != 0 {
buttons |= MouseButtons::WHEEL_POSITI... |
rust_dataset_chunk_519891 | rust_dataset.txt | 519,891 | 512 | ifiers::ALT | Modifiers::SHIFT),
(";5", Modifiers::CTRL),
(";6", Modifiers::CTRL | Modifiers::SHIFT),
(";7", Modifiers::CTRL | Modifiers::ALT),
(";8", Modifiers::CTRL | Modifiers::ALT | Modifiers::SHIFT),
];
let meta = Modifiers::ALT;
let meta_modi... |
rust_dataset_chunk_519892 | rust_dataset.txt | 519,892 | 512 | let key = format!("\x1b[27{};{}~", suffix, c);
map.insert(
key,
InputEvent::Key(KeyEvent {
key: match c {
8 | 0x7f => KeyCode::Backspace,
0x1b => KeyCode::Esca... |
rust_dataset_chunk_519893 | rust_dataset.txt | 519,893 | 512 | (KeyCode::ApplicationLeftArrow, b'D'),
] {
// Arrow keys in application cursor mode encoded using SS3
let app = [0x1b, b'O', *dir];
map.insert(
&app,
InputEvent::Key(KeyEvent {
key: *keycode,
... |
rust_dataset_chunk_519894 | rust_dataset.txt | 519,894 | 512 | // F11-F14 encoded as 23-26
(11..=14, 12),
// F15-F16 encoded as 28-29
(15..=16, 13),
// F17-F20 encoded as 31-34
(17..=20, 14),
] {
for n in range.clone() {
for (suffix, modifiers) in modifier_combos_including_meta() {
... |
rust_dataset_chunk_519895 | rust_dataset.txt | 519,895 | 512 | modifiers: Modifiers::NONE,
}),
);
map.insert(
b"\x1b[Z",
InputEvent::Key(KeyEvent {
key: KeyCode::Tab,
modifiers: Modifiers::SHIFT,
}),
);
map.insert(
&[b'\r'],
InputEvent::Key(KeyE... |
rust_dataset_chunk_519896 | rust_dataset.txt | 519,896 | 512 | c, len) = Self::first_char_and_len(s);
Some((c, len))
} else {
None
}
},
}
}
fn dispatch_callback<F: FnMut(InputEvent, usize)>(
&mut self,
mut callback: F,
event: InputEvent,
) {
// `... |
rust_dataset_chunk_519897 | rust_dataset.txt | 519,897 | 512 | , whitelisted CSI host-reply) that the upcoming bytes
/// match — those sequences are autonomous host events and cannot be
/// ALT-combined with the parked ESC, so the ESC must be flushed
/// before the sequence is emitted.
fn flush_parked_esc_if_held<F: FnMut(InputEvent, usize)>(&mut self, callback: &m... |
rust_dataset_chunk_519898 | rust_dataset.txt | 519,898 | 512 | // as Alt+`[`.
if self.buf.as_slice().get(0) == Some(&b'\x1b') {
if let Some((event, len)) = parse_sgr_mouse(self.buf.as_slice()) {
self.flush_parked_esc_if_held(&mut callback);
self.buf.advance(len);... |
rust_dataset_chunk_519899 | rust_dataset.txt | 519,899 | 512 | // following keypress. Buffer up the escape key and
// consume it from the input. dispatch_callback() will
// emit either the ESC or the ALT modified following key.
(
Found::Exact(
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.