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_1900 | rust_dataset.txt | 1,900 | 512 |
/// │ RESIZE BUFFER │
/// │ │
/// ├─────────────────────────┤ <-- self.history_size() + lines
/// │ │
/// │ SCROLLUP REGION │
/// │ │
/// ├─────────────────────────┤v lines
/// │ │|
/// │ VISIBLE REG... |
rust_dataset_chunk_1901 | rust_dataset.txt | 1,901 | 512 | _size;
}
pub fn scroll_display(&mut self, scroll: Scroll) {
self.display_offset = match scroll {
Scroll::Delta(count) => {
min(max((self.display_offset as i32) + count, 0) as usize, self.history_size())
},
Scroll::PageUp => min(self.display_offset + s... |
rust_dataset_chunk_1902 | rust_dataset.txt | 1,902 | 512 | {
self.raw.swap(i, i - positions as i32);
}
// Rotate the entire line buffer downward.
self.raw.rotate_down(positions);
// Ensure all new lines are fully cleared.
for i in (0..positions).map(Line::from) {
self.raw[i].reset(&s... |
rust_dataset_chunk_1903 | rust_dataset.txt | 1,903 | 512 | swapped with
// each other.
for i in (0..region.start.0).rev().map(Line::from) {
self.raw.swap(i, i + positions);
}
// Rotate the entire line buffer upward.
self.raw.rotate(-(positions as isize));
// Swap the fixed lines at the b... |
rust_dataset_chunk_1904 | rust_dataset.txt | 1,904 | 512 | _lines() as i32);
for line in range.map(Line::from) {
self.raw[line].reset(&self.cursor.template);
}
}
}
impl<T> Grid<T> {
/// Reset a visible region within the grid.
pub fn reset_region<D, R: RangeBounds<Line>>(&mut self, bounds: R)
where
T: ResetDiscriminant<D> + G... |
rust_dataset_chunk_1905 | rust_dataset.txt | 1,905 | 512 | calling `Grid::iter_from` in combination with
/// `Iterator::take_while`.
#[inline]
pub fn display_iter(&self) -> GridIterator<'_, T> {
let last_column = self.last_column();
let start = Point::new(Line(-(self.display_offset() as i32) - 1), last_column);
let end_line = min(start.line... |
rust_dataset_chunk_1906 | rust_dataset.txt | 1,906 | 512 | fn columns(&self) -> usize;
/// Index for the last column.
#[inline]
fn last_column(&self) -> Column {
Column(self.columns() - 1)
}
/// Line farthest up in the grid history.
#[inline]
fn topmost_line(&self) -> Line {
Line(-(self.history_size() as i32))
}
/// Line ... |
rust_dataset_chunk_1907 | rust_dataset.txt | 1,907 | 512 | Indexed<&'a T>;
fn next(&mut self) -> Option<Self::Item> {
// Stop once we've reached the end of the grid.
if self.point >= self.end {
return None;
}
match self.point {
Point { column, .. } if column >= self.grid.last_column() => {
self.poin... |
rust_dataset_chunk_1908 | rust_dataset.txt | 1,908 | 512 | ::term::cell::{Flags, ResetDiscriminant};
use crate::grid::row::Row;
use crate::grid::{Dimensions, Grid, GridCell};
impl<T: GridCell + Default + PartialEq> Grid<T> {
/// Resize the grid's width and/or height.
pub fn resize<D>(&mut self, reflow: bool, lines: usize, columns: usize)
where
T: ResetDis... |
rust_dataset_chunk_1909 | rust_dataset.txt | 1,909 | 512 |
/// bottom of the screen. This is achieved by pushing history "out the top"
/// of the terminal window.
///
/// Alacritty takes the same approach.
fn shrink_lines<D>(&mut self, target: usize)
where
T: ResetDiscriminant<D>,
D: PartialEq,
{
// Scroll up to keep content... |
rust_dataset_chunk_1910 | rust_dataset.txt | 1,910 | 512 | Remove wrap flag before appending additional cells.
if let Some(cell) = last_row.last_mut() {
cell.flags_mut().remove(Flags::WRAPLINE);
}
// Remove leading spacers when reflowing wide char to the previous line.
let mut last_len = last_row.len();
... |
rust_dataset_chunk_1911 | rust_dataset.txt | 1,911 | 512 | () {
if i < self.display_offset {
// Since we removed a line, rotate down the viewport.
self.display_offset = self.display_offset.saturating_sub(1);
}
// Rotate cursor down if content below them was pulled from history.
... |
rust_dataset_chunk_1912 | rust_dataset.txt | 1,912 | 512 | = false;
self.cursor.point.column += 1;
}
let mut new_raw = Vec::with_capacity(self.raw.len());
let mut buffered: Option<Vec<T>> = None;
let mut rows = self.raw.take_all();
for (i, mut row) in rows.drain(..).enumerate().rev() {
// Append lines left over... |
rust_dataset_chunk_1913 | rust_dataset.txt | 1,913 | 512 | the leading spacer from the end of the wrapped row.
wrapped[len - 2].flags_mut().insert(Flags::WRAPLINE);
wrapped.truncate(len - 1);
}
}
new_raw.push(row);
// Set line as wrapped if cells got removed.
... |
rust_dataset_chunk_1914 | rust_dataset.txt | 1,914 | 512 | went off.
self.display_offset = min(self.display_offset, self.history_size());
// Reflow the primary cursor, or clamp it if reflow is disabled.
if !reflow {
self.cursor.point.column = min(self.cursor.point.column, Column(columns - 1));
} else if self.cursor.point.column == ... |
rust_dataset_chunk_1915 | rust_dataset.txt | 1,915 | 512 | () >= columns {
return;
}
self.inner.resize_with(columns, T::default);
}
/// Reduce the number of columns in the row.
///
/// This will return all non-empty cells that were removed.
pub fn shrink(&mut self, columns: usize) -> Option<Vec<T>>
where
T: GridCell... |
rust_dataset_chunk_1916 | rust_dataset.txt | 1,916 | 512 | self.inner.append(vec);
}
#[inline]
pub fn append_front(&mut self, mut vec: Vec<T>) {
self.occ += vec.len();
vec.append(&mut self.inner);
self.inner = vec;
}
/// Check if all cells in the row are empty.
#[inline]
pub fn is_clear(&self) -> bool
where
... |
rust_dataset_chunk_1917 | rust_dataset.txt | 1,917 | 512 | : Range<Column>) -> &mut [T] {
self.occ = max(self.occ, *index.end);
&mut self.inner[(index.start.0)..(index.end.0)]
}
}
impl<T> Index<RangeTo<Column>> for Row<T> {
type Output = [T];
#[inline]
fn index(&self, index: RangeTo<Column>) -> &[T] {
&self.inner[..(index.end.0)]
}... |
rust_dataset_chunk_1918 | rust_dataset.txt | 1,918 | 512 | occ = max(self.occ, *index.end + 1);
&mut self.inner[..=(index.end.0)]
}
}
--- FILE: alacritty/alacritty_terminal/src/grid/storage.rs ---
use std::cmp::max;
use std::mem;
use std::mem::MaybeUninit;
use std::ops::{Index, IndexMut};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use super:... |
rust_dataset_chunk_1919 | rust_dataset.txt | 1,919 | 512 | to grow the scrollback buffer
/// without any additional insertions.
len: usize,
}
impl<T: PartialEq> PartialEq for Storage<T> {
fn eq(&self, other: &Self) -> bool {
// Both storage buffers need to be truncated and zeroed.
assert_eq!(self.zero, 0);
assert_eq!(other.zero, 0);
... |
rust_dataset_chunk_1920 | rust_dataset.txt | 1,920 | 512 | ,
{
if self.len + additional_rows > self.inner.len() {
self.rezero();
let realloc_size = self.inner.len() + max(additional_rows, MAX_CACHE_SIZE);
self.inner.resize_with(realloc_size, || Row::new(columns));
}
self.len += additional_rows;
}
#[inli... |
rust_dataset_chunk_1921 | rust_dataset.txt | 1,921 | 512 | .rust-lang.org/std/vec/struct.Vec.html#method.rotate_left
#[inline]
pub fn rotate_down(&mut self, count: usize) {
self.zero = (self.zero + count) % self.inner.len();
}
/// Update the raw storage buffer.
#[inline]
pub fn replace_inner(&mut self, vec: Vec<Row<T>>) {
self.len = vec... |
rust_dataset_chunk_1922 | rust_dataset.txt | 1,922 | 512 | (test)]
mod tests {
use crate::grid::GridCell;
use crate::grid::row::Row;
use crate::grid::storage::{MAX_CACHE_SIZE, Storage};
use crate::index::{Column, Line};
use crate::term::cell::Flags;
impl GridCell for char {
fn is_empty(&self) -> bool {
*self == ' ' || *self == '\t'
... |
rust_dataset_chunk_1923 | rust_dataset.txt | 1,923 | 512 | 1: 1
/// 2: -
/// After:
/// 0: 0 <- Zero
/// 1: 1
/// 2: -
/// 3: \0
/// ...
/// MAX_CACHE_SIZE: \0
#[test]
fn grow_after_zero() {
// Setup storage area.
let mut storage: Storage<char> = Storage {
inner: vec![filled_row('0'), filled_row(... |
rust_dataset_chunk_1924 | rust_dataset.txt | 1,924 | 512 | filled_row('\0'); MAX_CACHE_SIZE]);
assert_eq!(storage.visible_lines, expected.visible_lines);
assert_eq!(storage.inner, expected.inner);
assert_eq!(storage.zero, expected.zero);
assert_eq!(storage.len, expected.len);
}
/// Shrink the buffer one line at the start of the buffer.... |
rust_dataset_chunk_1925 | rust_dataset.txt | 1,925 | 512 | _row('0'), filled_row('1'), filled_row('2')],
zero: 0,
visible_lines: 2,
len: 2,
};
assert_eq!(storage.visible_lines, expected.visible_lines);
assert_eq!(storage.inner, expected.inner);
assert_eq!(storage.zero, expected.zero);
assert_eq!(storag... |
rust_dataset_chunk_1926 | rust_dataset.txt | 1,926 | 512 | /// 3: 1
/// 4: 2 <- Hidden
/// 5: 3 <- Hidden
/// After:
/// 0: 0 <- Zero
/// 1: 1
#[test]
fn truncate_invisible_lines() {
// Setup storage area.
let mut storage: Storage<char> = Storage {
inner: vec![
filled_row('4'),
... |
rust_dataset_chunk_1927 | rust_dataset.txt | 1,927 | 512 | it again.
///
/// Before:
/// 0: 4
/// 1: 5
/// 2: 0 <- Zero
/// 3: 1
/// 4: 2
/// 5: 3
/// After Shrinking:
/// 0: 4 <- Hidden
/// 1: 5 <- Hidden
/// 2: 0 <- Zero
/// 3: 1
/// 4: 2
/// 5: 3 <- Hidden
/// After Growing:
/// 0... |
rust_dataset_chunk_1928 | rust_dataset.txt | 1,928 | 512 | len: 4,
};
assert_eq!(storage.inner, growing_expected.inner);
assert_eq!(storage.zero, growing_expected.zero);
assert_eq!(storage.len, growing_expected.len);
}
#[test]
fn initialize() {
// Setup storage area.
let mut storage: Storage<char> = Storage {
... |
rust_dataset_chunk_1929 | rust_dataset.txt | 1,929 | 512 | &Flags {
unimplemented!();
}
fn flags_mut(&mut self) -> &mut Flags {
unimplemented!();
}
}
// Scroll up moves lines upward.
#[test]
fn scroll_up() {
let mut grid = Grid::<usize>::new(10, 1, 0);
for i in 0..10 {
grid[Line(i as i32)][Column(0)] = i;
}
grid.scroll_up... |
rust_dataset_chunk_1930 | rust_dataset.txt | 1,930 | 512 | (0)..Line(10)), 2);
assert_eq!(grid[Line(0)][Column(0)], 0); // was 8.
assert_eq!(grid[Line(0)].occ, 0);
assert_eq!(grid[Line(1)][Column(0)], 0); // was 9.
assert_eq!(grid[Line(1)].occ, 0);
assert_eq!(grid[Line(2)][Column(0)], 0);
assert_eq!(grid[Line(2)].occ, 1);
assert_eq!(grid[Line(3)][C... |
rust_dataset_chunk_1931 | rust_dataset.txt | 1,931 | 512 | )], 0);
assert_eq!(grid[Line(2)].occ, 1);
assert_eq!(grid[Line(3)][Column(0)], 1);
assert_eq!(grid[Line(3)].occ, 1);
assert_eq!(grid[Line(4)][Column(0)], 2);
assert_eq!(grid[Line(4)].occ, 1);
assert_eq!(grid[Line(5)][Column(0)], 3);
assert_eq!(grid[Line(5)].occ, 1);
assert_eq!(grid[Line(... |
rust_dataset_chunk_1932 | rust_dataset.txt | 1,932 | 512 | ().column);
assert_eq!(0, iter.point().line);
// Make sure iter.cell() returns the current iterator position.
assert_eq!(&4, iter.cell());
// Test that iter ends at end of grid.
let mut final_iter = grid.iter_from(Point { line: Line(4), column: Column(4) });
assert_eq!(None, final_iter.next())... |
rust_dataset_chunk_1933 | rust_dataset.txt | 1,933 | 512 | assert_eq!(grid.total_lines(), 3);
assert_eq!(grid[Line(-2)].len(), 2);
assert_eq!(grid[Line(-2)][Column(0)], cell('1'));
assert_eq!(grid[Line(-2)][Column(1)], wrap_cell('2'));
assert_eq!(grid[Line(-1)].len(), 2);
assert_eq!(grid[Line(-1)][Column(0)], cell('3'));
assert_eq!(grid[Line(-1)][... |
rust_dataset_chunk_1934 | rust_dataset.txt | 1,934 | 512 | !(grid[Line(-1)][Column(0)], wrap_cell('3'));
assert_eq!(grid[Line(0)].len(), 1);
assert_eq!(grid[Line(0)][Column(0)], cell('4'));
}
#[test]
fn grow_reflow() {
let mut grid = Grid::<Cell>::new(2, 2, 0);
grid[Line(0)][Column(0)] = cell('1');
grid[Line(0)][Column(1)] = wrap_cell('2');
grid[Line(... |
rust_dataset_chunk_1935 | rust_dataset.txt | 1,935 | 512 | ('2'));
assert_eq!(grid[Line(0)][Column(2)], cell('3'));
assert_eq!(grid[Line(0)][Column(3)], cell('4'));
assert_eq!(grid[Line(0)][Column(4)], cell('5'));
assert_eq!(grid[Line(0)][Column(5)], cell('6'));
// Make sure rest of grid is empty.
for r in (1..3).map(Line::from) {
assert_eq!(gr... |
rust_dataset_chunk_1936 | rust_dataset.txt | 1,936 | 512 | , 2);
assert_eq!(grid.total_lines(), 1);
assert_eq!(grid[Line(0)].len(), 2);
assert_eq!(grid[Line(0)][Column(0)], cell('1'));
assert_eq!(grid[Line(0)][Column(1)], cell('2'));
}
#[test]
fn accurate_size_hint() {
let grid = Grid::<Cell>::new(5, 5, 2);
size_hint_matches_count(grid.iter_from(Poi... |
rust_dataset_chunk_1937 | rust_dataset.txt | 1,937 | 512 | /// Horizontal direction.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum Direction {
Left,
Right,
}
impl Direction {
#[must_use]
pub fn opposite(self) -> Self {
match self {
Side::Right => Side::Left,
Side::Left => Side::Right,
}
}
}
/// Terminal grid... |
rust_dataset_chunk_1938 | rust_dataset.txt | 1,938 | 512 | point to a grid boundary.
#[inline]
#[must_use = "this returns the result of the operation, without modifying the original"]
pub fn grid_clamp<D>(mut self, dimensions: &D, boundary: Boundary) -> Self
where
D: Dimensions,
{
let last_column = dimensions.last_column();
self.col... |
rust_dataset_chunk_1939 | rust_dataset.txt | 1,939 | 512 | let screen_lines = dimensions.screen_lines() as i32;
let total_lines = dimensions.total_lines() as i32;
if self >= screen_lines {
let topmost_line = dimensions.topmost_line();
let extra = (self.0 - screen_lines) % total_lines;
... |
rust_dataset_chunk_1940 | rust_dataset.txt | 1,940 | 512 | ", self.0)
}
}
macro_rules! ops {
($ty:ty, $construct:expr, $primitive:ty) => {
impl Deref for $ty {
type Target = $primitive;
#[inline]
fn deref(&self) -> &$primitive {
&self.0
}
}
impl From<$primitive> for $ty {
... |
rust_dataset_chunk_1941 | rust_dataset.txt | 1,941 | 512 | $ty {
#[inline]
fn eq(&self, other: &$primitive) -> bool {
self.0.eq(other)
}
}
impl PartialOrd<$ty> for $primitive {
#[inline]
fn partial_cmp(&self, other: &$ty) -> Option<Ordering> {
self.partial_cmp(&other.0... |
rust_dataset_chunk_1942 | rust_dataset.txt | 1,942 | 512 | let point = Point::new(Line(0), Column(0));
let result = point.sub(&size, Boundary::Cursor, 1);
assert_eq!(result, point);
}
#[test]
fn sub_grid_clamp() {
let size = (0, 42);
let point = Point::new(Line(0), Column(0));
let result = point.sub(&size, Boundary::Grid... |
rust_dataset_chunk_1943 | rust_dataset.txt | 1,943 | 512 | }
}
--- FILE: alacritty/alacritty_terminal/src/lib.rs ---
//! Alacritty - The GPU Enhanced Terminal.
#![warn(rust_2018_idioms, future_incompatible)]
#![deny(clippy::all, clippy::if_not_else, clippy::enum_glob_use)]
#![cfg_attr(clippy, deny(warnings))]
pub mod event;
#[cfg(not(target_family = "wasm"))]
pub mod even... |
rust_dataset_chunk_1944 | rust_dataset.txt | 1,944 | 512 | { start, end, is_block }
}
}
impl SelectionRange {
/// Check if a point lies within the selection.
pub fn contains(&self, point: Point) -> bool {
self.start.line <= point.line
&& self.end.line >= point.line
&& (self.start.column <= point.column
|| (self.star... |
rust_dataset_chunk_1945 | rust_dataset.txt | 1,945 | 512 |
/// out to semantic boundaries as the selection point changes. Similarly, [`lines`] will always
/// expand the new point to encompass entire lines.
///
/// [`simple`]: enum.Selection.html#method.simple
/// [`block`]: enum.Selection.html#method.block
/// [`semantic`]: enum.Selection.html#method.semantic
/// [`lines`]: ... |
rust_dataset_chunk_1946 | rust_dataset.txt | 1,946 | 512 | end.point.line = min(end.point.line - delta, bottommost_line);
// Delete selection if end has overtaken the start.
if end.point.line < start.point.line {
return None;
}
// Clamp selection to end of region.
if end.point.line >= ran... |
rust_dataset_chunk_1947 | rust_dataset.txt | 1,947 | 512 | _start,
Bound::Excluded(&range_start) => range_start + 1,
Bound::Unbounded => Line(i32::MIN),
};
let range_bottom = match range.end_bound() {
Bound::Included(&range_end) => range_end,
Bound::Excluded(&range_end) => range_end - 1,
Bound::Unboun... |
rust_dataset_chunk_1948 | rust_dataset.txt | 1,948 | 512 | Range {
if start == end {
if let Some(matching) = term.bracket_search(start) {
if (matching.line == start.line && matching.column < start.column)
|| (matching.line < start.line)
{
start = matching;
} else {
... |
rust_dataset_chunk_1949 | rust_dataset.txt | 1,949 | 512 | if selection ends to the left of a cell.
if end.side == Side::Left && start.point != end.point && end.point.column.0 > 0 {
end.point.column -= 1;
}
// Remove first cell if selection starts at the right of a cell.
if start.side == Side::Right && start.point != end.point {
... |
rust_dataset_chunk_1950 | rust_dataset.txt | 1,950 | 512 | _to_left() {
let location = Point::new(Line(0), Column(0));
let mut selection = Selection::new(SelectionType::Simple, location, Side::Right);
selection.update(location, Side::Left);
assert_eq!(selection.to_range(&term(1, 2)).unwrap(), SelectionRange {
start: location,
... |
rust_dataset_chunk_1951 | rust_dataset.txt | 1,951 | 512 | Right);
assert_eq!(selection.to_range(&term(2, 5)).unwrap(), SelectionRange {
start: Point::new(Line(0), Column(2)),
end: Point::new(Line(1), Column(1)),
is_block: false,
});
}
#[rustfmt::skip]
/// Test selection across adjacent lines.
///
/// 1.... |
rust_dataset_chunk_1952 | rust_dataset.txt | 1,952 | 512 | );
let mut selection =
Selection::new(SelectionType::Semantic, Point::new(Line(9), Column(3)), Side::Left);
selection.update(Point::new(Line(4), Column(1)), Side::Right);
selection = selection.rotate(&size, &(Line(0)..Line(size.0 as i32)), 4).unwrap();
assert_eq!(selection.t... |
rust_dataset_chunk_1953 | rust_dataset.txt | 1,953 | 512 | selection.is_empty());
selection.update(Point::new(Line(0), Column(0)), Side::Right);
assert!(!selection.is_empty());
}
#[test]
fn block_is_empty() {
let mut selection =
Selection::new(SelectionType::Block, Point::new(Line(1), Column(0)), Side::Right);
assert!(se... |
rust_dataset_chunk_1954 | rust_dataset.txt | 1,954 | 512 | ), size.last_column()),
is_block: false,
});
}
#[test]
fn rotate_in_region_up_block() {
let size = (10, 5);
let mut selection =
Selection::new(SelectionType::Block, Point::new(Line(7), Column(3)), Side::Right);
selection.update(Point::new(Line(4), Col... |
rust_dataset_chunk_1955 | rust_dataset.txt | 1,955 | 512 | /// Acquire a lease to reserve the mutex lock.
///
/// This will prevent others from acquiring a terminal lock, but block if anyone else is
/// already holding a lease.
pub fn lease(&self) -> MutexGuard<'_, ()> {
self.next.lock()
}
/// Lock the mutex.
pub fn lock(&self) -> MutexGua... |
rust_dataset_chunk_1956 | rust_dataset.txt | 1,956 | 512 | = 0b0000_0000_0001_0000;
const WIDE_CHAR = 0b0000_0000_0010_0000;
const WIDE_CHAR_SPACER = 0b0000_0000_0100_0000;
const DIM = 0b0000_0000_1000_0000;
const DIM_BOLD = 0b0000_0000_1000_0010;
const HID... |
rust_dataset_chunk_1957 | rust_dataset.txt | 1,957 | 512 | }
}
impl From<Hyperlink> for VteHyperlink {
fn from(val: Hyperlink) -> Self {
VteHyperlink { id: Some(val.id().to_owned()), uri: val.uri().to_owned() }
}
}
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
struct HyperlinkInner {
/// Identifie... |
rust_dataset_chunk_1958 | rust_dataset.txt | 1,958 | 512 | Cell {
c: ' ',
bg: Color::Named(NamedColor::Background),
fg: Color::Named(NamedColor::Foreground),
flags: Flags::empty(),
extra: None,
}
}
}
impl Cell {
/// Zerowidth characters stored in this cell.
#[inline]
pub fn zerowidth(&... |
rust_dataset_chunk_1959 | rust_dataset.txt | 1,959 | 512 | ());
Arc::make_mut(extra).hyperlink = hyperlink;
}
}
/// Hyperlink stored in this cell.
#[inline]
pub fn hyperlink(&self) -> Option<Hyperlink> {
self.extra.as_ref()?.hyperlink.clone()
}
}
impl GridCell for Cell {
#[inline]
fn is_empty(&self) -> bool {
(s... |
rust_dataset_chunk_1960 | rust_dataset.txt | 1,960 | 512 | ::mem;
use crate::grid::Row;
use crate::index::Column;
#[test]
fn cell_size_is_below_cap() {
// Expected cell size on 64-bit architectures.
const EXPECTED_CELL_SIZE: usize = 24;
// Ensure that cell size isn't growing by accident.
assert!(mem::size_of::<Cell>() <= EXPEC... |
rust_dataset_chunk_1961 | rust_dataset.txt | 1,961 | 512 | #[inline]
fn index(&self, index: NamedColor) -> &Self::Output {
&self.0[index as usize]
}
}
impl IndexMut<NamedColor> for Colors {
#[inline]
fn index_mut(&mut self, index: NamedColor) -> &mut Self::Output {
&mut self.0[index as usize]
}
}
--- FILE: alacritty/alacritty_terminal... |
rust_dataset_chunk_1962 | rust_dataset.txt | 1,962 | 512 | : usize = 8;
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct TermMode: u32 {
const NONE = 0;
const SHOW_CURSOR = 1;
const APP_CURSOR = 1 << 1;
const APP_KEYPAD = 1 << 2;
const MOUSE_REPORT... |
rust_dataset_chunk_1963 | rust_dataset.txt | 1,963 | 512 | (TermMode::DISAMBIGUATE_ESC_CODES, disambiguate_esc_codes);
let report_event_types = value.contains(KeyboardModes::REPORT_EVENT_TYPES);
mode.set(TermMode::REPORT_EVENT_TYPES, report_event_types);
let report_alternate_keys = value.contains(KeyboardModes::REPORT_ALTERNATE_KEYS);
mode.set... |
rust_dataset_chunk_1964 | rust_dataset.txt | 1,964 | 512 | = Self::undamaged(self.line, num_cols);
}
#[inline]
pub fn expand(&mut self, left: usize, right: usize) {
self.left = cmp::min(self.left, left);
self.right = cmp::max(self.right, right);
}
#[inline]
pub fn is_damaged(&self) -> bool {
self.left <= self.right
}
}
//... |
rust_dataset_chunk_1965 | rust_dataset.txt | 1,965 | 512 | Reset point, so old cursor won't end up outside of the viewport.
self.last_cursor = Default::default();
self.full = true;
self.lines.clear();
self.lines.reserve(num_lines);
for line in 0..num_lines {
self.lines.push(LineDamageBounds::undamaged(line, num_cols));
... |
rust_dataset_chunk_1966 | rust_dataset.txt | 1,966 | 512 | : Option<String>,
/// Stack of saved window titles. When a title is popped from this stack, the `title` for the
/// term is set.
title_stack: Vec<Option<String>>,
/// The stack for the keyboard modes.
keyboard_mode_stack: Vec<KeyboardModes>,
/// Currently inactive keyboard mode stack.
ina... |
rust_dataset_chunk_1967 | rust_dataset.txt | 1,967 | 512 | _offset();
self.grid.scroll_display(scroll);
self.event_proxy.send_event(Event::MouseCursorDirty);
// Clamp vi mode cursor to the viewport.
let viewport_start = -(self.grid.display_offset() as i32);
let viewport_end = viewport_start + self.bottommost_line().0;
let vi_cur... |
rust_dataset_chunk_1968 | rust_dataset.txt | 1,968 | 512 | [`reset_damage`]: Self::reset_damage
#[must_use]
pub fn damage(&mut self) -> TermDamage<'_> {
// Ensure the entire terminal is damaged after entering insert mode.
// Leaving is handled in the ansi handler.
if self.mode.contains(TermMode::INSERT) {
self.mark_fully_damaged();
... |
rust_dataset_chunk_1969 | rust_dataset.txt | 1,969 | 512 | everything on config updates.
self.mark_fully_damaged();
}
/// Convert the active selection to a String.
pub fn selection_to_string(&self) -> Option<String> {
let selection_range = self.selection.as_ref().and_then(|s| s.to_range(self))?;
let SelectionRange { start, end, .. } = sele... |
rust_dataset_chunk_1970 | rust_dataset.txt | 1,970 | 512 | ER) {
cols.start -= 1;
}
let mut tab_mode = false;
for column in (cols.start.0..line_length.0).map(Column::from) {
let cell = &grid_line[column];
// Skip over cells until next tab-stop once a tab was found.
if tab_mode {
if self.t... |
rust_dataset_chunk_1971 | rust_dataset.txt | 1,971 | 512 | _lines = size.screen_lines();
if old_cols == num_cols && old_lines == num_lines {
debug!("Term::resize dimensions unchanged");
return;
}
debug!("New num_cols is {num_cols} and num_lines is {num_lines}");
// Move vi mode cursor with the content.
let hist... |
rust_dataset_chunk_1972 | rust_dataset.txt | 1,972 | 512 | .grid.cursor.clone();
// Drop information about the primary screens saved cursor.
self.grid.saved_cursor = self.grid.cursor.clone();
// Reset alternate screen contents.
self.inactive_grid.reset_region(..);
}
mem::swap(&mut self.keyboard_mode_stack, &mut... |
rust_dataset_chunk_1973 | rust_dataset.txt | 1,973 | 512 | lines as i32));
self.grid.scroll_up(®ion, lines);
// Scroll vi mode cursor.
let viewport_top = Line(-(self.grid.display_offset() as i32));
let top = if region.start == 0 { viewport_top } else { region.start };
let line = &mut self.vi_mode_cursor.point.line;
if (top ... |
rust_dataset_chunk_1974 | rust_dataset.txt | 1,974 | 512 | /// Move vi cursor to a point in the grid.
#[inline]
pub fn vi_goto_point(&mut self, point: Point)
where
T: EventListener,
{
// Move viewport to make point visible.
self.scroll_to_point(point);
// Move vi cursor to the point.
self.vi_mode_cursor.point = point... |
rust_dataset_chunk_1975 | rust_dataset.txt | 1,975 | 512 | {
point.column -= 1;
}
let prev = point.sub(self, Boundary::Grid, 1);
if self.grid[prev].flags.contains(Flags::LEADING_WIDE_CHAR_SPACER) {
point = prev;
}
},
_ => (),
}
poin... |
rust_dataset_chunk_1976 | rust_dataset.txt | 1,976 | 512 | if cursor_cell.flags.intersects(Flags::WIDE_CHAR | Flags::WIDE_CHAR_SPACER) {
// Remove wide char and spacer.
let wide = cursor_cell.flags.contains(Flags::WIDE_CHAR);
let point = self.grid.cursor.point;
if wide && point.column < self.last_column() {
... |
rust_dataset_chunk_1977 | rust_dataset.txt | 1,977 | 512 | never)]
fn input(&mut self, c: char) {
// Number of cells the char will occupy.
let width = match c.width() {
Some(width) => width,
None => return,
};
// Handle zero-width characters.
if width == 0 {
// Get previous column.
let... |
rust_dataset_chunk_1978 | rust_dataset.txt | 1,978 | 512 | following the wide glyph.
self.grid.cursor.point.column += 1;
self.grid.cursor.template.flags.insert(Flags::WIDE_CHAR_SPACER);
self.write_at_cursor(' ');
self.grid.cursor.template.flags.remove(Flags::WIDE_CHAR_SPACER);
}
if self.grid.cursor.point.column ... |
rust_dataset_chunk_1979 | rust_dataset.txt | 1,979 | 512 | ;
let destination = cursor.point.column.0 + count;
let num_cells = self.columns() - destination;
let line = cursor.point.line;
self.damage.damage_line(line.0 as usize, 0, self.columns() - 1);
let row = &mut self.grid[line][..];
for offset in (0..num_cells).rev() {
... |
rust_dataset_chunk_1980 | rust_dataset.txt | 1,980 | 512 | [?6c");
self.event_proxy.send_event(Event::PtyWrite(text));
},
Some('>') => {
trace!("Reporting secondary device attributes");
let version = version_number(env!("CARGO_PKG_VERSION"));
let text = format!("\x1b[>0;{version};1c");
... |
rust_dataset_chunk_1981 | rust_dataset.txt | 1,981 | 512 | trace!("Reporting device status: {arg}");
match arg {
5 => {
let text = String::from("\x1b[0n");
self.event_proxy.send_event(Event::PtyWrite(text));
},
6 => {
let pos = self.grid.cursor.point;
let text = ... |
rust_dataset_chunk_1982 | rust_dataset.txt | 1,982 | 512 | , column);
}
}
/// Carriage return.
#[inline]
fn carriage_return(&mut self) {
trace!("Carriage return");
let new_col = 0;
let line = self.grid.cursor.point.line.0 as usize;
self.damage.damage_line(line, new_col, self.grid.cursor.point.column.0);
self.grid... |
rust_dataset_chunk_1983 | rust_dataset.txt | 1,983 | 512 | feed();
if self.mode.contains(TermMode::LINE_FEED_NEW_LINE) {
self.carriage_return();
}
}
#[inline]
fn set_horizontal_tabstop(&mut self) {
trace!("Setting horizontal tabstop");
self.tabs[self.grid.cursor.point.column] = true;
}
#[inline]
fn scroll_u... |
rust_dataset_chunk_1984 | rust_dataset.txt | 1,984 | 512 | , columns - 1);
let num_cells = columns - end;
let line = cursor.point.line;
self.damage.damage_line(line.0 as usize, 0, self.columns() - 1);
let row = &mut self.grid[line][..];
for offset in 0..num_cells {
row.swap(start + offset, end + offset);
}
... |
rust_dataset_chunk_1985 | rust_dataset.txt | 1,985 | 512 | !("Restoring cursor position");
self.damage_cursor();
self.grid.cursor = self.grid.saved_cursor.clone();
self.damage_cursor();
}
#[inline]
fn clear_line(&mut self, mode: ansi::LineClearMode) {
trace!("Clearing line: {mode:?}");
let cursor = &self.grid.cursor;
... |
rust_dataset_chunk_1986 | rust_dataset.txt | 1,986 | 512 | terminator
)
}),
));
}
/// Reset the indexed color to original value.
#[inline]
fn reset_color(&mut self, index: usize) {
trace!("Resetting color[{index}]");
// Damage terminal if the color changed and it's not the cursor.
if index != NamedC... |
rust_dataset_chunk_1987 | rust_dataset.txt | 1,987 | 512 | .cursor.point;
// If clearing more than one line.
if cursor.line > 1 {
// Fully clear all lines before the current line.
self.grid.reset_region(..cursor.line);
}
// Clear up to the current column in the current lin... |
rust_dataset_chunk_1988 | rust_dataset.txt | 1,988 | 512 | ::Current => {
self.tabs[self.grid.cursor.point.column] = false;
},
ansi::TabulationClearMode::All => {
self.tabs.clear_all();
},
}
}
/// Reset all important fields in the term struct.
#[inline]
fn reset_state(&mut self) {
... |
rust_dataset_chunk_1989 | rust_dataset.txt | 1,989 | 512 | Color::Foreground);
cursor.template.bg = Color::Named(NamedColor::Background);
cursor.template.flags = Flags::empty();
cursor.template.set_underline_color(None);
},
Attr::Reverse => cursor.template.flags.insert(Flags::INVERSE),
Attr::Ca... |
rust_dataset_chunk_1990 | rust_dataset.txt | 1,990 | 512 | return;
},
};
trace!("Setting private mode: {mode:?}");
match mode {
NamedPrivateMode::UrgencyHints => self.mode.insert(TermMode::URGENCY_HINTS),
NamedPrivateMode::SwapScreenAndSetRestoreCursor => {
if !self.mode.contains(TermMode::ALT_SCREEN... |
rust_dataset_chunk_1991 | rust_dataset.txt | 1,991 | 512 | true;
self.event_proxy.send_event(Event::CursorBlinkingChange);
},
NamedPrivateMode::SyncUpdate => (),
}
}
#[inline]
fn unset_private_mode(&mut self, mode: PrivateMode) {
let mode = match mode {
PrivateMode::Named(mode) => mode,
... |
rust_dataset_chunk_1992 | rust_dataset.txt | 1,992 | 512 | _event(Event::CursorBlinkingChange);
},
NamedPrivateMode::SyncUpdate => (),
}
}
#[inline]
fn report_private_mode(&mut self, mode: PrivateMode) {
trace!("Reporting private mode {mode:?}");
let state = match mode {
PrivateMode::Named(mode) => match ... |
rust_dataset_chunk_1993 | rust_dataset.txt | 1,993 | 512 | b[?{};{}$y",
mode.raw(),
state as u8,
)));
}
#[inline]
fn set_mode(&mut self, mode: ansi::Mode) {
let mode = match mode {
ansi::Mode::Named(mode) => mode,
ansi::Mode::Unknown(mode) => {
debug!("Ignoring unknown mode {mode} in s... |
rust_dataset_chunk_1994 | rust_dataset.txt | 1,994 | 512 | // Bottom should be included in the range, but range end is not
// usually included. One option would be to use an inclusive
// range, but instead we just let the open range end be 1
// higher.
let start = Line(top as i32 - 1);
let end = Line(bottom as i32);
trace!("Set... |
rust_dataset_chunk_1995 | rust_dataset.txt | 1,995 | 512 | !("Pushing '{:?}' onto title stack", self.title);
if self.title_stack.len() >= TITLE_STACK_MAX_DEPTH {
let removed = self.title_stack.remove(0);
trace!(
"Removing '{removed:?}' from bottom of title stack that exceeds its maximum depth"
);
}
s... |
rust_dataset_chunk_1996 | rust_dataset.txt | 1,996 | 512 | ().enumerate() {
let semver_number = semver_version.parse::<usize>().unwrap_or(0);
version_number += usize::pow(100, i as u32) * semver_number;
}
version_number
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ClipboardType {
Clipboard,
Selection,
}
struct TabStops {
tabs: ... |
rust_dataset_chunk_1997 | rust_dataset.txt | 1,997 | 512 | { shape, point }
}
}
/// Visible terminal content.
///
/// This contains all content required to render the current terminal view.
pub struct RenderableContent<'a> {
pub display_iter: GridIterator<'a, Cell>,
pub selection: Option<SelectionRange>,
pub cursor: RenderableCursor,
pub display_offset: u... |
rust_dataset_chunk_1998 | rust_dataset.txt | 1,998 | 512 | <VoidListener> {
let lines: Vec<&str> = content.split('\n').collect();
let num_cols = lines
.iter()
.map(|line| line.chars().filter(|c| *c != '\r').map(|c| c.width().unwrap()).sum())
.max()
.unwrap_or(0);
// Create terminal with the appropriate di... |
rust_dataset_chunk_1999 | rust_dataset.txt | 1,999 | 512 | (-1), Column(0)));
assert_eq!(term.grid.display_offset(), 10);
// Scrollable amount to top is 1.
term.scroll_display(Scroll::PageUp);
assert_eq!(term.vi_mode_cursor.point, Point::new(Line(-2), Column(0)));
assert_eq!(term.grid.display_offset(), 11);
// Scrollable amount... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.