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_1600 | rust_dataset.txt | 1,600 | 512 | b, 0x2b),
green: Rgb::new(0x5f, 0x6f, 0x3a),
yellow: Rgb::new(0xa1, 0x7e, 0x4d),
blue: Rgb::new(0x45, 0x68, 0x77),
magenta: Rgb::new(0x70, 0x4d, 0x68),
cyan: Rgb::new(0x4d, 0x77, 0x70),
white: Rgb::new(0x8e, 0x8e, 0x8e),
}
}
}
--- FIL... |
rust_dataset_chunk_1601 | rust_dataset.txt | 1,601 | 512 | )
}
#[inline]
pub fn blink_interval(self) -> u64 {
cmp::max(self.blink_interval, MIN_BLINK_INTERVAL)
}
#[inline]
pub fn blink_timeout(self) -> Duration {
if self.blink_timeout == 0 {
Duration::ZERO
} else {
cmp::max(
// Show/hide ... |
rust_dataset_chunk_1602 | rust_dataset.txt | 1,602 | 512 | blinking == CursorBlinking::On || blinking == CursorBlinking::Always
}
}
#[derive(ConfigDeserialize, Serialize, Debug, Default, Eq, PartialEq, Copy, Clone, Hash)]
pub enum CursorShape {
#[default]
Block,
Underline,
Beam,
}
impl From<CursorShape> for VteCursorShape {
fn from(value: CursorShape... |
rust_dataset_chunk_1603 | rust_dataset.txt | 1,603 | 512 | /alacritty/src/config/font.rs ---
use std::fmt;
use crossfont::Size as FontSize;
use serde::de::{self, Visitor};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use alacritty_config_derive::{ConfigDeserialize, SerdeReplace};
use crate::config::ui_config::Delta;
/// Font config.
///
/// Defaults are p... |
rust_dataset_chunk_1604 | rust_dataset.txt | 1,604 | 512 | : Default::default(),
use_thin_strokes: Default::default(),
bold_italic: Default::default(),
italic: Default::default(),
offset: Default::default(),
normal: Default::default(),
bold: Default::default(),
size: Default::default(),
... |
rust_dataset_chunk_1605 | rust_dataset.txt | 1,605 | 512 | }
}
deserializer.deserialize_any(NumVisitor)
}
}
impl Serialize for Size {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_f32(self.0.as_pt())
}
}
--- FILE: alacritty/alacritty/src/config/general.rs ---... |
rust_dataset_chunk_1606 | rust_dataset.txt | 1,606 | 512 | ::bindings::{
Action, BindingKey, BindingMode, KeyBinding, MouseAction, MouseEvent, SearchAction, ViAction,
};
pub use crate::config::ui_config::UiConfig;
use crate::logging::LOG_TARGET_CONFIG;
/// Maximum number of depth for the configuration file imports.
pub const IMPORT_RECURSION_LIMIT: usize = 5;
/// Result ... |
rust_dataset_chunk_1607 | rust_dataset.txt | 1,607 | 512 | {
Error::Toml(val)
}
}
impl From<TomlSeError> for Error {
fn from(val: TomlSeError) -> Self {
Error::TomlSe(val)
}
}
impl From<YamlError> for Error {
fn from(val: YamlError) -> Self {
Error::Yaml(val)
}
}
/// Load the configuration file.
pub fn load(options: &mut Options)... |
rust_dataset_chunk_1608 | rust_dataset.txt | 1,608 | 512 | )
},
}
}
/// Deserialize configuration file from path.
fn read_config(path: &Path) -> Result<UiConfig> {
let mut config_paths = Vec::new();
let config_value = parse_config(path, &mut config_paths, IMPORT_RECURSION_LIMIT)?;
// Deserialize to concrete type.
let mut config = UiConfig::deseria... |
rust_dataset_chunk_1609 | rust_dataset.txt | 1,609 | 512 | return Value::Table(Table::new());
},
};
// Parse configs for all imports recursively.
let mut merged = Value::Table(Table::new());
for import_path in import_paths {
let path = match import_path {
Ok(path) => path,
Err(err) => {
error!... |
rust_dataset_chunk_1610 | rust_dataset.txt | 1,610 | 512 | )) = (import_path.strip_prefix("~/"), home::home_dir()) {
import_path = home_dir.join(stripped);
}
if import_path.is_relative() {
if let Some(base_config_dir) = base_config_path.parent() {
import_path = base_config_dir.join(import_path)
}
}
import_path
}
/// Prune ... |
rust_dataset_chunk_1611 | rust_dataset.txt | 1,611 | 512 | if let Ok(home) = env::var("HOME") {
// Fallback path: $HOME/.config/alacritty/alacritty.toml.
let fallback = PathBuf::from(&home).join(".config/alacritty").join(&file_name);
if fallback.exists() {
return Some(fallback);
}
... |
rust_dataset_chunk_1612 | rust_dataset.txt | 1,612 | 512 | er;
use std::hash::{Hash, Hasher};
use std::path::PathBuf;
use std::sync::mpsc::{self, RecvTimeoutError, Sender};
use std::thread::JoinHandle;
use std::time::{Duration, Instant};
use log::{debug, error, warn};
use notify::event::{ModifyKind, RenameMode};
use notify::{
Config, Error as NotifyError, Event as NotifyE... |
rust_dataset_chunk_1613 | rust_dataset.txt | 1,613 | 512 | atcher) => watcher,
Err(err) => {
error!("Unable to watch config file: {err}");
return None;
},
};
let join_handle = thread::spawn_named("config watcher", move || {
// Get all unique parent directories.
let mut parents = pa... |
rust_dataset_chunk_1614 | rust_dataset.txt | 1,614 | 512 | event| event.paths.into_iter())
.any(|path| paths.contains(&path))
{
// Always reload the primary configuration file.
let event = Event::new(EventType::ConfigReload(paths[0].clone()), None);
... |
rust_dataset_chunk_1615 | rust_dataset.txt | 1,615 | 512 | Replace};
use crate::config::bindings::{self, MouseBinding};
use crate::config::ui_config;
#[derive(ConfigDeserialize, Serialize, Default, Clone, Debug, PartialEq)]
pub struct Mouse {
pub hide_when_typing: bool,
pub bindings: MouseBindings,
}
/// Active mouse bindings and the user's binding entries they were... |
rust_dataset_chunk_1616 | rust_dataset.txt | 1,616 | 512 | de> Deserialize<'de> for ScrollingHistory {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let lines = u32::deserialize(deserializer)?;
if lines > MAX_SCROLLBACK_LINES {
Err(SerdeError::custom(format!(
"exceeded... |
rust_dataset_chunk_1617 | rust_dataset.txt | 1,617 | 512 | .clone()), replacement);
let base = Value::Boolean(false);
let replacement = Value::Boolean(true);
assert_eq!(merge(base, replacement.clone()), replacement);
let base = Value::Integer(0.into());
let replacement = Value::Integer(1.into());
assert_eq!(merge(base, replacem... |
rust_dataset_chunk_1618 | rust_dataset.txt | 1,618 | 512 | mode.
pub osc52: SerdeOsc52,
/// Path to a shell program to run on startup.
pub shell: Option<Program>,
}
#[derive(SerdeReplace, Serialize, Default, Copy, Clone, Debug, PartialEq)]
pub struct SerdeOsc52(pub Osc52);
impl<'de> Deserialize<'de> for SerdeOsc52 {
fn deserialize<D>(deserializer: D) -> Resu... |
rust_dataset_chunk_1619 | rust_dataset.txt | 1,619 | 512 | _REGEX: &str = "(ipfs:|ipns:|magnet:|mailto:|gemini://|gopher://|https://|http://|news:|file:|git://|ssh:|ftp://)\
[^\u{0000}-\u{001F}\u{007F}-\u{009F}<>\"\\s{-}\\^⟨⟩`\\\\]+";
#[derive(ConfigDeserialize, Serialize, Default, Clone, Debug, PartialEq)]
pub struct UiConfig {
/// Miscellaneous ... |
rust_dataset_chunk_1620 | rust_dataset.txt | 1,620 | 512 | impl UiConfig {
/// Derive [`TermConfig`] from the config.
pub fn term_options(&self) -> TermConfig {
TermConfig {
semantic_escape_chars: self.selection.semantic_escape_chars.clone(),
scrolling_history: self.scrolling.history() as usize,
vi_mode_cursor_style: self.cur... |
rust_dataset_chunk_1621 | rust_dataset.txt | 1,621 | 512 | de>,
{
let mut user_bindings = Vec::<toml::Value>::deserialize(deserializer)?;
let bindings = deserialize_bindings(&mut user_bindings, bindings::default_key_bindings());
Ok(Self(bindings, user_bindings))
}
}
impl Serialize for KeyBindings {
fn serialize<S>(&self, serializer: S) -> R... |
rust_dataset_chunk_1622 | rust_dataset.txt | 1,622 | 512 | ::Command(Program::Just(String::from("xdg-open")));
#[cfg(target_os = "macos")]
let action = HintAction::Command(Program::Just(String::from("open")));
#[cfg(windows)]
let action = HintAction::Command(Program::WithArgs {
program: String::from("cmd"),
args: vec!["/c... |
rust_dataset_chunk_1623 | rust_dataset.txt | 1,623 | 512 | text to the PTY/search.
Paste,
/// Select the text matching the hint.
Select,
/// Move the vi mode cursor to the beginning of the hint.
MoveViModeCursor,
}
/// Actions for hint bindings.
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq)]
pub enum HintAction {
/// Built-in hint acti... |
rust_dataset_chunk_1624 | rust_dataset.txt | 1,624 | 512 | Value>()? {
match key.as_str() {
"regex" => match Option::<LazyRegex>::deserialize(value) {
Ok(regex) => content.regex = regex,
Err(err) => {
error!(
ta... |
rust_dataset_chunk_1625 | rust_dataset.txt | 1,625 | 512 | }
}
/// Hint mouse highlighting.
#[derive(ConfigDeserialize, Serialize, Default, Copy, Clone, Debug, PartialEq, Eq)]
pub struct HintMouse {
/// Hint mouse highlighting availability.
pub enabled: bool,
/// Required mouse modifiers for hint highlighting.
#[serde(skip_serializing)]
pub mods: ModsWra... |
rust_dataset_chunk_1626 | rust_dataset.txt | 1,626 | 512 | (regex),
};
// Compile the regex.
let regex_search = match RegexSearch::new(®ex) {
Ok(regex_search) => regex_search,
Err(err) => {
error!("could not compile hint regex: {err}");
*self = Self::Uncompilable(regex);
return ... |
rust_dataset_chunk_1627 | rust_dataset.txt | 1,627 | 512 | {
fn from(value: Program) -> Self {
match value {
Program::Just(program) => Shell::new(program, Vec::new()),
Program::WithArgs { program, args } => Shell::new(program, args),
}
}
}
impl SerdeReplace for Program {
fn replace(&mut self, value: toml::Value) -> Result<(... |
rust_dataset_chunk_1628 | rust_dataset.txt | 1,628 | 512 | ::trace::on_request::log_parameters",
"http//www.example.org",
"/user:example.org",
"mailto: example@example.org",
"http://<script>alert('xss')</script>",
"mailto:",
] {
let term = mock_term(url_like);
let mut regex = RegexSearc... |
rust_dataset_chunk_1629 | rust_dataset.txt | 1,629 | 512 | ,
)
.unwrap();
let serialized = serde_json::to_value(&config).unwrap();
assert_eq!(
serialized["keyboard"]["bindings"],
serde_json::json!([
{ "key": "N", "mods": "Control|Shift", "action": "SpawnNewInstance" },
])
);
as... |
rust_dataset_chunk_1630 | rust_dataset.txt | 1,630 | 512 | dimensions: Dimensions,
/// System decorations theme variant.
decorations_theme_variant: Option<Theme>,
/// Window level.
pub level: WindowLevel,
}
impl Default for WindowConfig {
fn default() -> Self {
Self {
dynamic_title: true,
blur: Default::default(),
... |
rust_dataset_chunk_1631 | rust_dataset.txt | 1,631 | 512 | self.startup_mode == StartupMode::Fullscreen {
Some(Fullscreen::Borderless(None))
} else {
None
}
}
#[inline]
pub fn maximized(&self) -> bool {
self.startup_mode == StartupMode::Maximized
}
#[cfg(target_os = "macos")]
pub fn option_as_alt(&self)... |
rust_dataset_chunk_1632 | rust_dataset.txt | 1,632 | 512 | _NAME, DEFAULT_NAME)
}
}
impl<'de> Deserialize<'de> for Class {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct ClassVisitor;
impl<'a> Visitor<'a> for ClassVisitor {
type Value = Class;
fn expecting(&self... |
rust_dataset_chunk_1633 | rust_dataset.txt | 1,633 | 512 | Theme {
Light,
Dark,
}
impl From<Theme> for WinitTheme {
fn from(theme: Theme) -> Self {
match theme {
Theme::Light => WinitTheme::Light,
Theme::Dark => WinitTheme::Dark,
}
}
}
#[derive(ConfigDeserialize, Serialize, Default, Debug, Clone, Copy, PartialEq, Eq)]
... |
rust_dataset_chunk_1634 | rust_dataset.txt | 1,634 | 512 |
// console window.
Command::new(program)
.args(args)
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.creation_flags(CREATE_NEW_PROCESS_GROUP | CREATE_NO_WINDOW)
.spawn()
.map(|_| ())
}
/// Start a new process in the background.
#[cfg... |
rust_dataset_chunk_1635 | rust_dataset.txt | 1,635 | 512 | let Some(working_directory) = working_directory.as_ref() {
libc::chdir(working_directory.as_ptr());
}
if libc::setsid() == -1 {
return Err(io::Error::last_os_error());
}
Ok(())
})
.spawn()?... |
rust_dataset_chunk_1636 | rust_dataset.txt | 1,636 | 512 | acritty/alacritty/src/display/bell.rs ---
use std::time::{Duration, Instant};
use crate::config::bell::{BellAnimation, BellConfig};
pub struct VisualBell {
/// Visual bell animation.
animation: BellAnimation,
/// Visual bell duration.
duration: Duration,
/// The last time the visual bell rang, i... |
rust_dataset_chunk_1637 | rust_dataset.txt | 1,637 | 512 | {
return 0.0;
}
let elapsed = instant.duration_since(earlier);
let elapsed_f =
elapsed.as_secs() as f64 + f64::from(elapsed.subsec_nanos()) / 1e9f64;
let duration_f = self.duration.as_secs() as f64
... |
rust_dataset_chunk_1638 | rust_dataset.txt | 1,638 | 512 | };
// Since we want the `intensity` of the VisualBell to decay over
// `time`, we subtract the `inverse_intensity` from 1.0.
1.0 - inverse_intensity
},
}
}
pub fn update_config(&mut self, bell_config: &BellConfig) {
se... |
rust_dataset_chunk_1639 | rust_dataset.txt | 1,639 | 512 | (&mut self, colors: &Colors) {
// Normals.
self[NamedColor::Black] = colors.normal.black;
self[NamedColor::Red] = colors.normal.red;
self[NamedColor::Green] = colors.normal.green;
self[NamedColor::Yellow] = colors.normal.yellow;
self[NamedColor::Blue] = colors.normal.blue... |
rust_dataset_chunk_1640 | rust_dataset.txt | 1,640 | 512 | Red] = colors.normal.red * DIM_FACTOR;
self[NamedColor::DimGreen] = colors.normal.green * DIM_FACTOR;
self[NamedColor::DimYellow] = colors.normal.yellow * DIM_FACTOR;
self[NamedColor::DimBlue] = colors.normal.blue * DIM_FACTOR;
self[NamedColor::DimMagenta]... |
rust_dataset_chunk_1641 | rust_dataset.txt | 1,641 | 512 | }
}
impl Index<usize> for List {
type Output = Rgb;
#[inline]
fn index(&self, idx: usize) -> &Self::Output {
&self.0[idx]
}
}
impl IndexMut<usize> for List {
#[inline]
fn index_mut(&mut self, idx: usize) -> &mut Self::Output {
&mut self.0[idx]
}
}
impl Index<NamedColor> ... |
rust_dataset_chunk_1642 | rust_dataset.txt | 1,642 | 512 | // Used for deserializing reftests.
#[derive(Deserialize)]
struct RgbDerivedDeser {
r: u8,
g: u8,
b: u8,
}
impl Visitor<'_> for RgbVisitor {
type Value = Rgb;
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {... |
rust_dataset_chunk_1643 | rust_dataset.txt | 1,643 | 512 | ) {
Ok(mut color) => {
let b = (color & 0xff) as u8;
color >>= 8;
let g = (color & 0xff) as u8;
color >>= 8;
let r = color as u8;
Ok(Rgb::new(r, g, b))
},
Err(_) => Err(()),
}
... |
rust_dataset_chunk_1644 | rust_dataset.txt | 1,644 | 512 | ;
use std::num::NonZeroU32;
use std::ops::Deref;
use std::{cmp, mem};
use alacritty_terminal::event::EventListener;
use alacritty_terminal::grid::{Dimensions, Indexed};
use alacritty_terminal::index::{Column, Line, Point};
use alacritty_terminal::selection::SelectionRange;
use alacritty_terminal::term::cell::{Cell, Fl... |
rust_dataset_chunk_1645 | rust_dataset.txt | 1,645 | 512 | Shape::Hidden
} else if !term.is_focused && config.cursor.unfocused_hollow {
CursorShape::HollowBlock
} else {
terminal_content.cursor.shape
};
// Convert terminal cursor point to viewport position.
let cursor_point = terminal_content.cursor.point;
... |
rust_dataset_chunk_1646 | rust_dataset.txt | 1,646 | 512 | from cell colors to RGB.
let mut text_color = text_color.color(cell.fg, cell.bg);
let mut cursor_color = cursor_color.color(cell.fg, cell.bg);
// Invert cursor color with insufficient contrast to prevent invisible cursors.
if insufficient_contrast {
cursor_color = self.conf... |
rust_dataset_chunk_1647 | rust_dataset.txt | 1,647 | 512 | reduce the cell size we
/// pass around.
#[derive(Clone, Debug)]
pub struct RenderableCellExtra {
pub zerowidth: Option<Vec<char>>,
pub hyperlink: Option<Hyperlink>,
}
impl RenderableCell {
fn new(content: &mut RenderableContent<'_>, cell: Indexed<&Cell>) -> Self {
// Lookup RGB values.
le... |
rust_dataset_chunk_1648 | rust_dataset.txt | 1,648 | 512 | .contains(Flags::HIDDEN) {
// Reveal inversed text when fg/bg is the same.
fg = content.color(NamedColor::Background as usize);
bg = content.color(NamedColor::Foreground as usize);
bg_alpha = 1.0;
}
} else if content.search.as_mut().is_... |
rust_dataset_chunk_1649 | rust_dataset.txt | 1,649 | 512 | Rgb,
) {
let old_fg = mem::replace(cell_fg, fg.color(*cell_fg, *cell_bg));
*cell_bg = bg.color(old_fg, *cell_bg);
if bg != CellRgb::CellBackground {
*bg_alpha = 1.0;
}
}
/// Get the RGB color from a cell's foreground color.
fn compute_fg_rgb(content: &Render... |
rust_dataset_chunk_1650 | rust_dataset.txt | 1,650 | 512 | (content: &RenderableContent<'_>, bg: Color) -> Rgb {
match bg {
Color::Spec(rgb) => rgb.into(),
Color::Named(ansi) => content.color(ansi as usize),
Color::Indexed(idx) => content.color(idx as usize),
}
}
/// Compute background alpha based on cell's original ... |
rust_dataset_chunk_1651 | rust_dataset.txt | 1,651 | 512 | a Vec<Vec<char>>,
}
impl Hint<'_> {
/// Advance the hint iterator.
///
/// If the point is within a hint, the keyboard shortcut character that should be displayed at
/// this position will be returned.
///
/// The tuple's [`bool`] will be `true` when the character is the first for this hint.
... |
rust_dataset_chunk_1652 | rust_dataset.txt | 1,652 | 512 | Self { matches: matches.into(), index: 0 }
}
/// Create from regex matches on term visible part.
fn visible_regex_matches<T>(term: &Term<T>, dfas: &mut RegexSearch) -> Self {
let matches = hint::visible_regex_match_iter(term, dfas).collect::<Vec<_>>();
Self::new(matches)
}
/// Adv... |
rust_dataset_chunk_1653 | rust_dataset.txt | 1,653 | 512 | underline(x, y, width, height, thickness, self.color()),
CursorShape::HollowBlock => hollow(x, y, width, height, thickness, self.color()),
_ => CursorRects::default(),
}
}
}
/// Cursor rect iterator.
#[derive(Default)]
pub struct CursorRects {
rects: [Option<RenderRect>; 4],
... |
rust_dataset_chunk_1654 | rust_dataset.txt | 1,654 | 512 | color, 1.);
CursorRects {
rects: [Some(top_line), Some(bottom_line), Some(left_line), Some(right_line)],
index: 0,
}
}
--- FILE: alacritty/alacritty/src/display/damage.rs ---
use std::iter::Peekable;
use std::{cmp, mem};
use glutin::surface::Rect;
use alacritty_terminal::index::Point;
use ... |
rust_dataset_chunk_1655 | rust_dataset.txt | 1,655 | 512 | columns);
}
self.frame().full = true;
}
/// Damage vi cursor inside the viewport.
pub fn damage_vi_cursor(&mut self, mut vi_cursor: Option<Point<usize>>) {
mem::swap(&mut self.old_vi_cursor, &mut vi_cursor);
if self.frame().full {
return;
}
if ... |
rust_dataset_chunk_1656 | rust_dataset.txt | 1,656 | 512 | FrameDamage {
/// The entire frame needs to be redrawn.
full: bool,
/// Terminal lines damaged in the given frame.
lines: Vec<LineDamageBounds>,
/// Rectangular regions damage in the given frame.
rects: Vec<Rect>,
}
impl FrameDamage {
/// Damage line for the given frame.
#[inline]
... |
rust_dataset_chunk_1657 | rust_dataset.txt | 1,657 | 512 | i32, height: i32) -> i32 {
size_info.height() as i32 - y - height
}
/// Convert viewport `y` coordinate to [`Rect`] damage coordinate.
pub fn damage_y_to_viewport_y(size_info: &SizeInfo, rect: &Rect) -> i32 {
size_info.height() as i32 - rect.y - rect.height
}
/// Iterator which converts `alacritty_terminal` ... |
rust_dataset_chunk_1658 | rust_dataset.txt | 1,658 | 512 | RenderDamageIterator<'_> {
type Item = Rect;
fn next(&mut self) -> Option<Rect> {
let line = self.damaged_lines.next()?;
let size_info = &self.size_info;
let mut total_damage_rect = Self::overdamage(size_info, self.rect_for_line(line));
// Merge rectangles which overlap with e... |
rust_dataset_chunk_1659 | rust_dataset.txt | 1,659 | 512 | true,
)
.into();
// Test min clamping.
let rect = Rect::new(0, 0, rect_side, rect_side);
let rect = RenderDamageIterator::overdamage(&size_info, rect);
assert_eq!(Rect::new(0, 0, rect_side + 2 * cell_size, 10 + cell_size), rect);
// Test max clamping.
l... |
rust_dataset_chunk_1660 | rust_dataset.txt | 1,660 | 512 | <Rect> = iter.collect();
}
#[test]
fn add_viewport_damage() {
let mut frame_damage = FrameDamage::default();
let viewport_height = 100.;
let x = 0;
let y = 40;
let height = 5;
let width = 10;
let size_info = SizeInfo::new(viewport_height, viewport_hei... |
rust_dataset_chunk_1661 | rust_dataset.txt | 1,661 | 512 | keys: Vec<char>,
}
impl HintState {
/// Initialize an inactive hint state.
pub fn new<S: Into<String>>(alphabet: S) -> Self {
Self {
alphabet: alphabet.into(),
hint: Default::default(),
matches: Default::default(),
labels: Default::default(),
... |
rust_dataset_chunk_1662 | rust_dataset.txt | 1,662 | 512 | .len();
// Get the label for each match.
self.labels.resize(match_count, Vec::new());
for i in (0..match_count).rev() {
let mut label = generator.next();
if label.len() >= keys_len && label[..keys_len] == self.keys[..] {
self.labels[i] = label.split_off(k... |
rust_dataset_chunk_1663 | rust_dataset.txt | 1,663 | 512 | /// Hint match which was selected by the user.
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct HintMatch {
/// Terminal range matching the hint.
bounds: Match,
/// OSC 8 hyperlink.
hyperlink: Option<Hyperlink>,
/// Hint which triggered this match.
hint: Rc<Hint>,
}
impl HintMatch {
#[in... |
rust_dataset_chunk_1664 | rust_dataset.txt | 1,664 | 512 | the tail character easy, part of the alphabet cannot be used for
/// any other position.
///
/// All characters in the alphabet before this index will be used for the last character, while
/// the rest will be used for everything else.
split_point: usize,
}
impl HintLabels {
/// Create a new l... |
rust_dataset_chunk_1665 | rust_dataset.txt | 1,665 | 512 | () as i32));
let viewport_end = viewport_start + term.bottommost_line();
let mut start = term.line_search_left(Point::new(viewport_start, Column(0)));
let mut end = term.line_search_right(Point::new(viewport_end, Column(0)));
start.line = start.line.max(viewport_start - MAX_SEARCH_LINES);
end.line =... |
rust_dataset_chunk_1666 | rust_dataset.txt | 1,666 | 512 | sub-matches if necessary.
if post_processing {
HintPostProcessor::new(term, regex, regex_match).find(|rm| rm.contains(&point))
} else {
Some(regex_match)
}
}
/// Check if there is a hint highlighted at the specified point.
pub fn highlighted_at<T>(
term: &Term<T>,
config: &UiConfig... |
rust_dataset_chunk_1667 | rust_dataset.txt | 1,667 | 512 | cell.point;
} else {
break;
}
}
Some((hyperlink, match_start..=match_end))
}
/// Iterator over all post-processed matches inside an existing hint match.
struct HintPostProcessor<'a, T> {
/// Regex search DFAs.
regex: &'a mut RegexSearch,
/// Terminal reference.
te... |
rust_dataset_chunk_1668 | rust_dataset.txt | 1,668 | 512 | ed) => c = indexed.cell.c,
None => break,
}
}
// Truncate trailing characters which are likely to be delimiters.
let start = *regex_match.start();
while iter.point() != start {
if !matches!(c, '.' | ',' | ':' | ';' | '?' | '!' | '(' | '[' | '\'') ... |
rust_dataset_chunk_1669 | rust_dataset.txt | 1,669 | 512 | vec!['2', '1']);
assert_eq!(generator.next(), vec!['3', '0']);
assert_eq!(generator.next(), vec!['3', '1']);
assert_eq!(generator.next(), vec!['2', '2', '0']);
assert_eq!(generator.next(), vec!['2', '2', '1']);
assert_eq!(generator.next(), vec!['2', '3', '0']);
assert_e... |
rust_dataset_chunk_1670 | rust_dataset.txt | 1,670 | 512 | '3', '1']);
}
#[test]
fn closed_bracket_does_not_result_in_infinite_iterator() {
let term = mock_term(" ) ");
let mut search = RegexSearch::new("[^/ ]").unwrap();
let count = HintPostProcessor::new(
&term,
&mut search,
Point::new(Line(0), Colum... |
rust_dataset_chunk_1671 | rust_dataset.txt | 1,671 | 512 | it only cares about visible content.
let term = mock_term(&content);
let mut regex = RegexSearch::new("match!").unwrap();
// The iterator should match everything in the viewport.
assert_eq!(visible_regex_match_iter(&term, &mut regex).count(), 4096);
}
}
--- FILE: alacritty/alacri... |
rust_dataset_chunk_1672 | rust_dataset.txt | 1,672 | 512 | add_sample(&mut self, sample: Duration) {
let mut usec = 0f64;
usec += f64::from(sample.subsec_nanos()) / 1e3;
usec += (sample.as_secs() as f64) * 1e6;
let prev = self.times[self.index];
self.times[self.index] = usec;
self.avg -= prev / NUM_SAMPLES as f64;
self... |
rust_dataset_chunk_1673 | rust_dataset.txt | 1,673 | 512 | ::Dimensions;
#[cfg(not(windows))]
use crate::config::window::StartupMode;
use crate::display::bell::VisualBell;
use crate::display::color::{List, Rgb};
use crate::display::content::{RenderableContent, RenderableCursor};
use crate::display::cursor::IntoRects;
use crate::display::damage::{DamageTracker, damage_y_to_view... |
rust_dataset_chunk_1674 | rust_dataset.txt | 1,674 | 512 | mt(f),
Error::Font(err) => err.fmt(f),
Error::Render(err) => err.fmt(f),
Error::Context(err) => err.fmt(f),
}
}
}
impl From<window::Error> for Error {
fn from(val: window::Error) -> Self {
Error::Window(val)
}
}
impl From<crossfont::Error> for Error {
... |
rust_dataset_chunk_1675 | rust_dataset.txt | 1,675 | 512 | }
}
}
impl<T: Clone + Copy> SizeInfo<T> {
#[inline]
pub fn width(&self) -> T {
self.width
}
#[inline]
pub fn height(&self) -> T {
self.height
}
#[inline]
pub fn cell_width(&self) -> T {
self.cell_width
}
#[inline]
pub fn cell_height(&se... |
rust_dataset_chunk_1676 | rust_dataset.txt | 1,676 | 512 | as f32 * self.cell_height) as usize
&& y > self.padding_y as usize
}
/// Calculate padding to spread it evenly around the terminal content.
#[inline]
fn dynamic_padding(padding: f32, dimension: f32, cell_dimension: f32) -> f32 {
padding + ((dimension - 2. * padding) % cell_dimensio... |
rust_dataset_chunk_1677 | rust_dataset.txt | 1,677 | 512 | : List,
/// State of the keyboard hints.
pub hint_state: HintState,
/// Unprocessed display updates.
pub pending_update: DisplayUpdate,
/// The renderer update that takes place only once before the actual rendering.
pub pending_renderer_update: Option<RendererUpdate>,
/// The ime on the ... |
rust_dataset_chunk_1678 | rust_dataset.txt | 1,678 | 512 | !("Filling glyph cache with common glyphs");
renderer.with_loader(|mut api| {
glyph_cache.reset_glyph_cache(&mut api);
});
let padding = config.window.padding(window.scale_factor as f32);
let viewport_size = window.inner_size();
// Create new size with at least one ... |
rust_dataset_chunk_1679 | rust_dataset.txt | 1,679 | 512 | new(size_info.screen_lines(), size_info.columns());
damage_tracker.debug = config.debug.highlight_damage;
// Disable vsync.
if let Err(err) = surface.set_swap_interval(&context, SwapInterval::DontWait) {
info!("Failed to disable vsync: {err}");
}
Ok(Self {
... |
rust_dataset_chunk_1680 | rust_dataset.txt | 1,680 | 512 | ManuallyDrop::drop(&mut self.renderer);
ManuallyDrop::drop(&mut self.context);
}
// Activate new context.
let context = context.treat_as_possibly_current();
self.context = ManuallyDrop::new(context);
self.context.make_current(&self.surface).expect("failed... |
rust_dataset_chunk_1681 | rust_dataset.txt | 1,681 | 512 | /// Process update events.
pub fn handle_update<T>(
&mut self,
terminal: &mut Term<T>,
pty_resize_handle: &mut dyn OnResize,
message_buffer: &MessageBuffer,
search_state: &mut SearchState,
config: &UiConfig,
) where
T: EventListener,
{
let pen... |
rust_dataset_chunk_1682 | rust_dataset.txt | 1,682 | 512 | || self.size_info.columns() != new_size.columns()
{
// Resize PTY.
pty_resize_handle.on_resize(new_size.into());
// Resize terminal.
terminal.resize(new_size);
// Resize damage tracking.
self.damage_tracker.resize(new_size.screen_lines()... |
rust_dataset_chunk_1683 | rust_dataset.txt | 1,683 | 512 | , self, &terminal, search_state);
let mut grid_cells = Vec::new();
for cell in &mut content {
grid_cells.push(cell);
}
let selection_range = content.selection_range();
let foreground_color = content.color(NamedColor::Foreground as usize);
let background_color ... |
rust_dataset_chunk_1684 | rust_dataset.txt | 1,684 | 512 | viewport.
#[cfg(target_os = "macos")]
self.renderer.set_viewport(&size_info);
let glyph_cache = &mut self.glyph_cache;
let highlighted_hint = &self.highlighted_hint;
let vi_highlighted_hint = &self.vi_highlighted_hint;
let damage_tracker = &mut s... |
rust_dataset_chunk_1685 | rust_dataset.txt | 1,685 | 512 | config.bell.color,
visual_bell_intensity as f32,
);
rects.push(visual_bell_rect);
}
// Handle IME positioning and search bar rendering.
let ime_position = match search_state.regex() {
Some(regex) => {
let search_label = match ... |
rust_dataset_chunk_1686 | rust_dataset.txt | 1,686 | 512 | y() {
MessageType::Error => config.colors.normal.red,
MessageType::Warning => config.colors.normal.yellow,
};
let x = 0;
let width = size_info.width() as i32;
let height = (size_info.height() - y) as i32;
let message_bar_rect =... |
rust_dataset_chunk_1687 | rust_dataset.txt | 1,687 | 512 | synchronize (this is `glClear` in Alacritty), which causes a
// permanent one frame delay.
self.renderer.finish();
}
// XXX: Request the new frame after swapping buffers, so the
// time to finish OpenGL operations is accounted for in the timeout.
if !matches!(se... |
rust_dataset_chunk_1688 | rust_dataset.txt | 1,688 | 512 | .is_some() {
// If mouse changed the line, we should update the hyperlink preview, since the
// highlighted hint could be disrupted by the old preview.
dirty = self.hint_mouse_point.is_some_and(|p| p.line != point.line);
self.hint_mouse_point = Some(point);
se... |
rust_dataset_chunk_1689 | rust_dataset.txt | 1,689 | 512 | _len, num_cols);
let start = end.saturating_sub(visible_len);
let start = Point::new(point.line, Column(start));
let end = Point::new(point.line, Column(end - 1));
let glyph_cache = &mut self.glyph_cache;
let metrics = glyph_cache.font_metrics();
self.renderer.draw_str... |
rust_dataset_chunk_1690 | rust_dataset.txt | 1,690 | 512 | to_owned();
}
// The search string consists of `search_label` + `search_regex` + `cursor`.
let mut bar_text = String::from(search_label);
bar_text.extend(StrShortener::new(
search_regex,
max_width.wrapping_sub(label_len + 1),
ShortenDirection::Left,
... |
rust_dataset_chunk_1691 | rust_dataset.txt | 1,691 | 512 | line
}
})
.take(uris.len())
.flat_map(|line| term::point_to_viewport(display_offset, Point::new(line, Column(0))));
let fg = config.colors.footer_bar_foreground();
let bg = config.colors.footer_bar_background();
for (uri, p... |
rust_dataset_chunk_1692 | rust_dataset.txt | 1,692 | 512 | a line in history.
#[inline(never)]
fn draw_line_indicator(
&mut self,
config: &UiConfig,
total_lines: usize,
obstructed_column: Option<Column>,
line: usize,
) {
let columns = self.size_info.columns();
let text = format!("[{}/{}]", line, total_lines -... |
rust_dataset_chunk_1693 | rust_dataset.txt | 1,693 | 512 | num_lines = self.size_info.screen_lines();
for (hint, hint_age, reset_mouse) in hints {
let (start, end) = match hint {
Some(hint) => (*hint.bounds().start(), *hint.bounds().end()),
None => continue,
};
// Ignore hints that were created this ... |
rust_dataset_chunk_1694 | rust_dataset.txt | 1,694 | 512 | .renderer);
ManuallyDrop::drop(&mut self.context);
ManuallyDrop::drop(&mut self.surface);
}
}
}
/// Input method state.
#[derive(Debug, Default)]
pub struct Ime {
/// Whether the IME is enabled.
enabled: bool,
/// Current IME preedit.
preedit: Option<Preedit>,
}
im... |
rust_dataset_chunk_1695 | rust_dataset.txt | 1,695 | 512 | (Debug, Default, Copy, Clone)]
pub struct RendererUpdate {
/// Should resize the window.
resize: bool,
/// Clear font caches.
clear_font_cache: bool,
}
/// The frame timer state.
pub struct FrameTimer {
/// Base timestamp used to compute sync points.
base: Instant,
/// The last timestamp ... |
rust_dataset_chunk_1696 | rust_dataset.txt | 1,696 | 512 | given padding, terminal dimensions and cell size.
fn window_size(
config: &UiConfig,
dimensions: Dimensions,
cell_width: f32,
cell_height: f32,
scale_factor: f32,
) -> PhysicalSize<u32> {
let padding = config.window.padding(scale_factor);
let grid_width = cell_width * dimensions.columns.ma... |
rust_dataset_chunk_1697 | rust_dataset.txt | 1,697 | 512 | , Fullscreen, ImePurpose, Theme, UserAttentionType, Window as WinitWindow,
WindowAttributes, WindowId,
};
use alacritty_terminal::index::Point;
use crate::cli::WindowOptions;
use crate::config::UiConfig;
use crate::config::window::{Decorations, Identity, WindowConfig};
use crate::display::SizeInfo;
/// Window ic... |
rust_dataset_chunk_1698 | rust_dataset.txt | 1,698 | 512 | 64,
/// Flag indicating whether redraw was requested.
pub requested_redraw: bool,
/// Hold the window when terminal exits.
pub hold: bool,
window: WinitWindow,
/// Current window title.
title: String,
is_x11: bool,
current_mouse_cursor: CursorIcon,
mouse_visible: bool,
i... |
rust_dataset_chunk_1699 | rust_dataset.txt | 1,699 | 512 | (config.window.theme())
.with_visible(false)
.with_transparent(true)
.with_blur(config.window.blur)
.with_maximized(config.window.maximized())
.with_fullscreen(config.window.fullscreen())
.with_window_level(config.window.level.into());
let... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.