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_516800
rust_dataset.txt
516,800
512
panel.rs --- use crate::config::options::Options; use crate::{config, emulation}; pub(crate) fn panel_layout(view: &str) -> String { format!( "keybinds clear-defaults=true {{\n}}\nlayout {{\n pane {{\n plugin location=\"zellij:session-manager\" {{\n role \"app_panel\"\n view...
rust_dataset_chunk_516801
rust_dataset.txt
516,801
512
args.working_directory .clone() .map(|dir| match std::env::current_dir() { Ok(cwd) if dir.is_relative() => cwd.join(dir), _ => dir, }) .or_else(|| std::env::current_dir().ok()) .unwrap_or_else(|| PathBuf::from(".")) } pub(crate) struct Plan { pub(cra...
rust_dataset_chunk_516802
rust_dataset.txt
516,802
512
{ let mut options = config::options::resolve(settings, None); if let Some(mode) = args.startup_mode { options.startup_mode = mode; } options } --- FILE: zellij/zellij-terminal/src/launch/standalone.rs --- use crate::config::options::Options; use crate::config::window_state::Startup; use crate...
rust_dataset_chunk_516803
rust_dataset.txt
516,803
512
Err(e) => { return refuse( Refusal::new(format!("{:#}", e)), &args, fonts.map(|fonts| (fonts, options)), ) }, }; drive( connection, args, fonts, options, settings, opts, ...
rust_dataset_chunk_516804
rust_dataset.txt
516,804
512
.paints, }; let window = window::WindowOptions { options, settings, detacher, startup, }; let switching = move |to: &ConnectToSession, geometry: Geometry| { switch(to, &opts, &config_options, ...
rust_dataset_chunk_516805
rust_dataset.txt
516,805
512
(crate) fn resolve( args: &TerminalArgs, config_options: &SessionOptions, capabilities: Capabilities, ) -> Result<Target, Refusal> { let attach = &args.attach; if attach.remote_url().is_some() { return remote::target(args, capabilities); } if args.watch { let info = ...
rust_dataset_chunk_516806
rust_dataset.txt
516,806
512
attach, geometry, local_config), }; let handshake = first_message( info, opts, config_options, geometry.size(), session::spawn::attaching_host_terminal_env(), focus.0, focus.1, switch_context, ); let session_name = info.get_session_name().t...
rust_dataset_chunk_516807
rust_dataset.txt
516,807
512
. pub(crate) fn start_server( session_name: &str, launch_env: Option<&BTreeMap<String, String>>, ) -> Result<PathBuf> { let cwd = session::spawn::resolve_cwd(None)?; let program = session::spawn::resolve_program()?; session::spawn::prepare_socket_dir()?; let socket_path = session::connection::ne...
rust_dataset_chunk_516808
rust_dataset.txt
516,808
512
..Default::default() }, ..config::settings::Settings::default() } } fn planned(args: &TerminalArgs) -> Result<Plan> { planned_with( args, &sized(crate::text::font::test_helpers::pixels_to_points(16.0)), ) } fn planned_with(args: &TerminalArgs, settings: &config::settings::...
rust_dataset_chunk_516809
rust_dataset.txt
516,809
512
, shown: config::window_state::Shown) -> Option<WindowState> { Some(WindowState { cols, rows, state: shown, }) } fn no_size() -> TerminalArgs { TerminalArgs { rows: None, cols: None, ..args() } } #[test] fn remember_opens_at_the_saved_size() { let pl...
rust_dataset_chunk_516810
rust_dataset.txt
516,810
512
}, &remembering(StartupMode::Remember), saved(90, 30, config::window_state::Shown::Windowed), ) .unwrap(); assert_eq!((plan.geometry.cols, plan.geometry.rows), (80, 24)); } #[test] fn a_headless_run_never_consults_the_remembered_size() { assert!(remembered( &TerminalArgs...
rust_dataset_chunk_516811
rust_dataset.txt
516,811
512
unwrap() .capabilities .local_media, "a recording must stay replayable on another machine" ); } #[test] fn a_degenerate_geometry_is_refused_before_anything_is_spawned() { for args in [ TerminalArgs { rows: Some(0), ..args() }, TerminalArgs...
rust_dataset_chunk_516812
rust_dataset.txt
516,812
512
from("/tmp/recording")), ..windowed() }, ] { assert!(!hosted_by_the_app_with(&args, false), "{:?}", args); } } #[test] fn the_request_handed_to_the_app_keeps_the_window_flags() { use zellij_utils::input::terminal::StartupMode; let mut args = TerminalArgs { startup_mo...
rust_dataset_chunk_516813
rust_dataset.txt
516,813
512
_attach(AttachArgs { session_name: Some("https://example.com/api".to_owned()), options: Some(Box::new(SessionCommand::Options(options.clone()))), token: Some("secret".to_owned()), remember: true, ca_cert: Some(PathBuf::from("/etc/ca.pem")), insecur...
rust_dataset_chunk_516814
rust_dataset.txt
516,814
512
", described ); assert!( described.contains("\"view\": \"sessions\""), "{}", described ); } #[test] fn the_panel_session_is_locked_quiet_frameless_and_never_saved() { let dialer = Dialer { opts: CliArgs::default(), config_options: SessionOptions { ...
rust_dataset_chunk_516815
rust_dataset.txt
516,815
512
..Default::default() }, ..Styling::default() }; assert_eq!(panel_border(&themed(selected_only), &options), [9, 8, 7]); let eight_bit = Styling { frame_unselected: Some(StyleDeclaration { base: PaletteColor::EightBit(4), ..Default::default() }), ...
rust_dataset_chunk_516816
rust_dataset.txt
516,816
512
let request = OpenWindowRequest { session: Some(name), create: true, options: Some(SessionOptions { pane_frames: Some(false), ..SessionOptions::default() }), ..Default::default() }; assert_eq!(dialer.options_for(&request).pane_frames, Some(false))...
rust_dataset_chunk_516817
rust_dataset.txt
516,817
512
) { Some(ClientInfo::New(name, layout, cwd, initial_panes)) => { assert!(!name.is_empty()); assert_eq!(layout, None); assert_eq!(cwd, None); assert!(initial_panes.is_none()); }, other => panic!("an unnamed window opened {:?}", other), } ass...
rust_dataset_chunk_516818
rust_dataset.txt
516,818
512
_target( &ConnectToSession { name: Some(name.clone()), ..ConnectToSession::default() }, &SessionOptions::default(), capabilities(), ); std::env::remove_var(zellij_utils::envs::SESSION_NAME_ENV_KEY); match opened.map(|target| local(target.reach)) { ...
rust_dataset_chunk_516819
rust_dataset.txt
516,819
512
_requests) .unwrap_or_default() } pub(crate) fn run_waited(args: TerminalArgs, opts: CliArgs) -> Result<i32> { let waited = session::terminal_request::Waited { command: args.execute.clone(), cwd: starting_folder(&args), hold: args.hold, }; let hosted = hosted_by_the_app(&args) ...
rust_dataset_chunk_516820
rust_dataset.txt
516,820
512
) = opened { report!("{:#}", e); } Ok(code) } pub(crate) fn run_in_background(args: TerminalArgs, opts: CliArgs) -> Result<()> { if zellij_utils::app_control::app_is_running() { return Ok(()); } let config_options = match Setup::from_cli_args(&opts) { Ok((_, _, config_option...
rust_dataset_chunk_516821
rust_dataset.txt
516,821
512
(); if args.waits_for_command() { let code = launch::run_waited(args, opts)?; std::process::exit(code); } let result = if args.background { launch::run_in_background(args, opts) } else { launch::open(args, opts) }; run.finish(&result); result } --- FILE: zel...
rust_dataset_chunk_516822
rust_dataset.txt
516,822
512
return false; }; unsafe { (ringer.bell)(ringer.display, 0); (ringer.flush)(ringer.display); } true } } #[cfg(target_os = "macos")] mod platform { #[link(name = "AppKit", kind = "framework")] extern "C" { fn NSBeep(); } pub fn ring() ...
rust_dataset_chunk_516823
rust_dataset.txt
516,823
512
WindowHandle::Win32(handle) = handle.as_raw() else { return false; }; let backdrop = backdrop(blur); let result = unsafe { DwmSetWindowAttribute( handle.hwnd.get() as *mut c_void, DWMWA_SYSTEMBACKDROP_TYPE as u32, &backdrop ...
rust_dataset_chunk_516824
rust_dataset.txt
516,824
512
FILE: zellij/zellij-terminal/src/platform/os/unix.rs --- use anyhow::Result; use crate::window::AppPoster; pub struct Run; impl Run { pub fn prepare() -> Self { Run } pub fn finish(&self, _result: &Result<()>) {} } pub fn claim_app_identity() {} pub fn terminate_on_signal(poster: AppPoster) {...
rust_dataset_chunk_516825
rust_dataset.txt
516,825
512
0x0000_0200; command.creation_flags(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP); } --- FILE: zellij/zellij-terminal/src/platform/static_build.rs --- use anyhow::{bail, Result}; pub const LOADS_SYSTEM_LIBRARIES: bool = !cfg!(all( target_os = "linux", target_env = "musl", target_feature = "crt-static...
rust_dataset_chunk_516826
rust_dataset.txt
516,826
512
io::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender}; use tokio_tungstenite::tungstenite::Message; use zellij_client::remote_attach::{ self, extract_server_url, ClientDeclaration, Prompting, WebSocketConnections, }; use zellij_client::web_client::control_message::{ TerminalMetricsPayload, We...
rust_dataset_chunk_516827
rust_dataset.txt
516,827
512
ClientToServerMsg::TerminalPixelDimensions { pixel_dimensions } => { match ( pixel_dimensions.text_area_size, pixel_dimensions.character_cell_size, ) { (Some(area), Some(cell)) => { Outbound::Control(Payload::TerminalMetrics(Te...
rust_dataset_chunk_516828
rust_dataset.txt
516,828
512
=> { Outbound::Dropped("ColorRegisters (the window answers host queries itself)".to_owned()) }, other => Outbound::Dropped(message_name(&other)), } } pub fn inbound(wire: Inbound) -> std::result::Result<ServerToClientMsg, String> { match wire { Inbound::Frame(frame) => Ok(S...
rust_dataset_chunk_516829
rust_dataset.txt
516,829
512
c| c.is_alphanumeric() || *c == '_') .collect() } fn message_name(msg: &ClientToServerMsg) -> String { let debug = format!("{:?}", msg); debug .chars() .take_while(|c| c.is_alphanumeric() || *c == '_') .collect() } struct WebSocketSink { outbound: UnboundedSender<Outbound>,...
rust_dataset_chunk_516830
rust_dataset.txt
516,830
512
url, attach, geometry, local_config) } #[derive(Debug, Clone, PartialEq)] pub struct WatchedConfig { pub path: PathBuf, pub dir: Option<PathBuf>, } pub fn watch_local_config( runtime: &tokio::runtime::Handle, config: WatchedConfig, ) -> UnboundedReceiver<()> { let (changed_tx, changed_rx) = unboun...
rust_dataset_chunk_516831
rust_dataset.txt
516,831
512
() .map(|config| (config.path.clone(), config.dir.clone())); let config_changes = local_config.map(|config| watch_local_config(runtime.handle(), config.clone())); runtime.spawn(pump( connections, outbound_rx, inbound_tx, config_changes, config_files, )...
rust_dataset_chunk_516832
rust_dataset.txt
516,832
512
); None }, } } fn push_local_settings( inbound_tx: &Sender<ServerToClientMsg>, config_files: Option<&(PathBuf, Option<PathBuf>)>, ) -> std::result::Result<(), ()> { match config_files.and_then(|(path, dir)| local_settings(path, dir.as_deref())) { Some(msg) => inb...
rust_dataset_chunk_516833
rust_dataset.txt
516,833
512
; } }, Some(Ok(_)) => {}, Some(Err(_)) | None => break, } } message = control_rx.next() => { match message { Some(Ok(Message::Text(text))) => { ...
rust_dataset_chunk_516834
rust_dataset.txt
516,834
512
{ let mut event = MouseEvent::new(); event.wheel_right = true; assert_eq!( outbound(action(Action::MouseEvent { event })), Outbound::Control(WebClientToWebServerControlMessagePayload::Mouse { event }) ); assert_eq!( outbound(action(Action::Pas...
rust_dataset_chunk_516835
rust_dataset.txt
516,835
512
_pixel_height: 18, text_area_pixel_width: 840, text_area_pixel_height: 720, } )) ); } #[test] fn the_acknowledgement_and_the_host_reply_keep_their_names() { assert_eq!( outbound(ClientToServerMsg::RenderFrameAck...
rust_dataset_chunk_516836
rust_dataset.txt
516,836
512
::RenderFrame { frame: vec![1, 2, 3] }) ); assert_eq!( inbound(Inbound::Ansi("\u{1b}[2J".to_owned())), Ok(ServerToClientMsg::Render { content: "\u{1b}[2J".to_owned() }), "ANSI is carried through as a render so th...
rust_dataset_chunk_516837
rust_dataset.txt
516,837
512
::LogError { lines: vec!["one".to_owned()] }) ); } #[test] fn the_four_control_messages_a_window_has_no_use_for_are_dropped_by_name() { let dropped = [ WebServerToWebClientControlMessage::SetConfig(Default::default()), WebServerToWebClient...
rust_dataset_chunk_516838
rust_dataset.txt
516,838
512
test] fn a_remote_window_is_handed_the_settings_of_its_own_configuration_file() { let directory = tempfile::TempDir::new().unwrap(); let path = directory.path().join("config.kdl"); std::fs::write(&path, "terminal {\n font \"Local Mono\"\n}\n").unwrap(); match local_settings(&path, No...
rust_dataset_chunk_516839
rust_dataset.txt
516,839
512
write(14); if tokio::time::timeout(std::time::Duration::from_millis(750), changes.recv()) .await .is_ok() { return true; } } false }); assert!(armed, "the w...
rust_dataset_chunk_516840
rust_dataset.txt
516,840
512
Char(char), Text(Arc<str>), } impl GlyphKey { pub fn of(text: &str) -> Self { let mut characters = text.chars(); match (characters.next(), characters.next()) { (Some(only), None) => GlyphKey::Char(only), _ => GlyphKey::Text(Arc::from(text)), } } pub ...
rust_dataset_chunk_516841
rust_dataset.txt
516,841
512
U64, Ordering}; static REVISIONS: AtomicU64 = AtomicU64::new(1); REVISIONS.fetch_add(1, Ordering::Relaxed) } impl GlyphAtlas { pub fn new(channels: u32) -> Self { let budget = if channels == 1 { MASK_BUDGET_BYTES } else { COLOR_BUDGET_BYTES }; let mut...
rust_dataset_chunk_516842
rust_dataset.txt
516,842
512
Some(rows.unwrap_or((0, 0))) } pub fn width(&self) -> u32 { self.side } pub fn height(&self) -> u32 { self.height } pub fn channels(&self) -> u32 { self.channels } pub fn coverage(&self) -> &[u8] { &self.coverage } pub fn revision(&sel...
rust_dataset_chunk_516843
rust_dataset.txt
516,843
512
+= bitmap.width + PADDING; self.shelf_height = self.shelf_height.max(bitmap.height); self.revision = next_revision(); if self.dirty_log.len() >= MAX_DIRTY_LOG { self.dirty_log.clear(); self.reshaped_at = self.revision; } else { self.dirty_log ...
rust_dataset_chunk_516844
rust_dataset.txt
516,844
512
64 { self.generation } pub fn exhausted(&self) -> bool { self.exhausted } pub fn may_flush(&self, now: Instant) -> bool { self.overflowed_at .is_none_or(|overflowed_at| now.duration_since(overflowed_at) >= OVERFLOW_RETRY) } pub fn note_overflow(&mut self, n...
rust_dataset_chunk_516845
rust_dataset.txt
516,845
512
cached; } if self.exhausted { return ClusterLookup::Blank; } let raster = self.fonts.rasterize_cluster(style, &key.text(), budget); let lookup = match raster { ClusterRaster::Sprite(bitmap) => match self.insert(&bitmap) { Insertion::Placed(...
rust_dataset_chunk_516846
rust_dataset.txt
516,846
512
return Lookup::Missing; }; self.place(key, &bitmap) } fn rendered(&mut self, glyph: Glyph, budget: u32) -> Lookup { self.rendered_with_room(glyph, budget, 0) } fn rendered_with_room(&mut self, glyph: Glyph, budget: u32, spill: u32) -> Lookup { let key = RasterKey { ...
rust_dataset_chunk_516847
rust_dataset.txt
516,847
512
}, } } } #[cfg(test)] pub(crate) mod test_helpers; #[cfg(test)] mod tests; --- FILE: zellij/zellij-terminal/src/render/atlas/test_helpers.rs --- use super::*; impl GlyphAtlas { pub fn bytes(&self) -> usize { self.coverage.len() } } impl GlyphCache { pub fn tiny(fonts: ...
rust_dataset_chunk_516848
rust_dataset.txt
516,848
512
u32, fill: u8) -> GlyphBitmap { GlyphBitmap { left: 0, top: 0, width, height, coverage: vec![fill; (width * height * 4) as usize], content: GlyphContent::Color, } } fn read(atlas: &GlyphAtlas, entry: AtlasEntry) -> Vec<u8> { let channels = atlas.channels() a...
rust_dataset_chunk_516849
rust_dataset.txt
516,849
512
2; 16]); } #[test] fn a_full_shelf_wraps_onto_the_next_one() { let mut atlas = GlyphAtlas::new(1); let mut previous = atlas.insert(&bitmap(8, 8, 1)).unwrap(); let mut wrapped = false; for _ in 0..(ATLAS_WIDTH / 8) { let entry = atlas.insert(&bitmap(8, 8, 1)).unwrap(); if entry.y > previ...
rust_dataset_chunk_516850
rust_dataset.txt
516,850
512
entry; let bold = rendered(cache.glyph(FaceStyle::Bold, 'A', 1)).entry; assert_ne!((regular.x, regular.y), (bold.x, bold.y)); } #[test] fn budgets_are_cached_independently() { let mut cache = cache(); let wide = rendered(cache.glyph(FaceStyle::Regular, '\u{4f60}', 2)).entry; let narrow = rendered(c...
rust_dataset_chunk_516851
rust_dataset.txt
516,851
512
(), before); assert!(cache.atlases().color.revision() > 0); } #[test] fn a_fallback_glyph_is_a_mask_when_the_face_has_no_color() { let mut cache = cache(); let cjk = rendered(cache.glyph(FaceStyle::Regular, '\u{4f60}', 2)); assert_eq!(cjk.content, GlyphContent::Mask); } fn tiny() -> GlyphCache { G...
rust_dataset_chunk_516852
rust_dataset.txt
516,852
512
ases().mask.revision(), cache.atlases().color.revision(), cache.generation(), cache.bytes(), ); cache.flush(); assert!(cache.atlases().mask.revision() > mask); assert!(cache.atlases().color.revision() > color); assert!(cache.generation() > generation); assert_eq!(cache.en...
rust_dataset_chunk_516853
rust_dataset.txt
516,853
512
for _ in 0..2000 { atlas.insert(&bitmap(8, 8, 1)).unwrap(); } let (top, bottom) = atlas.dirty_rows_since(seen).unwrap(); assert!(top >= first.y && bottom > top); assert_eq!( atlas.dirty_rows_since(uploaded), atlas.dirty_rows_since(uploaded), ); } #[test] fn growth_forces...
rust_dataset_chunk_516854
rust_dataset.txt
516,854
512
!cache.exhausted(), "the atlas filled up at {:?} after {} icons at size {}", icon, drawn, size ); } assert!( drawn > 10_000, "only {} icons were drawn at size {}", drawn, size ...
rust_dataset_chunk_516855
rust_dataset.txt
516,855
512
_text_keyed_glyph_is_rasterized_once_per_style_and_budget() { let mut cache = cache(); let key = GlyphKey::of("e\u{301}"); let first = cache.cluster_glyph(FaceStyle::Regular, &key, 1); assert!(matches!(first, ClusterLookup::Sprite(_)), "{:?}", first); let revision = cache.atlases().mask.revision(); ...
rust_dataset_chunk_516856
rust_dataset.txt
516,856
512
rendered.entry.width <= cache.metrics().width * 2); }, other => panic!("the family was not one sprite: {:?}", other), } assert_eq!(cache.cluster_entries(), entries + 1); assert_eq!(cache.atlases().mask.revision(), before); } #[test] fn a_cluster_nothing_covers_is_remembered_as_drawn_cell_by...
rust_dataset_chunk_516857
rust_dataset.txt
516,857
512
/zellij-terminal/src/render/graphics.rs --- use anyhow::{anyhow, Result}; use glutin::config::Config; use glutin::context::{ ContextApi, ContextAttributes, ContextAttributesBuilder, GlProfile, NotCurrentContext, Version, }; use glutin::display::Display; use glutin::prelude::*; use winit::raw_window_handle::RawWindo...
rust_dataset_chunk_516858
rust_dataset.txt
516,858
512
&request.attributes(handle)) } { Ok(context) => { // Every window and panel opening gets here, so only a fallback is worth saying // out loud; the usual choice goes to the log. if refusals.is_empty() { log::info!("drawing through {}", requ...
rust_dataset_chunk_516859
rust_dataset.txt
516,859
512
fn linux_asks_for_exactly_the_es_context_the_goldens_were_drawn_with() { assert_eq!( context_attempts(Platform::Linux), &[ContextRequest::Gles { major: 3, minor: 0 }] ); } #[test] fn macos_asks_only_for_desktop_core_contexts_newest_first() { assert_eq!( ...
rust_dataset_chunk_516860
rust_dataset.txt
516,860
512
Dialect::for_context(false, 3, 3).unwrap(), ShaderDialect::Glsl330 ); assert_eq!( ShaderDialect::for_context(false, 4, 0).unwrap(), ShaderDialect::Glsl330 ); assert_eq!( ShaderDialect::for_context(false, 4, 1).unwrap(), ShaderDi...
rust_dataset_chunk_516861
rust_dataset.txt
516,861
512
.write_image_data(&image.pixels) .context("failed to write PNG pixels")?; } Ok(encoded) } pub fn decode(encoded: &[u8]) -> Result<Image> { let decoder = png::Decoder::new(encoded); let mut reader = decoder.read_info().context("failed to read PNG header")?; let mut pixels = ...
rust_dataset_chunk_516862
rust_dataset.txt
516,862
512
::path::Path; impl Image { pub fn pixel(&self, x: u32, y: u32) -> [u8; 4] { let offset = ((y * self.width + x) * 4) as usize; [ self.pixels[offset], self.pixels[offset + 1], self.pixels[offset + 2], self.pixels[offset + 3], ] } } pub fn w...
rust_dataset_chunk_516863
rust_dataset.txt
516,863
512
impl Pacer { pub fn new(millihertz: Option<u32>) -> Self { Self { interval: interval_of(millihertz), last_draw: None, pending: false, } } pub fn interval(&self) -> Duration { self.interval } pub fn follow_refresh(&mut self, millihertz: Op...
rust_dataset_chunk_516864
rust_dataset.txt
516,864
512
(); let boundary = start + pacer.interval(); assert_eq!( pacer.decide(start + Duration::from_micros(700)), Decision::At(boundary) ); assert_eq!( pacer.decide(boundary - Duration::from_micros(1)), Decision::At(boundary) ); } ...
rust_dataset_chunk_516865
rust_dataset.txt
516,865
512
(1), Some(19_999), Some(500_001), Some(u32::MAX), ] { assert_eq!( interval_of(reported), sixty, "{:?} is not a refresh rate to pace by", reported ); } } #[test] fn fol...
rust_dataset_chunk_516866
rust_dataset.txt
516,866
512
uploaded: Option<crate::render::atlas::AtlasStamp>, uploaded_size: (u32, u32), atlas: &GlyphAtlas, ) -> AtlasUpload { let size = (atlas.width(), atlas.height()); if size.1 == 0 { return AtlasUpload::Nothing; } let Some(uploaded) = uploaded else { return AtlasUpload::Whole; ...
rust_dataset_chunk_516867
rust_dataset.txt
516,867
512
(atlas.coverage())), ); }, } } target.size = size; target.uploaded = Some(atlas.stamp()); } --- FILE: zellij/zellij-terminal/src/render/renderer/images.rs --- use crate::render::renderer::bytemuck_cast; use crate::render::renderer::push_image_vertices; use crate::render...
rust_dataset_chunk_516868
rust_dataset.txt
516,868
512
{ let stale: Vec<ImageKey> = self .images .keys() .copied() .filter(|key| resident.binary_search(key).is_err()) .collect(); for key in stale { if let Some(image) = self.images.remove(&key) { unsafe { self.gl.delete_...
rust_dataset_chunk_516869
rust_dataset.txt
516,869
512
::render::renderer::GLYPH_STRIDE; use crate::render::renderer::SOLID_STRIDE; use anyhow::{anyhow, Result}; use glow::HasContext; pub(crate) const SOLID_VERTEX: &str = r#"uniform vec2 u_viewport; uniform vec2 u_origin; in vec2 a_position; in vec3 a_color; out vec3 v_color; void main() { v_color = a_color; vec2 ...
rust_dataset_chunk_516870
rust_dataset.txt
516,870
512
= texel.rgb * v_color; o_color = vec4(tinted * texel.a, texel.a); } "#; pub(super) unsafe fn premultiplied_blending(gl: &glow::Context) { gl.blend_func_separate( glow::ONE, glow::ONE_MINUS_SRC_ALPHA, glow::ONE, glow::ONE_MINUS_SRC_ALPHA, ); } pub(super) unsafe fn solid_pas...
rust_dataset_chunk_516871
rust_dataset.txt
516,871
512
(f32, f32), ) { if vertices.is_empty() { return; } gl.use_program(Some(pass.program)); gl.uniform_2_f32(pass.viewport.as_ref(), viewport.0, viewport.1); gl.uniform_2_f32(pass.origin.as_ref(), origin.0, origin.1); gl.bind_vertex_array(Some(pass.vertex_array)); gl.bind_buffer(glow::AR...
rust_dataset_chunk_516872
rust_dataset.txt
516,872
512
.delete_shader(shader); } Ok(program) } --- FILE: zellij/zellij-terminal/src/render/renderer/row_buffers.rs --- use super::*; use crate::render::renderer::rows::lay_out; use crate::render::renderer::rows::write_slot; use crate::render::scene::{Rect, RowScene}; fn row(rects: usize) -> RowScene { RowScene...
rust_dataset_chunk_516873
rust_dataset.txt
516,873
512
= Vec::new(); push_solid_vertices(&mut vertices, &row(SLOT_QUADS).rects); assert_eq!( write_slot(&mut buffer, 0, &vertices), Some((offset, capacity)) ); assert_eq!(live(&buffer, 0), vertices); assert!( buffer.data[offset + vertices.len()..offset + capacity] .iter...
rust_dataset_chunk_516874
rust_dataset.txt
516,874
512
32) -> Self { Self { stride_floats: stride as usize / 4, data: Vec::new(), slots: Vec::new(), uploaded: 0, atlas_size: (0, 0), } } pub(super) fn quad_floats(&self) -> usize { self.stride_floats * VERTICES_PER_QUAD } pu...
rust_dataset_chunk_516875
rust_dataset.txt
516,875
512
{ upload_whole(gl, pass, buffer); return; } unsafe { gl.bind_vertex_array(Some(pass.vertex_array)); gl.bind_buffer(glow::ARRAY_BUFFER, Some(pass.buffer)); for (offset, len) in ranges { gl.buffer_sub_data_u8_slice( glow::ARRAY_BUFFER, ...
rust_dataset_chunk_516876
rust_dataset.txt
516,876
512
gl.buffer_data_u8_slice( glow::ARRAY_BUFFER, bytemuck_cast(&buffer.data), glow::DYNAMIC_DRAW, ); } } pub(super) unsafe fn draw_rows( gl: &glow::Context, pass: &Pass, buffer: &RowVertices, viewport: (f32, f32), origin: (f32, f32), ) { if bu...
rust_dataset_chunk_516877
rust_dataset.txt
516,877
512
pub layer: Option<&'a crate::render::scroll_animation::ScrollLayer>, } struct Pass { program: glow::Program, vertex_array: glow::VertexArray, buffer: glow::Buffer, viewport: Option<glow::UniformLocation>, origin: Option<glow::UniformLocation>, } pub struct Renderer { gl: glow::Context, so...
rust_dataset_chunk_516878
rust_dataset.txt
516,878
512
"u_origin"), program: glyph_program, vertex_array: gl.create_vertex_array().map_err(|e| anyhow!(e))?, buffer: gl.create_buffer().map_err(|e| anyhow!(e))?, }; gl.bind_vertex_array(Some(glyph.vertex_array)); gl.bind_buffer(glow::ARRAY_BU...
rust_dataset_chunk_516879
rust_dataset.txt
516,879
512
4 * 4); let fade = Pass { viewport: gl.get_uniform_location(solid_program, "u_viewport"), origin: gl.get_uniform_location(solid_program, "u_origin"), program: solid_program, vertex_array: gl.create_vertex_array().map_err(|e| anyhow!(e))?, ...
rust_dataset_chunk_516880
rust_dataset.txt
516,880
512
_atlas, atlases.mask); upload_atlas(&self.gl, &mut self.color_atlas, atlases.color); let everything = self.retained != Some(scene.identity()) || scene.rebuilt_everything(); self.retained = Some(scene.identity()); if everything || scene.replaced_images() { self.sync_images(sc...
rust_dataset_chunk_516881
rust_dataset.txt
516,881
512
.solid, &self.solid_rows, viewport, origin); if let Some(layer) = layer { self.layer_vertices.clear(); push_solid_vertices(&mut self.layer_vertices, &layer.rects); draw_pass( &self.gl, &self.layer_solid, ...
rust_dataset_chunk_516882
rust_dataset.txt
516,882
512
.0, 0.0, width, height) { vertices.extend_from_slice(&[x, y, 0.0, 0.0, 0.0]); } self.gl.blend_color(0.0, 0.0, 0.0, opacity); self.gl.blend_func_separate( glow::ZERO, glow::CONSTANT_ALPHA, glow::ZERO, glow::CONSTANT_ALPHA, ); ...
rust_dataset_chunk_516883
rust_dataset.txt
516,883
512
Some(image.texture)); self.gl .draw_arrays(glow::TRIANGLES, batch.first, batch.count); } } unsafe fn draw_layer_images( &mut self, images: &[ImageQuad], viewport: (f32, f32), origin: (f32, f32), below_text: bool, ) { for q...
rust_dataset_chunk_516884
rust_dataset.txt
516,884
512
f32); let origin = (0.0, 0.0); unsafe { draw_pass( &self.gl, &self.solid, &solid_vertices, SOLID_STRIDE, viewport, origin, ); self.gl.active_texture(glow::TEXTURE0); ...
rust_dataset_chunk_516885
rust_dataset.txt
516,885
512
_samples_the_source_rectangle_it_names() { let quad = ImageQuad { key: ImageKey::Kitty(1), revision: 1, x: 10, y: 20, width: 4, height: 5, source_x: 2, source_y: 5, z: 0, image: std::rc::Rc::new(crate::emulation::kitty::Image { ...
rust_dataset_chunk_516886
rust_dataset.txt
516,886
512
0); assert_eq!( plan_atlas_upload(None, (0, 0), &empty), AtlasUpload::Nothing ); assert_eq!( plan_atlas_upload(Some(other), (4096, 256), &empty), AtlasUpload::Nothing ); assert_eq!( plan_atlas_upload(Some(other), (empty.width(), 0), &empty), AtlasUplo...
rust_dataset_chunk_516887
rust_dataset.txt
516,887
512
); } #[test] fn a_texture_last_filled_by_another_atlas_is_uploaded_whole_even_if_that_atlas_changed_later() { let mut ours = GlyphAtlas::new(1); let mut theirs = GlyphAtlas::new(1); ours.insert(&glyph(8, 16)).unwrap(); theirs.insert(&glyph(8, 16)).unwrap(); theirs.insert(&glyph(8, 16)).unwrap()...
rust_dataset_chunk_516888
rust_dataset.txt
516,888
512
let (u0, v0) = ( quad.source_x as f32 / image_width, quad.source_y as f32 / image_height, ); let (u1, v1) = ( (quad.source_x + quad.width) as f32 / image_width, (quad.source_y + quad.height) as f32 / image_height, ); for ((x, y), (u, v)) in quad_corners(x0, y0, x1, y1...
rust_dataset_chunk_516889
rust_dataset.txt
516,889
512
(vertices), ) } } pub(super) fn quad_corners(x0: f32, y0: f32, x1: f32, y1: f32) -> [(f32, f32); 6] { [(x0, y0), (x1, y0), (x1, y1), (x0, y0), (x1, y1), (x0, y1)] } pub(super) fn normalized(color: crate::emulation::color::Srgb) -> [f32; 3] { [ color[0] as f32 / 255.0, color[1] as f...
rust_dataset_chunk_516890
rust_dataset.txt
516,890
512
rebuilt_rows: Vec<usize>, } impl Default for RetainedScene { fn default() -> Self { Self::new() } } impl RetainedScene { pub fn new() -> Self { Self { identity: next_identity(), width: 0, height: 0, clear: [0, 0, 0], transparency...
rust_dataset_chunk_516891
rust_dataset.txt
516,891
512
() .chain(held.iter()) .map(|held| (held.content.y, held.content.rows)) .collect(); for (top, rows) in spans { for row in top..top + rows { self.mark_row(row); } } self.held = held; self.held_changed = true; ...
rust_dataset_chunk_516892
rust_dataset.txt
516,892
512
with_transparency(self.transparency) .with_contrast(&self.contrast) .with_held_out(&self.held) .with_selection(self.selection.as_ref()); let (width, height) = (context.width(), context.height()); if self.generation != cache.generation() || self.rows.len() ...
rust_dataset_chunk_516893
rust_dataset.txt
516,893
512
oned() .collect(), ) } pub fn blink_damage(state: &TerminalState, cursor: CursorOptions) -> Damage { let mut rows: Vec<usize> = state.screen().blinking_rows().collect(); if state.cursor_is_visible() && cursor.blinks(state.cursor_is_blinking()) { rows.push(state.cursor_position().0); ...
rust_dataset_chunk_516894
rust_dataset.txt
516,894
512
Medium, GraphicsRecord, GRAPHICS_FORMAT_RGBA8, }; fn cache() -> GlyphCache { GlyphCache::new(FontStack::embedded(DEFAULT_FONT_SIZE).expect("no embedded font")) } fn refreshed(scene: &mut RetainedScene, state: &TerminalState, cache: &mut GlyphCache) { scene.refresh( SceneInputs { state: sta...
rust_dataset_chunk_516895
rust_dataset.txt
516,895
512
_eq!(retained.rebuilt_rows(), [2]); assert_eq!(retained.flatten(), rebuilt(&state, &mut cache)); } #[test] fn a_new_glyph_cache_rebuilds_every_row() { let mut cache = cache(); let state = painted(); let mut retained = RetainedScene::new(); refreshed(&mut retained, &state, &mut cache); refreshed...
rust_dataset_chunk_516896
rust_dataset.txt
516,896
512
&state, &mut cache); assert_eq!(retained.rebuilt_rows(), [1, 2]); assert_eq!(retained.flatten(), rebuilt(&state, &mut cache)); } #[test] fn a_row_index_past_the_viewport_marks_everything() { let mut cache = cache(); let state = painted(); let mut retained = RetainedScene::new(); refreshed(&mut...
rust_dataset_chunk_516897
rust_dataset.txt
516,897
512
default(), hovered_link: None, preedit: None, }, &mut cache, ); assert_eq!(retained.rebuilt_rows(), [2]); assert_eq!( retained.flatten(), scene::test_helpers::build_at( &state, &mut cache, BlinkPhase::Off, ...
rust_dataset_chunk_516898
rust_dataset.txt
516,898
512
a_screen_the_atlas_cannot_hold_is_not_flushed_on_every_refresh() { let mut cache = tiny_cache(); let state = overflowing(); let mut retained = RetainedScene::new(); refreshed(&mut retained, &state, &mut cache); assert!( cache.exhausted(), "the screen must overflow even a freshly flu...
rust_dataset_chunk_516899
rust_dataset.txt
516,899
512
format: GRAPHICS_FORMAT_RGBA8, medium: GraphicsMedium::Inline, byte_len: 16, data: [10, 20, 30, 255].repeat(4), }, placement(cell_x), ], ); state } fn see_through() -> Transparency { Transparency { opacity: 0.8, ...