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_1800 | rust_dataset.txt | 1,800 | 512 | other(format!("Invalid IPC format: {err}")))?;
// Ensure reply matches request.
match (message, &reply) {
// Write requested config to STDOUT.
(SocketMessage::GetConfig(..), SocketReply::GetConfig(config)) => {
println!("{config}");
Ok(())
},
// Ignore re... |
rust_dataset_chunk_1801 | rust_dataset.txt | 1,801 | 512 | ?.filter_map(|entry| entry.ok()) {
let path = entry.path();
// Skip files that aren't Alacritty sockets.
let socket_prefix = socket_prefix();
if path
.file_name()
.and_then(OsStr::to_str)
.filter(|file| file.starts_with(&socket_prefix) && file.ends_wi... |
rust_dataset_chunk_1802 | rust_dataset.txt | 1,802 | 512 | IPC read events.
const IPC_READ_KEY: usize = 0;
/// Unix I/O event listener.
pub struct IoListener {
ipc_listener: Option<IpcListener>,
signal_listener: SignalListener,
events: Events,
poller: Poller,
}
impl IoListener {
/// Create background thread to listen for I/O events.
pub fn spawn(
... |
rust_dataset_chunk_1803 | rust_dataset.txt | 1,803 | 512 | (IPC_READ_KEY))?;
}
// Wait for the next event to be ready.
self.events.clear();
self.poller.wait(&mut self.events, None)?;
for event in self.events.iter() {
if event.key == IPC_READ_KEY {
if let Some(ipc_listener) = &mut self.ipc_listener {
... |
rust_dataset_chunk_1804 | rust_dataset.txt | 1,804 | 512 | use std::borrow::Cow;
use std::collections::HashSet;
use std::ffi::{CStr, CString};
use std::sync::OnceLock;
use std::sync::atomic::{AtomicBool, Ordering};
use std::{fmt, ptr};
use ahash::RandomState;
use crossfont::Metrics;
use glutin::context::{ContextApi, GlContext, PossiblyCurrentContext};
use glutin::display::{Ge... |
rust_dataset_chunk_1805 | rust_dataset.txt | 1,805 | 512 | Renderer),
Glsl3(Glsl3Renderer),
}
#[derive(Debug)]
pub struct Renderer {
text_renderer: TextRendererProvider,
rect_renderer: RectRenderer,
robustness: bool,
}
/// Wrapper around gl::GetString with error checking and reporting.
fn gl_get_string(
string_id: gl::types::GLenum,
description: &str,... |
rust_dataset_chunk_1806 | rust_dataset.txt | 1,806 | 512 | sl3) => (true, true),
Some(RendererPreference::Gles2) => (false, true),
Some(RendererPreference::Gles2Pure) => (false, false),
None => (shader_version.as_ref() >= "3.3" && !is_gles_context, true),
};
let (text_renderer, rect_renderer) = if use_glsl3 {
let... |
rust_dataset_chunk_1807 | rust_dataset.txt | 1,807 | 512 | let flags = if wide_char_spacer {
wide_char_spacer = false;
return None;
} else if character.width() == Some(2) {
// The spacer is always following the wide char.
wide_char_spacer = true;
Flags::WIDE_CHAR
... |
rust_dataset_chunk_1808 | rust_dataset.txt | 1,808 | 512 | / 255.0).min(1.0) * alpha,
alpha,
);
gl::Clear(gl::COLOR_BUFFER_BIT);
}
}
/// Get the context reset status.
pub fn was_context_reset(&self) -> bool {
// If robustness is not supported, don't use its functions.
if !self.robustness {
... |
rust_dataset_chunk_1809 | rust_dataset.txt | 1,809 | 512 | }
struct GlExtensions;
impl GlExtensions {
/// Check if the given `extension` is supported.
///
/// This function will lazily load OpenGL extensions.
fn contains(extension: &str) -> bool {
static OPENGL_EXTENSIONS: OnceLock<HashSet<&'static str, RandomState>> = OnceLock::new();
OPENGL... |
rust_dataset_chunk_1810 | rust_dataset.txt | 1,810 | 512 | LevelFilter, debug};
use winit::dpi::PhysicalSize;
#[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))]
use winit::platform::x11;
use winit::raw_window_handle::{RawDisplayHandle, RawWindowHandle};
/// Create the GL display.
pub fn create_gl_display(
raw_display_handle: RawDisplayHandle,
_raw_w... |
rust_dataset_chunk_1811 | rust_dataset.txt | 1,811 | 512 | ),
config_10bit.with_transparency(false),
];
for config in configs {
let gl_config = unsafe {
gl_display.find_configs(config.build()).ok().and_then(|mut configs| configs.next())
};
if let Some(gl_config) = gl_config {
debug!(
r#"Picked GL... |
rust_dataset_chunk_1812 | rust_dataset.txt | 1,812 | 512 | .create_context(gl_config, &attributes) } {
Ok(profile) => return Ok(profile),
Err(err) => error = Some(err),
}
}
}
// If no context was built successfully, return an error for the most permissive one.
Err(error.unwrap())
}
pub fn create_gl_surface(
... |
rust_dataset_chunk_1813 | rust_dataset.txt | 1,813 | 512 | start: Point<usize>,
pub end: Point<usize>,
pub color: Rgb,
}
// NOTE: These flags must be in sync with their usage in the rect.*.glsl shaders.
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum RectKind {
Normal = 0,
Undercurl = 1,
DottedUnderline = 2,
DashedUnderline = 3,
... |
rust_dataset_chunk_1814 | rust_dataset.txt | 1,814 | 512 | => {
(metrics.descent, metrics.descent.abs(), RectKind::DottedUnderline)
},
Flags::DASHED_UNDERLINE => {
(metrics.underline_position, metrics.underline_thickness, RectKind::DashedUnderline)
},
Flags::STRIKEOUT => {
(metrics... |
rust_dataset_chunk_1815 | rust_dataset.txt | 1,815 | 512 | })
.collect()
}
/// Update the stored lines with the next cell info.
#[inline]
pub fn update(&mut self, cell: &RenderableCell) {
self.update_flag(cell, Flags::UNDERLINE);
self.update_flag(cell, Flags::DOUBLE_UNDERLINE);
self.update_flag(cell, Flags::STRIKEOUT);
... |
rust_dataset_chunk_1816 | rust_dataset.txt | 1,816 | 512 | )]
pub struct RectRenderer {
// GL buffer objects.
vao: GLuint,
vbo: GLuint,
programs: [RectShaderProgram; 4],
vertices: [Vec<Vertex>; 4],
}
impl RectRenderer {
pub fn new(shader_version: ShaderVersion) -> Result<Self, renderer::Error> {
let mut vao: GLuint = 0;
let mut vbo: GL... |
rust_dataset_chunk_1817 | rust_dataset.txt | 1,817 | 512 | programs = [rect_program, undercurl_program, dotted_program, dashed_program];
Ok(Self { vao, vbo, programs, vertices: Default::default() })
}
pub fn draw(&mut self, size_info: &SizeInfo, metrics: &Metrics, rects: Vec<RenderRect>) {
unsafe {
// Bind VAO to enable vertex attribute sl... |
rust_dataset_chunk_1818 | rust_dataset.txt | 1,818 | 512 | half_width - 1.0;
let y = -rect.y / half_height + 1.0;
let width = rect.width / half_width;
let height = rect.height / half_height;
let (r, g, b) = rect.color.as_tuple();
let a = (rect.alpha * 255.) as u8;
// Make quad vertices.
let quad = [
Vertex {... |
rust_dataset_chunk_1819 | rust_dataset.txt | 1,819 | 512 | DashedUnderline => Some("#define DRAW_DASHED\n"),
_ => None,
};
let program = ShaderProgram::new(shader_version, header, RECT_SHADER_V, RECT_SHADER_F)?;
Ok(Self {
u_cell_width: program.get_uniform_location(c"cellWidth").ok(),
u_cell_height: program.get_unifor... |
rust_dataset_chunk_1820 | rust_dataset.txt | 1,820 | 512 | alacritty/alacritty/src/renderer/shader.rs ---
use std::ffi::CStr;
use std::fmt;
use crate::gl;
use crate::gl::types::*;
/// A wrapper for a shader program id, with automatic lifetime management.
#[derive(Debug)]
pub struct ShaderProgram(GLuint);
#[derive(Copy, Clone, Debug)]
pub enum ShaderVersion {
/// OpenGL... |
rust_dataset_chunk_1821 | rust_dataset.txt | 1,821 | 512 | Drop for ShaderProgram {
fn drop(&mut self) {
unsafe { gl::DeleteProgram(self.0) }
}
}
/// A wrapper for a shader id, with automatic lifetime management.
#[derive(Debug)]
struct Shader(GLuint);
impl Shader {
fn new(
shader_version: ShaderVersion,
shader_header: Option<&str>,
... |
rust_dataset_chunk_1822 | rust_dataset.txt | 1,822 | 512 | _len(actual_length as usize);
}
String::from_utf8_lossy(&buf).to_string()
}
fn get_shader_info_log(shader: GLuint) -> String {
// Get expected log length.
let mut max_length: GLint = 0;
unsafe {
gl::GetShaderiv(shader, gl::INFO_LOG_LENGTH, &mut max_length);
}
// Read the info log.... |
rust_dataset_chunk_1823 | rust_dataset.txt | 1,823 | 512 | _height < height - row_baseline
/// ├─────┼─────┼─────┼─────┼─────┤
/// │ 5 │ 6 │ 7 │ 8 │ 9 │
/// │ │ │ │ │ │
/// ├─────┼─────┼─────┼─────┴─────┤ <- Row height is tallest glyph in row; this is
/// │ 1 │ 2 │ 3 │ 4 │ used as the baseline for the following row.
/// ... |
rust_dataset_chunk_1824 | rust_dataset.txt | 1,824 | 512 | TEXTURE_2D,
0,
gl::RGBA as i32,
size,
size,
0,
gl::RGBA,
gl::UNSIGNED_BYTE,
ptr::null(),
);
gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_WRAP_S, gl::CLAMP_TO_EDGE as ... |
rust_dataset_chunk_1825 | rust_dataset.txt | 1,825 | 512 | mut u32) -> Glyph {
let offset_y = self.row_baseline;
let offset_x = self.row_extent;
let height = glyph.height;
let width = glyph.width;
let multicolor;
unsafe {
gl::BindTexture(gl::TEXTURE_2D, self.id);
// Load data into OpenGL.
let... |
rust_dataset_chunk_1826 | rust_dataset.txt | 1,826 | 512 | ,
uv_height,
}
}
/// Check if there's room in the current row for given glyph.
pub fn room_in_row(&self, raw: &RasterizedGlyph) -> bool {
let next_extent = self.row_extent + raw.width;
let enough_width = next_extent <= self.width;
let enough_height = raw.height <... |
rust_dataset_chunk_1827 | rust_dataset.txt | 1,827 | 512 | : 0.,
uv_left: 0.,
uv_width: 0.,
uv_height: 0.,
},
}
}
#[inline]
pub fn clear_atlas(atlas: &mut [Atlas], current_atlas: &mut usize) {
for atlas in atlas.iter_mut() {
atlas.clear();
}
*current_atlas = 0;
... |
rust_dataset_chunk_1828 | rust_dataset.txt | 1,828 | 512 | }' => {
box_drawing(character, metrics, offset)
},
// Powerline symbols: '','','',''
POWERLINE_TRIANGLE_LTR..=POWERLINE_ARROW_RTL => {
powerline_drawing(character, metrics, offset)?
},
_ => return None,
};
// Since we want to ignore `glyph_off... |
rust_dataset_chunk_1829 | rust_dataset.txt | 1,829 | 512 | | -> f32 { k * x + h + y_offset };
let from_x = 0.;
let to_x = x_end + 1.;
for stroke_size in 0..2 * stroke_size {
let stroke_size = stroke_size as f32 / 2.;
if character == '\u{2571}' || character == '\u{2573}' {
let h = y_end - s... |
rust_dataset_chunk_1830 | rust_dataset.txt | 1,830 | 512 | + 1), 1);
let y = canvas.y_center();
for gap in 0..=num_gaps {
let x = cmp::min(gap * (dash_len + dash_gap_len), width);
canvas.draw_h_line(x as f32, y, dash_len as f32, stroke_size);
}
},
// Vertical dashes: '┆', '┇', '┊', '┋', '╎', '... |
rust_dataset_chunk_1831 | rust_dataset.txt | 1,831 | 512 | ','┣','┤','┥','┦','┧','┨','┩','┪','┫','┬','┭','┮','┯','┰','┱','┲','┳','┴','┵','┶','┷',
// '┸','┹','┺','┻','┼','┽','┾','┿','╀','╁','╂','╃','╄','╅','╆','╇','╈','╉','╊','╋'.
// Mixed light and heavy lines: '╼', '╽', '╾', '╿'.
'\u{2500}'..='\u{2503}' | '\u{250c}'..='\u{254b}' | '\u{2574}'..='\u{257f... |
rust_dataset_chunk_1832 | rust_dataset.txt | 1,832 | 512 | 2537}' | '\u{2539}' | '\u{253b}' | '\u{253d}'
| '\u{253f}' | '\u{2543}' | '\u{2545}' | '\u{2547}' | '\u{2548}' | '\u{2549}'
| '\u{254b}' | '\u{2578}' | '\u{257e}' => heavy_stroke_size,
_ => 0,
};
// Right horizontal line.
let stroke_siz... |
rust_dataset_chunk_1833 | rust_dataset.txt | 1,833 | 512 | roke_size,
_ => 0,
};
// Top vertical line.
let stroke_size_v1 = match character {
'\u{2502}' | '\u{2514}' | '\u{2515}' | '\u{2518}' | '\u{2519}' | '\u{251c}'
| '\u{251d}' | '\u{251f}' | '\u{2522}' | '\u{2524}' | '\u{2525}' | '\u{2527}'... |
rust_dataset_chunk_1834 | rust_dataset.txt | 1,834 | 512 | '\u{2524}' | '\u{2525}' | '\u{2526}'
| '\u{2529}' | '\u{252c}' | '\u{252d}' | '\u{252e}' | '\u{252f}' | '\u{253c}'
| '\u{253d}' | '\u{253e}' | '\u{253f}' | '\u{2540}' | '\u{2543}' | '\u{2544}'
| '\u{2547}' | '\u{2577}' | '\u{257f}' => stroke_size,
'\u{250... |
rust_dataset_chunk_1835 | rust_dataset.txt | 1,835 | 512 | let size_v1 =
cmp::max(h_line_bounds_left.1 as i32, h_line_bounds_right.1 as i32) as f32;
let y_v = cmp::min(h_line_bounds_left.0 as i32, h_line_bounds_right.0 as i32) as f32;
let size_v2 = height as f32 - y_v;
// Left horizontal line.
canvas.... |
rust_dataset_chunk_1836 | rust_dataset.txt | 1,836 | 512 | f}' | '\u{2562}'
| '\u{2565}' | '\u{2568}' | '\u{256b}' => (canvas.y_center(), canvas.y_center()),
_ => {
let h_line_bounds = canvas.h_line_bounds(canvas.y_center(), stroke_size);
let top_line = cmp::max(h_line_bounds.0 as i32 - 1, 0) as f32;
... |
rust_dataset_chunk_1837 | rust_dataset.txt | 1,837 | 512 | ='\u{2554}' | '\u{2568}' => (v_left_bounds.0, v_right_bounds.0, width),
'\u{2558}'..='\u{255a}' => (v_right_bounds.0, v_left_bounds.0, width),
'\u{255e}'..='\u{2560}' | '\u{256a}' | '\u{256c}' => {
(v_right_bounds.0, v_right_bounds.0, width)
},
... |
rust_dataset_chunk_1838 | rust_dataset.txt | 1,838 | 512 | }' => (canvas.y_center(), h_bot_bounds.0, height),
'\u{2561}'..='\u{2563}' => (h_bot_bounds.0, canvas.y_center(), height),
'\u{2564}'..='\u{2566}' | '\u{256b}' | '\u{256c}' => {
(h_bot_bounds.0, h_bot_bounds.0, height)
},
_ => (0., 0., ... |
rust_dataset_chunk_1839 | rust_dataset.txt | 1,839 | 512 | '\u{256d}' || character == '\u{256e}' {
let center = canvas.y_center() as usize;
let extra_offset = usize::from(stroke_size % 2 != height % 2);
let buffer = canvas.buffer_mut();
if extra_offset != 0 {
let bottom_row = (height - 1) * ... |
rust_dataset_chunk_1840 | rust_dataset.txt | 1,840 | 512 | 8.,
'\u{258e}' | '\u{1fb87}' => width * 2. / 8.,
'\u{258f}' => width * 1. / 8.,
'\u{2590}' => width * 4. / 8.,
'\u{2595}' => width * 1. / 8.,
_ => width,
};
let (mut rect_height, mut y) = match character {
... |
rust_dataset_chunk_1841 | rust_dataset.txt | 1,841 | 512 | coordinates.
y = (height - y).round();
// Ensure that resulted glyph will be visible and also round sizes instead of straight
// flooring them.
rect_width = rect_width.round().max(1.);
rect_height = rect_height.round().max(1.);
let x = match cha... |
rust_dataset_chunk_1842 | rust_dataset.txt | 1,842 | 512 | u{2596}' | '\u{2599}' | '\u{259b}' | '\u{259e}' | '\u{259f}' => {
(x_center, y_center)
},
_ => (0., 0.),
};
let (w_fourth, h_fourth) = match character {
'\u{2597}' | '\u{2599}' | '\u{259a}' | '\u{259c}' | '\u{259f}' => {
... |
rust_dataset_chunk_1843 | rust_dataset.txt | 1,843 | 512 | ��', '🬷', '🬸', '🬹', '🬺', '🬻'.
'\u{1fb00}'..='\u{1fb3b}' => {
let x_center = canvas.x_center().round().max(1.);
let y_third = (height as f32 / 3.).round().max(1.);
let y_last_third = height as f32 - 2. * y_third;
let (w_top_left, h_top_left) = match character... |
rust_dataset_chunk_1844 | rust_dataset.txt | 1,844 | 512 | {1fb18}' | '\u{1fb19}' | '\u{1fb1c}'
| '\u{1fb1d}' | '\u{1fb20}' | '\u{1fb21}' | '\u{1fb24}' | '\u{1fb25}'
| '\u{1fb28}' | '\u{1fb2b}' | '\u{1fb2c}' | '\u{1fb2f}' | '\u{1fb30}'
| '\u{1fb33}' | '\u{1fb34}' | '\u{1fb37}' | '\u{1fb38}' | '\u{1fb3b}' => {
... |
rust_dataset_chunk_1845 | rust_dataset.txt | 1,845 | 512 | u{1fb0a}' | '\u{1fb0b}'
| '\u{1fb0c}' | '\u{1fb0d}' | '\u{1fb0e}' | '\u{1fb16}' | '\u{1fb17}'
| '\u{1fb18}' | '\u{1fb19}' | '\u{1fb1a}' | '\u{1fb1b}' | '\u{1fb1c}'
| '\u{1fb1d}' | '\u{1fb26}' | '\u{1fb27}' | '\u{1fb28}' | '\u{1fb29}'
| '\u{1fb2a}' | '\u{1f... |
rust_dataset_chunk_1846 | rust_dataset.txt | 1,846 | 512 | {1fb3a}' | '\u{1fb3b}' => {
(x_center, y_last_third)
},
_ => (0., 0.),
};
let (w_bottom_right, h_bottom_right) = match character {
'\u{1fb1e}' | '\u{1fb1f}' | '\u{1fb20}' | '\u{1fb21}' | '\u{1fb22}'
| '\u{1fb23}'... |
rust_dataset_chunk_1847 | rust_dataset.txt | 1,847 | 512 | character,
top,
left: 0,
height: height as i32,
width: width as i32,
buffer,
advance: (width as i32, height as i32),
}
}
fn powerline_drawing(
character: char,
metrics: &Metrics,
offset: &Delta<i8>,
) -> Option<RasterizedGlyph> {
let height = (metric... |
rust_dataset_chunk_1848 | rust_dataset.txt | 1,848 | 512 | canvas.draw_rect(0., p1.1, p1.0 + 1., 1., COLOR_FILL);
canvas.draw_rect(0., p2.1, p2.0 + 1., 1., COLOR_FILL);
} else if character == POWERLINE_ARROW_LTR || character == POWERLINE_ARROW_RTL {
let p3 = top_inner_line.next().unwrap_or(p2);
let p4 = bottom_inner_line.next().unwr... |
rust_dataset_chunk_1849 | rust_dataset.txt | 1,849 | 512 | .saturating_add(rhs._b);
Pixel { _r, _g, _b }
}
}
impl ops::Div<u8> for Pixel {
type Output = Pixel;
fn div(self, rhs: u8) -> Self::Output {
let _r = self._r / rhs;
let _g = self._g / rhs;
let _b = self._b / rhs;
Pixel { _r, _g, _b }
}
}
/// Canvas which is use... |
rust_dataset_chunk_1850 | rust_dataset.txt | 1,850 | 512 | ) -> (f32, f32) {
let start_x = cmp::max((x - stroke_size as f32 / 2.) as i32, 0) as f32;
let end_x = cmp::min((x + stroke_size as f32 / 2.) as i32, self.width as i32) as f32;
(start_x, end_x)
}
/// Flip horizontally.
fn flip_horizontal(&mut self) {
for row in 0..self.heigh... |
rust_dataset_chunk_1851 | rust_dataset.txt | 1,851 | 512 | if the color is brighter than the one buffer
/// already has in place.
#[inline]
fn put_pixel(&mut self, x: f32, y: f32, color: Pixel) {
if x < 0. || y < 0. || x > self.width as f32 - 1. || y > self.height as f32 - 1. {
return;
}
let index = x as usize + y as usize * sel... |
rust_dataset_chunk_1852 | rust_dataset.txt | 1,852 | 512 | _2);
} else {
self.put_pixel(xpxl1, ypxl1, color_1);
self.put_pixel(xpxl1 + 1., ypxl1, color_2);
}
let mut intery = y_end + gradient;
let x_end = f32::round(to_x);
let y_end = to_y + gradient * (x_end - to_x);
let x_gap = (to_x + 0.5).fract();
... |
rust_dataset_chunk_1853 | rust_dataset.txt | 1,853 | 512 | unc(), color_1);
self.put_pixel(x as f32, intery.trunc() + 1., color_2);
intery += gradient;
}
}
}
/// Draws a quarter of a circle centered in `(0., self.height - radius)` with radius
/// `self.width` and an attached rectangle to form a "╭" using a given ... |
rust_dataset_chunk_1854 | rust_dataset.txt | 1,854 | 512 | _offset,
y + y_offset,
Pixel::gray((COLOR_FILL._r as f32 * value) as u8),
);
}
}
if self.height > self.width {
self.draw_rect(
self.x_center() - stroke_size_f * 0.5,
0.,
strok... |
rust_dataset_chunk_1855 | rust_dataset.txt | 1,855 | 512 | _thickness: 2.,
};
#[test]
fn builtin_line_drawing_glyphs_coverage() {
let offset = Default::default();
let glyph_offset = Default::default();
// Test coverage of box drawing characters.
for character in ('\u{2500}'..='\u{259f}').chain('\u{1fb00}'..='\u{1fb3b}') {
... |
rust_dataset_chunk_1856 | rust_dataset.txt | 1,856 | 512 | str = include_str!("../../../res/gles2/text.v.glsl");
#[derive(Debug)]
pub struct Gles2Renderer {
program: TextShaderProgram,
vao: GLuint,
vbo: GLuint,
ebo: GLuint,
atlas: Vec<Atlas>,
batch: Batch,
current_atlas: usize,
active_tex: GLuint,
dual_source_blending: bool,
}
impl Gles2Re... |
rust_dataset_chunk_1857 | rust_dataset.txt | 1,857 | 512 | ::BufferData(
gl::ARRAY_BUFFER,
(BATCH_MAX * size_of::<TextVertex>()) as isize,
ptr::null(),
gl::STREAM_DRAW,
);
let mut index = 0;
let mut size = 0;
macro_rules! add_attr {
($count:expr, $g... |
rust_dataset_chunk_1858 | rust_dataset.txt | 1,858 | 512 | TextShaderProgram;
fn program(&self) -> &Self::Shader {
&self.program
}
fn with_api<'b: 'a, F, T>(&'b mut self, _: &'b SizeInfo, func: F) -> T
where
F: FnOnce(Self::RenderApi) -> T,
{
unsafe {
gl::UseProgram(self.program.id());
gl::BindVertexArray(s... |
rust_dataset_chunk_1859 | rust_dataset.txt | 1,859 | 512 | fn clear(&mut self) {
self.vertices.clear();
}
}
impl TextRenderBatch for Batch {
#[inline]
fn tex(&self) -> GLuint {
self.tex
}
#[inline]
fn full(&self) -> bool {
self.capacity() == self.len()
}
#[inline]
fn is_empty(&self) -> bool {
self.len()... |
rust_dataset_chunk_1860 | rust_dataset.txt | 1,860 | 512 | = glyph.uv_left + glyph.uv_width;
vertex.v = glyph.uv_bot;
self.vertices.push(vertex);
vertex.x = x + is_wide * size_info.cell_width() as i16;
vertex.y = y + size_info.cell_height() as i16;
vertex.glyph_x = glyph_x + glyph.width;
vertex.glyph_y = glyph_y + glyph.height;... |
rust_dataset_chunk_1861 | rust_dataset.txt | 1,861 | 512 | ZERO);
gl::DrawElements(gl::TRIANGLES, num_indices, gl::UNSIGNED_SHORT, ptr::null());
self.program.set_rendering_pass(RenderingPass::SubpixelPass1);
if self.dual_source_blending {
// Text rendering pass.
gl::BlendFunc(gl::SRC1_COLOR, gl::ONE_MINUS_SRC... |
rust_dataset_chunk_1862 | rust_dataset.txt | 1,862 | 512 | /// If GL_EXT_blend_func_extended is not available, the rendering is split into 4 passes.
/// One is used for the background and the rest to perform subpixel text rendering according to
/// <https://github.com/servo/webrender/blob/master/webrender/doc/text-rendering.md>.
///
/// Rendering is split i... |
rust_dataset_chunk_1863 | rust_dataset.txt | 1,863 | 512 | )]
pub struct Glsl3Renderer {
program: TextShaderProgram,
vao: GLuint,
ebo: GLuint,
vbo_instance: GLuint,
atlas: Vec<Atlas>,
current_atlas: usize,
active_tex: GLuint,
batch: Batch,
}
impl Glsl3Renderer {
pub fn new() -> Result<Self, Error> {
info!("Using OpenGL 3.3 renderer"... |
rust_dataset_chunk_1864 | rust_dataset.txt | 1,864 | 512 | 1);
#[allow(unused_assignments)]
{
size += $count * size_of::<$type>();
index += 1;
}
};
}
// Coords.
add_attr!(2, gl::UNSIGNED_SHORT, u16);
// G... |
rust_dataset_chunk_1865 | rust_dataset.txt | 1,865 | 512 | unsafe {
gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, 0);
gl::BindBuffer(gl::ARRAY_BUFFER, 0);
gl::BindVertexArray(0);
gl::UseProgram(0);
}
res
}
fn program(&self) -> &Self::Shader {
&self.program
}
fn loader_api(&mut self) ... |
rust_dataset_chunk_1866 | rust_dataset.txt | 1,866 | 512 | LoadGlyph for RenderApi<'_> {
fn load_glyph(&mut self, rasterized: &RasterizedGlyph) -> Glyph {
Atlas::load_glyph(self.active_tex, self.atlas, self.current_atlas, rasterized)
}
fn clear(&mut self) {
Atlas::clear_atlas(self.atlas, self.current_atlas)
}
}
impl Drop for RenderApi<'_> {
... |
rust_dataset_chunk_1867 | rust_dataset.txt | 1,867 | 512 | : glyph.top,
left: glyph.left,
width: glyph.width,
height: glyph.height,
uv_bot: glyph.uv_bot,
uv_left: glyph.uv_left,
uv_width: glyph.uv_width,
uv_height: glyph.uv_height,
r: cell.fg.r,
g: cell.fg.g,
... |
rust_dataset_chunk_1868 | rust_dataset.txt | 1,868 | 512 | fn set_rendering_pass(&self, rendering_pass: RenderingPass) {
let value = match rendering_pass {
RenderingPass::Background | RenderingPass::SubpixelPass1 => rendering_pass as i32,
_ => unreachable!("provided pass is not supported in GLSL3 renderer"),
};
unsafe {
... |
rust_dataset_chunk_1869 | rust_dataset.txt | 1,869 | 512 | .
pub font_key: FontKey,
/// Bold font.
pub bold_key: FontKey,
/// Italic font.
pub italic_key: FontKey,
/// Bold italic font.
pub bold_italic_key: FontKey,
/// Font size.
pub font_size: crossfont::Size,
/// Font offset.
font_offset: Delta<i8>,
/// Glyph offset.
... |
rust_dataset_chunk_1870 | rust_dataset.txt | 1,870 | 512 | , character: i as char, size }, loader, true);
}
}
/// Computes font keys for (Regular, Bold, Italic, Bold Italic).
fn compute_font_keys(
font: &Font,
rasterizer: &mut Rasterizer,
) -> Result<(FontKey, FontKey, FontKey, FontKey), crossfont::Error> {
let size = font.size(... |
rust_dataset_chunk_1871 | rust_dataset.txt | 1,871 | 512 | };
FontDesc::new(desc.family.clone(), style)
}
/// Get a glyph from the font.
///
/// If the glyph has never been loaded before, it will be rasterized and inserted into the
/// cache.
///
/// # Errors
///
/// This will fail when the glyph could not be rasterized. Usu... |
rust_dataset_chunk_1872 | rust_dataset.txt | 1,872 | 512 | where
L: LoadGlyph + ?Sized,
{
glyph.left += i32::from(self.glyph_offset.x);
glyph.top += i32::from(self.glyph_offset.y);
glyph.top -= self.metrics.descent as i32;
// The metrics of zero-width characters are based on rendering
// the character after the current c... |
rust_dataset_chunk_1873 | rust_dataset.txt | 1,873 | 512 | _for_font(self.font_key, loader);
self.load_glyphs_for_font(self.bold_key, loader);
self.load_glyphs_for_font(self.italic_key, loader);
self.load_glyphs_for_font(self.bold_italic_key, loader);
}
}
--- FILE: alacritty/alacritty/src/renderer/text/mod.rs ---
use bitflags::bitflags;
use crossf... |
rust_dataset_chunk_1874 | rust_dataset.txt | 1,874 | 512 | cells: I,
) {
self.with_api(size_info, |mut api| {
for cell in cells {
api.draw_cell(cell, glyph_cache, size_info);
}
})
}
fn with_api<'b: 'a, F, T>(&'b mut self, size_info: &'b SizeInfo, func: F) -> T
where
F: FnOnce(Self::RenderApi) -> ... |
rust_dataset_chunk_1875 | rust_dataset.txt | 1,875 | 512 | mut cell: RenderableCell,
glyph_cache: &mut GlyphCache,
size_info: &SizeInfo,
) {
// Get font key for cell.
let font_key = match cell.flags & Flags::BOLD_ITALIC {
Flags::BOLD_ITALIC => glyph_cache.bold_italic_key,
Flags::ITALIC => glyph_cache.italic_key,
... |
rust_dataset_chunk_1876 | rust_dataset.txt | 1,876 | 512 | as u32) < (2 * padding_x as u32) || (height as u32) < (2 * padding_y as u32) {
return;
}
// Compute scale and offset factors, from pixel to ndc space. Y is inverted.
// [0, width - 2 * padding_x] to [-1, 1]
// [height - 2 * padding_y, 0] to [-1, 1]
let scale_x = 2. / (width - 2. * padd... |
rust_dataset_chunk_1877 | rust_dataset.txt | 1,877 | 512 | (&mut self) -> Option<Instant> {
let now = Instant::now();
while !self.timers.is_empty() && self.timers[0].deadline <= now {
if let Some(timer) = self.timers.pop_front() {
// Automatically repeat the event.
if let Some(interval) = timer.interval {
... |
rust_dataset_chunk_1878 | rust_dataset.txt | 1,878 | 512 | /// Terminate state reached.
Terminate,
/// Yield a shortener.
Shortener,
/// Yield a character.
Char,
}
/// The direction which we should shorten.
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum ShortenDirection {
/// Shorten to the start of the string.
Left,
/// Shorten to the end... |
rust_dataset_chunk_1879 | rust_dataset.txt | 1,879 | 512 | .
let num_chars = iter.last().map_or(offset, |(idx, _)| idx + 1);
let skip_chars = num_chars - offset;
let text_action = if current_len < max_width || shortener.is_none() {
TextAction::Char
} else {
TextAction::Shortener
};
let chars = text.chars... |
rust_dataset_chunk_1880 | rust_dataset.txt | 1,880 | 512 | ener::new("", 1, ShortenDirection::Left, Some('.')).collect::<String>()
);
assert_eq!(
".",
StrShortener::new(s, 1, ShortenDirection::Right, Some('.')).collect::<String>()
);
assert_eq!(
".",
StrShortener::new(s, 1, ShortenDirection::Left... |
rust_dataset_chunk_1881 | rust_dataset.txt | 1,881 | 512 | Shortener::new(s, len * 2, ShortenDirection::Right, Some('.')).collect::<String>()
);
}
#[test]
fn into_shortened_without_shortener() {
let s = "Hello";
assert_eq!("", StrShortener::new("", 1, ShortenDirection::Left, None).collect::<String>());
assert_eq!(
"H",
... |
rust_dataset_chunk_1882 | rust_dataset.txt | 1,882 | 512 | ち は P",
&StrShortener::new(s, len, ShortenDirection::Left, None).collect::<String>()
);
assert_eq!(
"こ Jん に ち は P",
&StrShortener::new(s, len, ShortenDirection::Right, None).collect::<String>()
);
}
}
--- FILE: alacritty/alacritty/src/window_context.rs... |
rust_dataset_chunk_1883 | rust_dataset.txt | 1,883 | 512 | one individual Alacritty window.
pub struct WindowContext {
pub message_buffer: MessageBuffer,
pub display: Display,
pub dirty: bool,
event_queue: Vec<WinitEvent<Event>>,
terminal: Arc<FairMutex<Term<EventProxy>>>,
cursor_blink_timed_out: bool,
prev_bell_cmd: Option<Instant>,
modifiers:... |
rust_dataset_chunk_1884 | rust_dataset.txt | 1,884 | 512 | let display = Display::new(window, gl_context, &config, false)?;
Self::new(display, config, options, proxy)
}
/// Create additional context with the graphics platform other windows are using.
pub fn additional(
gl_config: &GlutinConfig,
event_loop: &ActiveEventLoop,
... |
rust_dataset_chunk_1885 | rust_dataset.txt | 1,885 | 512 | _info.columns()
);
let event_proxy = EventProxy::new(proxy, display.window.id());
// Create the terminal.
//
// This object contains all of the state about what's being displayed. It's
// wrapped in a clonable mutex since both the I/O loop and display need to
//... |
rust_dataset_chunk_1886 | rust_dataset.txt | 1,886 | 512 | : Default::default(),
prev_bell_cmd: Default::default(),
inline_search_state: Default::default(),
message_buffer: Default::default(),
window_config: Default::default(),
search_state: Default::default(),
event_queue: Default::default(),
... |
rust_dataset_chunk_1887 | rust_dataset.txt | 1,887 | 512 | │
// │ N │ Y │ N ││ N │
// │ N │ N │ _ ││ Y │
if !self.preserve_title
&& (!self.config.window.dynamic_title
|| self.display.window.title() == old_config.window.identity.titl... |
rust_dataset_chunk_1888 | rust_dataset.txt | 1,888 | 512 | self.display.process_renderer_update();
// Request immediate re-draw if visual bell animation is not finished yet.
if !self.display.visual_bell.completed() {
// We can get an OS redraw which bypasses alacritty's frame throttling, thus
// marking the window as dirty when we don'... |
rust_dataset_chunk_1889 | rust_dataset.txt | 1,889 | 512 | ,
config: &self.config,
event_proxy,
#[cfg(target_os = "macos")]
event_loop,
clipboard,
scheduler,
};
let mut processor = input::Processor::new(context);
for event in self.event_queue.drain(..) {
processor.handl... |
rust_dataset_chunk_1890 | rust_dataset.txt | 1,890 | 512 | .as_bytes()))
.expect("write size.json");
File::create("./config.json")
.and_then(|mut f| f.write_all(serialized_config.as_bytes()))
.expect("write config.json");
}
/// Submit the pending changes to the `Display`.
fn submit_display_update(
terminal: &mut... |
rust_dataset_chunk_1891 | rust_dataset.txt | 1,891 | 512 | ;
use polling::{Event as PollingEvent, Events, PollMode, Poller};
use crate::event::{self, Event, EventListener, WindowSize};
use crate::sync::FairMutex;
use crate::term::Term;
use crate::{thread, tty};
use vte::ansi;
/// Max bytes to read from the PTY before forced terminal synchronization.
pub(crate) const READ_BUF... |
rust_dataset_chunk_1892 | rust_dataset.txt | 1,892 | 512 | .tx.clone(), poller: self.poll.clone() }
}
/// Drain the channel.
///
/// Returns `false` when a shutdown message was received.
fn drain_recv_channel(&mut self, state: &mut State) -> bool {
while let Some(msg) = self.rx.recv() {
match msg {
Msg::Input(input) => s... |
rust_dataset_chunk_1893 | rust_dataset.txt | 1,893 | 512 | unprocessed]);
processed += unprocessed;
unprocessed = 0;
// Assure we're not blocking the terminal too long unnecessarily.
if processed >= MAX_LOCKED_READ {
break;
}
}
// Queue terminal redraw unless all processed bytes were... |
rust_dataset_chunk_1894 | rust_dataset.txt | 1,894 | 512 | ating_duration_since(Instant::now()));
events.clear();
if let Err(err) = self.poll.wait(&mut events, timeout) {
match err.kind() {
ErrorKind::Interrupted => continue,
_ => {
error!("Event loo... |
rust_dataset_chunk_1895 | rust_dataset.txt | 1,895 | 512 | 'event_loop;
}
}
},
_ => (),
}
}
// Register write interest if necessary.
let needs_write = state.needs_write();
if needs_writ... |
rust_dataset_chunk_1896 | rust_dataset.txt | 1,896 | 512 | self, msg: Msg) -> Result<(), EventLoopSendError> {
self.sender.send(msg).map_err(EventLoopSendError::Send)?;
self.poller.notify().map_err(EventLoopSendError::Io)
}
}
/// All of the mutable state needed to run the event loop.
///
/// Contains list of items to write, current write state, etc. Anythi... |
rust_dataset_chunk_1897 | rust_dataset.txt | 1,897 | 512 | if self.peeked.is_some() {
self.peeked.take()
} else {
match self.rx.try_recv() {
Err(TryRecvError::Disconnected) => panic!("event loop channel closed"),
res => res.ok(),
}
}
}
}
--- FILE: alacritty/alacritty_terminal/src/event.r... |
rust_dataset_chunk_1898 | rust_dataset.txt | 1,898 | 512 | Event::ClipboardLoad(ty, _) => write!(f, "ClipboardLoad({ty:?})"),
Event::TextAreaSizeRequest(_) => write!(f, "TextAreaSizeRequest"),
Event::ColorRequest(index, _) => write!(f, "ColorRequest({index})"),
Event::PtyWrite(text) => write!(f, "PtyWrite({text})"),
E... |
rust_dataset_chunk_1899 | rust_dataset.txt | 1,899 | 512 | vte::ansi::{CharsetIndex, StandardCharset};
pub mod resize;
mod row;
mod storage;
#[cfg(test)]
mod tests;
pub use self::row::Row;
use self::storage::Storage;
pub trait GridCell: Sized {
/// Check if the cell contains any content.
fn is_empty(&self) -> bool;
/// Perform an opinionated cell reset based on... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.