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_512800 | rust_dataset.txt | 512,800 | 512 | entered_from_direction,
notify_guest,
) => {
let mut session_data = session_data.write().unwrap();
if let Some(session_data) = session_data.as_mut() {
let previous_pane = session_data
.key_passthrough_clients
... |
rust_dataset_chunk_512801 | rust_dataset.txt | 512,801 | 512 | Status(status) => {
if last_host_program_status != status {
last_host_program_status = status.clone();
let client_ids = session_state.read().unwrap().client_ids();
for client_id in client_ids {
let _ = os_input.send_to_c... |
rust_dataset_chunk_512802 | rust_dataset.txt | 512,802 | 512 | ounded);
let (to_plugin, plugin_receiver): ChannelWithContext<PluginInstruction> = channels::unbounded();
let to_plugin = SenderWithContext::new(to_plugin);
let (to_pty, pty_receiver): ChannelWithContext<PtyInstruction> = channels::unbounded();
let to_pty = SenderWithContext::new(to_pty);
let (to_... |
rust_dataset_chunk_512803 | rust_dataset.txt | 512,803 | 512 | .spawn({
let layout = layout.clone();
let pty = Pty::new(
Bus::new(
vec![pty_receiver],
Some(&to_screen_bounded),
None,
Some(&to_plugin),
Some(&to_server),
Som... |
rust_dataset_chunk_512804 | rust_dataset.txt | 512,804 | 512 | spawn({
let plugin_bus = Bus::new(
vec![plugin_receiver],
Some(&to_screen_bounded),
Some(&to_pty),
Some(&to_plugin),
Some(&to_server),
Some(&to_pty_writer),
Some(&to_background_jobs),
... |
rust_dataset_chunk_512805 | rust_dataset.txt | 512,805 | 512 | background_jobs_bus,
serialization_interval,
disable_session_metadata,
web_server_base_url,
session_id,
live_sessions,
)
.fatal()
}
})
.unwrap();
let mut k... |
rust_dataset_chunk_512806 | rust_dataset.txt | 512,806 | 512 | background_jobs_thread: Some(background_jobs_thread),
#[cfg(feature = "web_server_capability")]
web_sharing: config.options.web_sharing.unwrap_or(WebSharing::Off),
#[cfg(not(feature = "web_server_capability"))]
web_sharing: WebSharing::Disabled,
key_passthrough_clients: H... |
rust_dataset_chunk_512807 | rust_dataset.txt | 512,807 | 512 | _utils::desktop_integration::load();
if let Some(offer) = launcher_repair_offer(&state) {
return Some(plugin_floating_pane(
"about",
window_flag(BTreeMap::from([
("page".to_owned(), "repair".to_owned()),
("missing".to_owned(), offer.missing.display().t... |
rust_dataset_chunk_512808 | rust_dataset.txt | 512,808 | 512 | None
}
#[cfg(all(unix, not(target_os = "macos")))]
fn launcher_repair_offer(
_state: &zellij_utils::desktop_integration::IntegrationState,
) -> Option<zellij_utils::desktop_integration::RepairOffer> {
zellij_utils::desktop_integration::platform::launcher_repair_offer()
}
#[cfg(not(all(unix, not(target_os = "... |
rust_dataset_chunk_512809 | rust_dataset.txt | 512,809 | 512 | )
}
}
fn report_changes_in_config_file(
config_file_path: PathBuf,
config_dir: Option<&Path>,
to_server: SenderWithContext<ServerInstruction>,
) {
let config_dir = config_dir.map(Path::to_path_buf);
global_async_runtime::get_tokio_runtime().spawn(async move {
watch_config_file_changes(c... |
rust_dataset_chunk_512810 | rust_dataset.txt | 512,810 | 512 | : &Arc<RwLock<Option<SessionMetaData>>>,
) -> bool {
let (changes, dropped_changes) = session_data
.write()
.unwrap()
.as_mut()
.unwrap()
.session_configuration
.change_saved_config(new_saved_config);
let propagated_changes = !changes.is_empty();
let config_wa... |
rust_dataset_chunk_512811 | rust_dataset.txt | 512,811 | 512 | ToSession, zellij_utils::session_history::SessionHistory> {
let mut history = client_histories
.get(&client_id)
.cloned()
.unwrap_or_default();
history.remove_session(own_session_name);
loop {
let Some(target) = history.target(history_move).map(|t| t.to_owned()) else {
... |
rust_dataset_chunk_512812 | rust_dataset.txt | 512,812 | 512 | _name: &str,
new_name: &str,
) {
for history in client_histories.values_mut() {
history.rename_session(old_name, new_name);
}
}
#[inline(never)]
fn attach_switch_context(
connect_to_session: &mut ConnectToSession,
client_histories: &mut HashMap<ClientId, zellij_utils::session_history::Sessi... |
rust_dataset_chunk_512813 | rust_dataset.txt | 512,813 | 512 | .from_session.clone(),
});
if may_be_a_reattach && !switch_context.is_a_switch() {
let _ = senders.send_to_background_jobs(BackgroundJob::SessionSuggestions(
SessionSuggestionsJob::ClientReattached {
client_id,
away_since_ms: last_detached_at_ms.unwrap_or_else... |
rust_dataset_chunk_512814 | rust_dataset.txt | 512,814 | 512 | => {
log::error!("No config file path found.");
SaveOutcome::Failed(None)
},
}
};
match outcome {
SaveOutcome::Written {
file_contents,
saved_config,
changed_outside,
} => {
let saved_config = if... |
rust_dataset_chunk_512815 | rust_dataset.txt | 512,815 | 512 | config_file_path, config_dir.as_deref())
} else {
Config::from_default_assets().ok()
};
match reloaded {
Some(reloaded) => Ok((contents, reloaded)),
None => Err(Some(config_file_path)),
}
}
fn reload_config_file(session_data: &Arc<RwLock<Option<SessionMetaData>>>) {
let (con... |
rust_dataset_chunk_512816 | rust_dataset.txt | 512,816 | 512 | _configuration = session_with_theme_dir(&theme_dir);
let (path, theme) = session_configuration
.write_theme_file(&1, "mine", Some("dracula"), &[])
.unwrap();
assert_eq!(path, theme_dir.join("mine.kdl"));
assert!(theme.sourced_from_external_file);
let dracula = con... |
rust_dataset_chunk_512817 | rust_dataset.txt | 512,817 | 512 | &colours)
.is_err());
}
#[test]
fn deleting_a_folder_theme_brings_back_the_built_in_one() {
let dir = tempfile::tempdir().unwrap();
let theme_dir = dir.path().join("themes");
let session_configuration = session_with_theme_dir(&theme_dir);
let mut palette = zelli... |
rust_dataset_chunk_512818 | rust_dataset.txt | 512,818 | 512 | .last.as_deref(), Some("s1"));
assert_eq!(client_histories.get(&7), Some(&merged));
let mut toggled = merged.clone();
assert_eq!(
toggled.apply(HistoryMove::Toggle, "s2"),
Some("s1".to_owned())
);
let mut walked = merged.clone();
assert_eq!(walked.... |
rust_dataset_chunk_512819 | rust_dataset.txt | 512,819 | 512 | <u8>,
plugin_name: String,
plugin_id: PluginId,
}
impl LoggingPipe {
pub fn new(plugin_name: &str, plugin_id: PluginId) -> LoggingPipe {
LoggingPipe {
buffer: VecDeque::new(),
plugin_name: String::from(plugin_name),
plugin_id,
}
}
fn log_message(... |
rust_dataset_chunk_512820 | rust_dataset.txt | 512,820 | 512 | {
// Log last chunk iff the last char is endline. Otherwise do not do it.
if converted_buffer.ends_with('\n') && !msg.is_empty() {
self.log_message(msg);
consumed_bytes += msg.len() + 1;
... |
rust_dataset_chunk_512821 | rust_dataset.txt | 512,821 | 512 | test_buffer,
test_buffer,
test_buffer,
test_buffer,
test_buffer,
]
.concat()
.as_slice(),
)
.expect("Err write");
pipe.flush().expect("Err flush");
assert_eq!(pipe.buffer.len(), 0);
... |
rust_dataset_chunk_512822 | rust_dataset.txt | 512,822 | 512 | fn ping_interval_ms() -> u64 {
std::env::var("ZELLIJ_NESTED_PING_INTERVAL_MS")
.ok()
.and_then(|value| value.parse().ok())
.unwrap_or(PING_INTERVAL_MS)
}
pub fn pong_timeout_ms() -> u64 {
std::env::var("ZELLIJ_NESTED_PONG_TIMEOUT_MS")
.ok()
.and_then(|value| value.parse... |
rust_dataset_chunk_512823 | rust_dataset.txt | 512,823 | 512 | remove(&mut self, pane_id: PaneId) {
self.last_heard_from.remove(&pane_id);
self.dormant.remove(&pane_id);
}
pub fn is_tracked(&self, pane_id: PaneId) -> bool {
self.last_heard_from.contains_key(&pane_id)
}
pub fn is_dormant(&self, pane_id: PaneId) -> bool {
self.dormant... |
rust_dataset_chunk_512824 | rust_dataset.txt | 512,824 | 512 | = PaneId::Terminal(1);
let start = Instant::now();
tracker.on_announce(pane_id, start);
assert_eq!(
tracker.on_tick(pane_id, start + millis(PONG_TIMEOUT_MS + 1)),
GuestPingTickAction::Suspended
);
let much_later = start + millis(PONG_TIMEOUT_MS + 120_000)... |
rust_dataset_chunk_512825 | rust_dataset.txt | 512,825 | 512 | ::Unknown);
}
#[test]
fn removed_guest_stops_being_tracked() {
let mut tracker = NestedGuestTracker::default();
let pane_id = PaneId::Terminal(1);
let now = Instant::now();
tracker.on_announce(pane_id, now);
tracker.remove(pane_id);
assert_eq!(tracker.on_tick... |
rust_dataset_chunk_512826 | rust_dataset.txt | 512,826 | 512 | {7}", payload)),
NotificationProtocol::Osc9 => Some(format!("\u{1b}]9;{}\u{7}", payload)),
NotificationProtocol::Bell => Some("\u{7}".to_owned()),
NotificationProtocol::Off => None,
}
}
}
#[cfg(test)]
#[path = "./unit/notifications_tests.rs"]
mod notifications_tests;
-... |
rust_dataset_chunk_512827 | rust_dataset.txt | 512,827 | 512 | y();
for ext in pathext.split(';') {
let ext = ext.trim();
if ext.is_empty() {
continue;
}
let mut with_ext = candidate.as_os_str().to_os_string();
with_ext.push(ext);
... |
rust_dataset_chunk_512828 | rust_dataset.txt | 512,828 | 512 | : &mut PathBuf, args: &mut Vec<String>) {
let mut parts = vec![];
let mut current_part = String::new();
for part in command.display().to_string().split_ascii_whitespace() {
current_part.push_str(part);
if current_part.ends_with('\\') {
let _ = current_part.pop();
curr... |
rust_dataset_chunk_512829 | rust_dataset.txt | 512,829 | 512 | im")
|| command.ends_with("emacs")
|| command.ends_with("nano")
|| command.ends_with("kak")
{
failover_cmd_args = Some(vec![file_to_open.clone()]);
args.push(format!("+{}", line_number));
... |
rust_dataset_chunk_512830 | rust_dataset.txt | 512,830 | 512 | bounded();
let queued = Arc::new(AtomicUsize::new(0));
(
ClientBuffer {
sender,
queued: queued.clone(),
limit,
},
ClientBufferReceiver { receiver, queued },
)
}
impl ClientBuffer {
fn try_send(&self, msg: ServerToClientMsg) -> Result<(), TrySe... |
rust_dataset_chunk_512831 | rust_dataset.txt | 512,831 | 512 | ::spawn(move || {
let err_context = || format!("failed to send message to client {client_id}");
while let Some(msg) = client_buffer_receiver.recv() {
sender
.send_server_msg(msg)
.with_context(err_context)
.non_fatal();
... |
rust_dataset_chunk_512832 | rust_dataset.txt | 512,832 | 512 | ,
id: u32,
cols: u16,
rows: u16,
width_in_pixels: Option<u16>,
height_in_pixels: Option<u16>,
) -> Result<()>;
/// Spawn a new terminal, with a terminal action. The returned tuple contains:
/// - terminal_id (u32)
/// - an async reader for the PTY output
/// -... |
rust_dataset_chunk_512833 | rust_dataset.txt | 512,833 | 512 | mut self, client_id: ClientId) -> Result<()>;
fn load_palette(&self) -> Palette;
/// Returns the current working directory for a given pid
fn get_cwd(&self, pid: u32) -> Option<PathBuf>;
/// Returns the current working directory for multiple pids
fn get_cwds(&self, _pids: Vec<u32>) -> (HashMap<u32, ... |
rust_dataset_chunk_512834 | rust_dataset.txt | 512,834 | 512 | _terminal_size(id, cols, rows, width_in_pixels, height_in_pixels)
}
fn spawn_terminal(
&self,
terminal_action: TerminalAction,
quit_cb: Box<dyn Fn(PaneId, Option<i32>, RunCommand) + Send>,
default_editor: Option<PathBuf>,
pane_env: &PaneEnv,
) -> Result<(u32, Box<dyn ... |
rust_dataset_chunk_512835 | rust_dataset.txt | 512,835 | 512 | !("failed to send message to client {client_id}");
if let Some(sender) = self
.client_senders
.lock()
.to_anyhow()
.with_context(err_context)?
.get_mut(&client_id)
{
sender.send_or_buffer(msg).with_context(err_context)
} el... |
rust_dataset_chunk_512836 | rust_dataset.txt | 512,836 | 512 | None
}
fn get_cwds(&self, pids: Vec<u32>) -> (HashMap<u32, PathBuf>, HashMap<u32, Vec<String>>) {
let mut system_info = System::new();
let mut cwds = HashMap::new();
let mut cmds = HashMap::new();
let sysinfo_pids: Vec<sysinfo::Pid> =
pids.iter().map(|&p| sysinfo::... |
rust_dataset_chunk_512837 | rust_dataset.txt | 512,837 | 512 | 32, u32)],
post_hook: &Option<String>,
) -> HashMap<u32, Vec<String>> {
let mut terminal_to_fg_pid: HashMap<u32, u32> = HashMap::new();
for &(terminal_id, shell_pid) in panes {
if let Some(fpgid) = self.pty_backend.tcgetpgrp(terminal_id) {
if fpgid > 0 && fpgid as... |
rust_dataset_chunk_512838 | rust_dataset.txt | 512,838 | 512 | = ppids_to_cmds.get(&shell_pid.to_string()) {
cmds.insert(terminal_id, apply_post_command_hook(cmd.clone(), post_hook));
}
}
cmds
}
fn write_to_file(&mut self, buf: String, name: Option<String>) -> Result<()> {
let err_context = || "failed to write to file".... |
rust_dataset_chunk_512839 | rust_dataset.txt | 512,839 | 512 | (ServerOsInputOutput {
pty_backend: PtyBackendImpl::new()?,
client_senders: Arc::new(Mutex::new(HashMap::new())),
cached_resizes: Arc::new(Mutex::new(None)),
})
}
use crate::pty_writer::PtyWriteInstruction;
use crate::thread_bus::ThreadSenders;
pub struct ResizeCache {
senders: ThreadS... |
rust_dataset_chunk_512840 | rust_dataset.txt | 512,840 | 512 | -> Result<String, Box<dyn std::error::Error>> {
use std::os::windows::process::CommandExt;
// Passed as a raw argument because .arg() escapes quotes as \", which cmd
// doesn't understand. /D /S and the outer quotes work as in
// BackgroundCommand::shell.
let output = Command::new("cmd")
.a... |
rust_dataset_chunk_512841 | rust_dataset.txt | 512,841 | 512 | the runtime).
struct RawFdAsyncReader {
/// Holds the file before reactor registration; `None` after promotion.
pending: Option<File>,
/// Populated on first `read()` inside the Tokio runtime.
async_fd: Option<AsyncFd<File>>,
}
impl RawFdAsyncReader {
fn new(fd: RawFd) -> io::Result<Self> {
... |
rust_dataset_chunk_512842 | rust_dataset.txt | 512,842 | 512 | 0 {
break;
}
unsafe { buf.set_len(filled + more as usize) };
}
buf.shrink_to_fit();
Ok(buf)
}
#[async_trait]
impl AsyncReader for RawFdAsyncReader {
async fn read_chunk(&mut self, max: usize) -> Result<Vec<u8>, io::Error> {
let async_fd = self.get_async_fd()?;
... |
rust_dataset_chunk_512843 | rust_dataset.txt | 512,843 | 512 | // and exit this function
// TODO: handle errors?
break 'handle_exit Ok(status.code());
},
Ok(None) => {
thread::sleep(Duration::from_millis(10));
},
Err(e) => panic!("error attempting to wait: {}", e),
... |
rust_dataset_chunk_512844 | rust_dataset.txt | 512,844 | 512 | {
Some(value) => command.env(name, value),
None => command.env_remove(name),
};
}
command
.args(&cmd.args)
.env("ZELLIJ_PANE_ID", &format!("{}", terminal_id))
.pre_exec(move || -> io::Result<()> {
if libc::l... |
rust_dataset_chunk_512845 | rust_dataset.txt | 512,845 | 512 | descriptors and signals.
#[derive(Clone)]
pub(crate) struct UnixPtyBackend {
orig_termios: Arc<Mutex<Option<termios::Termios>>>,
terminal_id_to_raw_fd: Arc<Mutex<BTreeMap<u32, Option<RawFd>>>>,
next_terminal_id_counter: Arc<AtomicU32>,
}
/// Try to write as many bytes from `buf` as possible to `fd` withou... |
rust_dataset_chunk_512846 | rust_dataset.txt | 512,846 | 512 | = self
.orig_termios
.lock()
.to_anyhow()
.context("failed to lock orig_termios")?;
let (pid_primary, child_fd) = handle_terminal(
cmd,
failover_cmd,
orig_termios.clone(),
quit_cb,
terminal_id,
... |
rust_dataset_chunk_512847 | rust_dataset.txt | 512,847 | 512 | _fd(fd, buf).with_context(err_context)
}
pub fn tcdrain(&self, terminal_id: u32) -> Result<()> {
let err_context = || format!("failed to tcdrain to TTY ID {}", terminal_id);
match self
.terminal_id_to_raw_fd
.lock()
.to_anyhow()
.with_context(err... |
rust_dataset_chunk_512848 | rust_dataset.txt | 512,848 | 512 | mod tests {
use super::*;
use nix::fcntl::{fcntl, FcntlArg, OFlag};
use nix::sys::termios;
use std::io::{Read, Write};
#[test]
fn raw_fd_reader_returns_exact_bytes_in_order() {
let mut fds = [0 as libc::c_int; 2];
assert_eq!(unsafe { libc::pipe(fds.as_mut_ptr()) }, 0);
l... |
rust_dataset_chunk_512849 | rust_dataset.txt | 512,849 | 512 | borrowed_master = unsafe { BorrowedFd::borrow_raw(master_fd) };
let borrowed_slave = unsafe { BorrowedFd::borrow_raw(slave_fd) };
let mut attrs = termios::tcgetattr(borrowed_slave).expect("tcgetattr failed");
termios::cfmakeraw(&mut attrs);
termios::tcsetattr(borrowed_slave, termios::S... |
rust_dataset_chunk_512850 | rust_dataset.txt | 512,850 | 512 | not error on EAGAIN");
assert!(
written > 0 && written < size,
"expected partial write, got {written}/{size}",
);
unsafe {
libc::close(master_fd);
libc::close(slave_fd);
}
}
/// Verify that `try_write_to_fd` returns Ok(0) — not ... |
rust_dataset_chunk_512851 | rust_dataset.txt | 512,851 | 512 | }
--- FILE: zellij/zellij-server/src/os_input_output_windows.rs ---
use crate::os_input_output::{resolve_command, AsyncReader, PaneEnv};
use crate::panes::PaneId;
use std::{
collections::BTreeMap,
ffi::{OsStr, OsString},
io, mem,
os::windows::ffi::OsStrExt,
os::windows::io::{FromRawHandle, IntoRa... |
rust_dataset_chunk_512852 | rust_dataset.txt | 512,852 | 512 | PIPE_TYPE_BYTE: u32 = 0;
const PIPE_WAIT: u32 = 0;
const GENERIC_WRITE: u32 = 0x40000000;
/// Monotonic counter so each ConPTY output pipe gets a unique name, even when
/// re-spawning on the same `terminal_id` (the old async reader may still hold
/// the previous pipe handle).
static PIPE_SEQ: AtomicU64 = AtomicU64:... |
rust_dataset_chunk_512853 | rust_dataset.txt | 512,853 | 512 | PTY_DLL_NAME: &str = "conpty.dll";
const OPEN_CONSOLE_EXE_NAME: &str = "OpenConsole.exe";
/// Where to get the pseudoconsole from.
#[derive(Debug, PartialEq)]
enum ConptySource {
/// kernel32's pseudoconsole.
System,
/// Exactly this `conpty.dll`, from `ZELLIJ_CONPTY_DLL`.
Explicit(PathBuf),
/// Th... |
rust_dataset_chunk_512854 | rust_dataset.txt | 512,854 | 512 | pointers are plain fn pointers and thread-safe.
unsafe impl Sync for ConptyApi {}
unsafe impl Send for ConptyApi {}
impl ConptyApi {
fn load() -> Self {
let source = conpty_source(
std::env::var_os(CONPTY_DLL_ENV_VAR),
std::env::current_exe()
.ok()
.... |
rust_dataset_chunk_512855 | rust_dataset.txt | 512,855 | 512 | std::result::Result<Self, String> {
if let Some(problem) = conpty_dll_problem(dll) {
return Err(problem);
}
let wide_path: Vec<u16> = dll.as_os_str().encode_wide().chain(Some(0)).collect();
unsafe {
// Resolve conpty.dll's own dependencies from its folder and the... |
rust_dataset_chunk_512856 | rust_dataset.txt | 512,856 | 512 | and retry (with a sanity cap to avoid runaway allocation).
if (len as usize) < buf.len() {
buf.truncate(len as usize);
return Some(String::from_utf16_lossy(&buf));
}
if buf.len() >= 32_768 {
return None;
}
buf.resize(buf.len() * 2, 0);
}
}... |
rust_dataset_chunk_512857 | rust_dataset.txt | 512,857 | 512 | pipe.readable().await?;
let mut buf = vec![0u8; max];
match pipe.try_read(&mut buf) {
Ok(n) => return Ok(buf[..n].to_vec()),
Err(e) if e.kind() == io::ErrorKind::WouldBlock => continue,
Err(e) => return Err(e),
}
}
... |
rust_dataset_chunk_512858 | rust_dataset.txt | 512,858 | 512 | closing quote still terminates
// the argument rather than being escaped.
for _ in 0..(backslashes * 2) {
cmdline.push('\\');
}
cmdline.push('"');
}
/// Build a Windows command-line string from a `RunCommand`, following the
/// `CommandLineToArgvW` quoting convention.
fn build_command_line_str... |
rust_dataset_chunk_512859 | rust_dataset.txt | 512,859 | 512 | LAPPED` for IOCP and the client (write) end
/// is synchronous (required by ConPTY).
fn create_overlapped_output_pipe(terminal_id: u32) -> io::Result<(HANDLE, HANDLE)> {
let seq = PIPE_SEQ.fetch_add(1, Ordering::Relaxed);
let name = format!(
r"\\.\pipe\zellij-pty-{}-{}-{}",
std::process::id(),
... |
rust_dataset_chunk_512860 | rust_dataset.txt | 512,860 | 512 | _os_error(hr))
} else {
Ok(hpcon)
}
}
/// Spawn a child process attached to the given ConPTY.
///
/// Returns `(process_handle, thread_handle, child_pid)`.
fn spawn_child_process(
hpcon: HPCON,
cmd: &RunCommand,
terminal_id: u32,
pane_env: &PaneEnv,
) -> io::Result<(HANDLE, HANDLE, u32)... |
rust_dataset_chunk_512861 | rust_dataset.txt | 512,861 | 512 | without a console), and a shell reading a NUL stdin exits at once.
si.StartupInfo.dwFlags = STARTF_USESTDHANDLES;
si.lpAttributeList = attr_list;
// --- command line & environment ---
let mut cmd_line = build_command_line(cmd);
let env_block = build_environment_block(terminal_id, pane_env);
l... |
rust_dataset_chunk_512862 | rust_dataset.txt | 512,862 | 512 | Windows PTY backend using native ConPTY with IOCP-based async I/O.
#[derive(Clone)]
pub(crate) struct WindowsPtyBackend {
terminals: Arc<Mutex<BTreeMap<u32, Option<ConPtyTerminal>>>>,
next_terminal_id_counter: Arc<AtomicU32>,
}
impl WindowsPtyBackend {
pub fn new() -> Result<Self, io::Error> {
Ok(... |
rust_dataset_chunk_512863 | rust_dataset.txt | 512,863 | 512 | .
unsafe {
CloseHandle(input_read);
CloseHandle(output_write);
}
// 5. Spawn child process
let (process_handle, thread_handle, child_pid) =
match spawn_child_process(hpcon, &cmd, terminal_id, pane_env) {
Ok(r) => r,
Err... |
rust_dataset_chunk_512864 | rust_dataset.txt | 512,864 | 512 | ) = resolve_command(&cmd, pane_env) {
cmd.command = resolved;
return self.do_spawn(cmd, quit_cb, terminal_id, pane_env);
}
if let Some(mut failover) = failover_cmd {
if let Some(resolved) = resolve_command(&failover, pane_env) {
failover.command = reso... |
rust_dataset_chunk_512865 | rust_dataset.txt | 512,865 | 512 | written: u32 = 0;
let ok = unsafe {
WriteFile(
term.input_write_handle,
buf.as_ptr(),
buf.len() as u32,
&mut written,
std::ptr::null_mut(),
)
... |
rust_dataset_chunk_512866 | rust_dataset.txt | 512,866 | 512 | , terminal_id: u32) {
self.terminals.lock().unwrap().remove(&terminal_id);
}
pub fn next_terminal_id(&self) -> Option<u32> {
Some(
self.next_terminal_id_counter
.fetch_add(1, Ordering::Relaxed),
)
}
}
#[cfg(test)]
mod tests {
use super::*;
use st... |
rust_dataset_chunk_512867 | rust_dataset.txt | 512,867 | 512 |
// back to a\"b.
let s = build_command_line_string(&cmd("prog", &["a\\\"b c"]));
assert_eq!(s, "\"prog\" \"a\\\\\\\"b c\"");
}
#[test]
fn trailing_backslash_before_closing_quote_gets_doubled() {
// "path with space\" would let the trailing backslash escape the
// cl... |
rust_dataset_chunk_512868 | rust_dataset.txt | 512,868 | 512 | PathBuf::from(r"C:\zellij"),
PathBuf::from(r"C:\Program Files\WezTerm"),
PathBuf::from(r"C:\Windows"),
])
);
}
#[test]
fn missing_conpty_dll_is_rejected() {
let dir = tempfile::tempdir().unwrap();
assert!(conpty_dll_problem(&dir.path().jo... |
rust_dataset_chunk_512869 | rust_dataset.txt | 512,869 | 512 | _utils::errors::prelude::*;
use zellij_utils::pane_size::SizeInPixels;
use zellij_utils::pane_size::{PaneGeom, Size};
use zellij_utils::structured_render::{
CursorState, FrameBuilder, GeometryRecord, GraphicsMedium, GraphicsRecord, LinkEntry,
LinkRecord, PaneRect, PendingOverlay, ScrollRecord, ShiftEntry, Shift... |
rust_dataset_chunk_512870 | rust_dataset.txt | 512,870 | 512 | pub underline: bool,
pub layer: HighlightLayer,
}
fn adjust_styles_for_possible_selection(
chunk_selection_and_colors: &[HighlightSelection],
character_styles: CharacterStyles,
chunk_y: usize,
chunk_width: usize,
) -> CharacterStyles {
chunk_selection_and_colors
.iter()
.fin... |
rust_dataset_chunk_512871 | rust_dataset.txt | 512,871 | 512 | _h| l_h.output_osc8(new_styles.link_anchor))
{
write!(vte_output, "{}{}", new_styles, osc8_link).context(err_context)?;
} else {
write!(vte_output, "{}", new_styles).context(err_context)?;
}
} else {
write!(vte_output, "{}", new_sty... |
rust_dataset_chunk_512872 | rust_dataset.txt | 512,872 | 512 | pane_default_fg,
pane_default_bg,
);
write_changed_styles(
&mut character_styles,
current_character_styles,
chunk_changed_colors,
link_handler.as_ref(),
osc8_hyperlinks,
... |
rust_dataset_chunk_512873 | rust_dataset.txt | 512,873 | 512 | ImageKey>),
local_media: bool,
host_state: &mut HostKittyState,
) -> GraphicsRecord {
let shared = local_media
.then(|| write_shared_media(rgba, host_state))
.flatten();
match shared {
Some(path) => {
host_state.track_media_for_image(image_key, path.clone());
... |
rust_dataset_chunk_512874 | rust_dataset.txt | 512,874 | 512 | Record::DeleteImage { id: host_id as u64 });
host_state.transmitted.remove(&image_key);
host_state.release_media_for_image(&image_key);
host_state
.live_placements
.retain(|_, record| record.image_key != image_key);
}
if let Some(visible_panes) = visible_panes {
... |
rust_dataset_chunk_512875 | rust_dataset.txt | 512,875 | 512 | == pane_id && !current.contains_key(key))
.map(|(key, record)| (key.clone(), record.host_image_id, record.host_placement_id))
.collect();
stale.sort_by_key(|(key, _, _)| (key.placement_uid, key.sub_index));
for (key, host_image_id, host_placement_id) in stale {
out.p... |
rust_dataset_chunk_512876 | rust_dataset.txt | 512,876 | 512 | host_placement_id, _, _)) => host_placement_id,
None => {
let host_placement_id = host_state.next_host_placement_id;
host_state.next_host_placement_id += 1;
host_placement_id
},
};
out.push(GraphicsRecord... |
rust_dataset_chunk_512877 | rust_dataset.txt | 512,877 | 512 | : Option<AnsiCode>,
changed_colors: Option<&[Option<AnsiCode>; 256]>,
) -> Option<AnsiCode> {
match (code, changed_colors) {
(Some(AnsiCode::ColorIndex(index)), Some(changed_colors)) => {
changed_colors[index as usize].or(code)
},
_ => code,
}
}
fn wire_attrs(styles: &Ch... |
rust_dataset_chunk_512878 | rust_dataset.txt | 512,878 | 512 | ()
},
attrs: wire_attrs(&styles, styled_underlines),
width: t_character.width().min(u8::MAX as usize) as u8,
link: LINK_NONE,
}
}
pub struct LinkFlatten<'a> {
pub handler: &'a LinkHandler,
pub table: &'a mut LinkTable,
}
fn row_shifts_for(
character_chunks: &[CharacterC... |
rust_dataset_chunk_512879 | rust_dataset.txt | 512,879 | 512 | .shift(entry);
}
}
builder.push_shifts(&shifts);
}
let mut run: Vec<WireCell> = Vec::new();
for character_chunk in character_chunks {
if character_chunk.y >= rows || character_chunk.x >= cols {
continue;
}
if let Some(shift) = character_chunk.r... |
rust_dataset_chunk_512880 | rust_dataset.txt | 512,880 | 512 | _at(t_character, chunk_width),
chunk_changed_colors,
styled_underlines,
);
if !styles_vary_by_column {
last_styled = Some((t_character.styles.clone(), cell));
}
... |
rust_dataset_chunk_512881 | rust_dataset.txt | 512,881 | 512 | as u32,
}
}
if offset > 0 {
cell.attrs |= ATTR_GROUP_CONTINUE;
}
if let Some(links) = links.as_deref_mut() {
if let Some(uri) = links.handler.uri(member.styles.link_anchor) {
... |
rust_dataset_chunk_512882 | rust_dataset.txt | 512,882 | 512 | : sixel_chunk.sixel_image_pixel_width as u32,
pixel_height: sixel_chunk.sixel_image_pixel_height as u32,
payload: serialized_sixel_image.into_bytes(),
});
}
}
}
}
builder.extend_graphics(records.iter());
... |
rust_dataset_chunk_512883 | rust_dataset.txt | 512,883 | 512 | vte_output.push_str("\u{1b}[");
push_decimal(vte_output, unit_columns);
vte_output.push('X');
vte_output.push_str(&prepared.text);
vte_output.push_str("\u{1b}[");
push_decimal(vte_output, column + unit_columns + 1);
vte_output.push('G');
Ok(())
} else ... |
rust_dataset_chunk_512884 | rust_dataset.txt | 512,884 | 512 | mut erase_width = character_chunk.width();
if let Some(size) = max_size {
erase_width = erase_width.min(size.cols.saturating_sub(character_chunk.x));
}
if erase_width > 0 {
write!(vte_output, "\u{1b}[{}X", erase_width).with_context(err_context)?;
... |
rust_dataset_chunk_512885 | rust_dataset.txt | 512,885 | 512 | [previous])
== styles_at(&cells[next], column_starts[next])
});
let unit = &cells[index..unit_end];
let unit_columns: usize = unit.iter().map(|c| c.width()).sum();
if let Some(size) = max_size {
if chunk_width + unit_columns > size.cols... |
rust_dataset_chunk_512886 | rust_dataset.txt | 512,886 | 512 | above text unless the text was explicitly inserted after them (the
// latter being a case we handle in our own internal state and not in the output)
let save_cursor_position = "\u{1b}[s";
let restore_cursor_position = "\u{1b}[u";
vte_output.push_str(save_cursor_position);
vte_ou... |
rust_dataset_chunk_512887 | rust_dataset.txt | 512,887 | 512 | ) {
let _ = fs::remove_file(path);
}
}
fn track_media(&mut self, path: PathBuf) {
self.media_files.insert(path);
if self.media_files.len() > MAX_TRACKED_MEDIA_FILES {
self.media_files.retain(|path| path.exists());
}
}
fn track_media_for_image(
... |
rust_dataset_chunk_512888 | rust_dataset.txt | 512,888 | 512 | ;
for (part_index, part) in parts.iter().enumerate() {
if part_index == 0 {
write!(
out,
"\u{1b}_Ga=t,q=2,f=32,{}t=d,i={},s={},v={},m={};{}\u{1b}\\",
compression,
host_image_id,
width,
height,
... |
rust_dataset_chunk_512889 | rust_dataset.txt | 512,889 | 512 | width,
height,
rgba.len(),
BASE64_ENCODER.encode(name.as_bytes()),
)
.context("failed to serialize kitty local media transmit")?;
Ok(true)
}
fn serialize_kitty_frame(kitty_input: KittyFrameInput) -> Result<String> {
let err_context = "failed to serialize kitty frame";
... |
rust_dataset_chunk_512890 | rust_dataset.txt | 512,890 | 512 | )| {
(pane_sort_key(key.pane_id), key.placement_uid, key.sub_index)
});
for (key, host_image_id, host_placement_id) in to_delete {
write!(
out,
"\u{1b}_Ga=d,q=2,d=i,i={},p={}\u{1b}\\",
host_image_id, host_placement_id
)
... |
rust_dataset_chunk_512891 | rust_dataset.txt | 512,891 | 512 | .scaled_image;
let image_key = (chunk.internal_image_id, variant);
let host_image_id = match host_state.transmitted.get(&image_key) {
Some(host_image_id) => *host_image_id,
None => {
let raster_dims = match variant {
Som... |
rust_dataset_chunk_512892 | rust_dataset.txt | 512,892 | 512 | => {
let host_placement_id = host_state.next_host_placement_id;
host_state.next_host_placement_id += 1;
host_placement_id
},
};
vte_goto_instruction(chunk.cell_x, chunk.cell_y, &mut out).context(err_context)?;
... |
rust_dataset_chunk_512893 | rust_dataset.txt | 512,893 | 512 | (Debug, Clone, Copy, PartialEq, Eq)]
pub struct TrackedScroll {
pub offset: usize,
pub epoch: u64,
pub content_cols: u16,
pub content_rows: u16,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PaneScroll {
pub pane_id: PaneId,
pub state: Option<(usize, u64)>,
}
impl PaneScroll {
... |
rust_dataset_chunk_512894 | rust_dataset.txt | 512,894 | 512 | ();
let record = scroll_hints(&mut state.scroll_offsets, panes, suppressed);
builder.push_scroll(&record);
}
#[derive(Debug, Default)]
pub struct LinkTable {
ids: HashMap<String, u8>,
uris: HashMap<u8, String>,
shadow: Vec<u8>,
cols: usize,
fresh: Vec<LinkEntry>,
}
impl LinkTable {
pub... |
rust_dataset_chunk_512895 | rust_dataset.txt | 512,895 | 512 | .cols as usize,
entry.rows as usize,
entry.lines as usize,
);
if x + width > self.cols || y + height > rows || lines == 0 {
return;
}
for row in y..y + height {
let target = row * self.cols + x;
if row + lines < y + height {
... |
rust_dataset_chunk_512896 | rust_dataset.txt | 512,896 | 512 | self.in_flight = None;
self.in_flight_since = None;
}
pub fn delivery_deadline_expired(&self) -> bool {
match (self.in_flight, self.in_flight_since) {
(Some(_), Some(since)) => since.elapsed() >= STRUCTURED_RENDER_DEADLINE,
(Some(_), None) => true,
(N... |
rust_dataset_chunk_512897 | rust_dataset.txt | 512,897 | 512 | _state(
x: usize,
y: usize,
visible: bool,
shape_csi: &str,
) -> CursorState {
CursorState {
x: x.min(u16::MAX as usize) as u16,
y: y.min(u16::MAX as usize) as u16,
shape: wire_cursor_shape(shape_csi),
visible,
}
}
pub(crate) fn mirror_screen_from_chunks(
cha... |
rust_dataset_chunk_512898 | rust_dataset.txt | 512,898 | 512 | .get_mut(&client_id) else {
return false;
};
if state.last_geometry.as_ref() == Some(&geometry) {
return false;
}
builder.push_geometry(&geometry);
state.last_geometry = Some(geometry);
true
}
fn is_subsumed_by_frame_semantics(instruction: &str) -> bool {
if matches!(
... |
rust_dataset_chunk_512899 | rust_dataset.txt | 512,899 | 512 | _kitty_chunks: HashMap<ClientId, HashMap<PaneId, Vec<KittyImageChunk>>>,
client_rendered_kitty_panes: HashMap<ClientId, HashSet<PaneId>>,
client_kitty_visible_panes: HashMap<ClientId, HashSet<PaneId>>,
clients_with_cleared_host_display: HashSet<ClientId>,
link_handler: Option<Rc<RefCell<LinkHandler>>>,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.