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_511700 | rust_dataset.txt | 511,700 | 512 | ed() {
let (frame, payload) = announce_frame_and_payload();
let mut chunk = frame.clone();
chunk.extend_from_slice(&frame);
let mut p = StdinAnsiParser::new();
let out = p.feed(&chunk);
assert_eq!(out.nested_frames, vec![payload.clone(), payload]);
assert!(out.residue.is_empty());
}
#[test]... |
rust_dataset_chunk_511701 | rust_dataset.txt | 511,701 | 512 | iving_before_the_keypress_wins() {
let mut parser = StdinAnsiParser::new();
parser.open_clipboard_forward(2);
let mut input = Vec::new();
input.extend_from_slice(b"\x1b]52;c;d29ybGQ=\x1b\\");
input.extend_from_slice(b"x");
let out = parser.feed(&input);
assert_eq!(
out.completed_clip... |
rust_dataset_chunk_511702 | rust_dataset.txt | 511,702 | 512 | !(parser.take_active_clipboard_forward(), None);
}
#[test]
fn clipboard_timeout_only_fires_for_the_open_token() {
let mut parser = StdinAnsiParser::new();
parser.open_clipboard_forward(3);
assert_eq!(parser.close_clipboard_forward_on_timeout(4), None);
assert_eq!(
parser.close_clipboard_forward... |
rust_dataset_chunk_511703 | rust_dataset.txt | 511,703 | 512 | (&first.replies).is_empty());
let second = parser.feed(b"27;1$y\x1b[?62;22c");
assert!(second.residue.is_empty());
assert_eq!(grapheme_cluster_replies(&second.replies), vec![1]);
}
#[test]
fn grapheme_cluster_mode_without_reply_before_the_barrier_settles_as_unsupported() {
let mut parser = startup_pars... |
rust_dataset_chunk_511704 | rust_dataset.txt | 511,704 | 512 | zellij"
);
assert_eq!(out.completed_forward, Some((9, b"\x1b[?2027;1$y".to_vec())));
}
#[test]
fn grapheme_cluster_mode_replies_are_split_between_zellij_and_a_forwarding_pane() {
let mut parser = startup_parser();
parser.open_forward(4);
let own = parser.feed(b"\x1b[?2027;2$y\x1b[?62;22c");
as... |
rust_dataset_chunk_511705 | rust_dataset.txt | 511,705 | 512 | 0);
use zellij_utils::{
channels::SenderWithContext,
vendored::termwiz::input::{InputEvent, InputParser},
};
pub(crate) fn stdin_loop(
mut os_input: Box<dyn ClientOsApi>,
send_input_instructions: SenderWithContext<InputInstruction>,
stdin_ansi_parser: Arc<Mutex<StdinAnsiParser>>,
explicitly_dis... |
rust_dataset_chunk_511706 | rust_dataset.txt | 511,706 | 512 | ::AnsiStdinInstructions(vec![
HostReply::KittyGraphicsSupport(false),
HostReply::KittyZlibSupport(false),
]));
}
} else {
let _ = send_input_instructions.send(InputInstruction::AnsiStdinInstructions(vec![
... |
rust_dataset_chunk_511707 | rust_dataset.txt | 511,707 | 512 | map_err(|_| mpsc::RecvTimeoutError::Disconnected)
} {
Ok(result) => {
match result {
Ok(buf) => {
// Strip + classify any host-reply sequences
// continuously. The residue is the byte stream
/... |
rust_dataset_chunk_511708 | rust_dataset.txt | 511,708 | 512 | keeps its state so the next chunk's
// continuation completes the sequence.
match kitty_parser.feed(&residue) {
KittyParseOutcome::Complete(key_with_modifier) => {
if send_input_instructions
... |
rust_dataset_chunk_511709 | rust_dataset.txt | 511,709 | 512 | break;
} else if e == "Session ended" {
log::debug!("Switched sessions, signing this thread off...");
} else {
log::error!("Failed to read from STDIN: {}", e);
}
... |
rust_dataset_chunk_511710 | rust_dataset.txt | 511,710 | 512 | _to_keyboard(
input_parser: &mut InputParser,
current_buffer: &mut Vec<u8>,
send_input_instructions: SenderWithContext<InputInstruction>,
drained: Vec<u8>,
) {
if !drained.is_empty() {
current_buffer.extend_from_slice(&drained);
}
let mut events: Vec<(InputEvent, usize)> = vec![];
... |
rust_dataset_chunk_511711 | rust_dataset.txt | 511,711 | 512 | current_buffer.len().saturating_sub(buffered);
if excess > 0 {
current_buffer.drain(..excess);
}
}
/// Build the fire-and-forget host-query batch sent at client startup.
/// The host's replies refine `Screen`'s cached state asynchronously as
/// they arrive; the UI does not block on them.
fn build_sta... |
rust_dataset_chunk_511712 | rust_dataset.txt | 511,712 | 512 | use super::{
build_startup_query_string, extract_focus_reports, realign_current_buffer, InputParser,
PIXEL_SIZE_QUERY,
};
#[test]
fn realign_after_lone_paste_start_empties_the_buffer() {
let mut parser = InputParser::new();
parser.parse_with_consumed(b"\x1b[200~", |_, _| {}... |
rust_dataset_chunk_511713 | rust_dataset.txt | 511,713 | 512 | _palette_register_loop() {
let query = build_startup_query_string(true, false);
assert_eq!(
query,
"\u{1b}[14t\u{1b}[16t\u{1b}]11;?\u{1b}\u{5c}\u{1b}]10;?\u{1b}\u{5c}\u{1b}[?2026$p\u{1b}_Ga=q,i=31,s=1,v=1,t=d,f=24;AAAA\u{1b}\u{5c}\u{1b}_Ga=q,i=32,s=4,v=4,t=d,f=24,o=z;eJxjYCANAAAA... |
rust_dataset_chunk_511714 | rust_dataset.txt | 511,714 | 512 | ,s=1,v=1,t=d,f=24;AAAA\u{1b}\u{5c}"));
let probe_pos = query.find("\u{1b}_Ga=q,i=31,").unwrap();
let barrier_pos = query.find("\u{1b}[c").unwrap();
assert!(probe_pos < barrier_pos);
}
#[test]
fn startup_query_contains_zlib_probe_between_kitty_probe_and_barrier() {
let query ... |
rust_dataset_chunk_511715 | rust_dataset.txt | 511,715 | 512 | ENABLE_WINDOW_INPUT, STD_INPUT_HANDLE,
};
use crate::InputInstruction;
use zellij_utils::channels::SenderWithContext;
use zellij_utils::input::{cast_crossterm_key, from_crossterm_mouse};
use zellij_utils::vendored::termwiz::input::InputEvent;
/// Saved console input mode from before `enable_vt_input()` modified it.
... |
rust_dataset_chunk_511716 | rust_dataset.txt | 511,716 | 512 | clear:
// ENABLE_PROCESSED_INPUT (0x0001) - let VT sequences through raw
// ENABLE_LINE_INPUT (0x0002) - no line buffering
// ENABLE_ECHO_INPUT (0x0004) - no echo
// ENABLE_QUICK_EDIT_MODE (0x0040) - would intercept mouse events
let new_mode = ENABLE_WINDOW... |
rust_dataset_chunk_511717 | rust_dataset.txt | 511,717 | 512 | },
Ok(Event::Mouse(mouse_event)) => {
let mouse_event = from_crossterm_mouse(mouse_event);
if send_input_instructions
.send(InputInstruction::MouseEvent(mouse_event))
.is_err()
{
break;
... |
rust_dataset_chunk_511718 | rust_dataset.txt | 511,718 | 512 | (replies.into_iter().collect())),
..Default::default()
}
}
fn sent_payloads(&self) -> Vec<Option<String>> {
self.sent_payloads.lock().unwrap().clone()
}
fn stdout(&self) -> String {
String::from_utf8_lossy(&self.stdout.lock().unwrap()).into_owned()
}
}
struct Sha... |
rust_dataset_chunk_511719 | rust_dataset.txt | 511,719 | 512 | ::Duration::from_secs(2);
loop {
if let Some(msg) = self.inbox.lock().unwrap().pop_front() {
return Some((msg, ErrorContext::default()));
}
if std::time::Instant::now() > deadline {
return None;
}
std::thread::sleep(std:... |
rust_dataset_chunk_511720 | rust_dataset.txt | 511,720 | 512 | b\n"),
vec![
vec![release(None)],
vec![release(None)],
vec![output("answer\n"), release(None)],
],
);
assert_eq!(run(&os_api, pipe_action(None)), 0);
assert_eq!(
os_api.sent_payloads(),
vec![Some("a\n".to_owned()), Some("b\n".to_owned()), N... |
rust_dataset_chunk_511721 | rust_dataset.txt | 511,721 | 512 | push?",
"--yes",
"Push",
"--no",
"Cancel",
"--timeout",
"5s",
"--json",
]),
no_stdin,
false,
)
.unwrap();
assert_eq!(plan.element, PromptElement::Confirm);
assert_eq!(plan.args.get("message").unw... |
rust_dataset_chunk_511722 | rust_dataset.txt | 511,722 | 512 | _cli(&[
"number",
"Port",
"--min",
"1",
"--max",
"10",
"--default",
"42",
]),
no_stdin,
false,
)
.unwrap_err();
assert_eq!(error, "--default: 42 is not between 1 and 10");
assert!(plan... |
rust_dataset_chunk_511723 | rust_dataset.txt | 511,723 | 512 | let error = plan_prompt(&prompt_cli(&["toggle"]), no_stdin, false).unwrap_err();
let message = prompt_error_message(&error, "toggle", false);
assert!(
message.starts_with("error: toggle: the label is missing\n\n"),
"{}",
message
);
assert!(
message.contains("Usage: zelli... |
rust_dataset_chunk_511724 | rust_dataset.txt | 511,724 | 512 | (|e| (e.kind(), e.render().to_string()))
})
.unwrap()
.join()
.unwrap();
let (kind, rendered) = result.unwrap_err();
assert_eq!(
kind,
clap::error::ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand
);
assert!(
rendered.contains("confirm") && rend... |
rust_dataset_chunk_511725 | rust_dataset.txt | 511,725 | 512 | Placement::TopRight);
assert!(!notify.takes_focus());
assert_eq!(
prompt_cli(&["notify", "x", "--at", "bottom-left"]).placement(),
PipePopupPlacement::BottomLeft
);
assert!(prompt_cli(&["toggle", "x"]).takes_focus());
assert!(<PromptCli as clap::Parser>::try_parse_from([
"pro... |
rust_dataset_chunk_511726 | rust_dataset.txt | 511,726 | 512 | ,
)
.unwrap();
assert_eq!(plan.element, zellij_utils::prompt::PromptElement::Notify);
assert_eq!(
plan.args
.get(zellij_utils::prompt::ARG_MESSAGE)
.map(|m| m.as_str()),
Some("Build finished")
);
assert!(!plan
.args
.contains_key(zellij_uti... |
rust_dataset_chunk_511727 | rust_dataset.txt | 511,727 | 512 | std::sync::{Arc, Mutex};
use zellij_utils::channels::{self, ChannelWithContext, SenderWithContext};
use zellij_utils::data::{InputMode, Palette};
use zellij_utils::errors::ErrorContext;
use zellij_utils::input::actions::Action;
use zellij_utils::input::config::Config;
use zellij_utils::input::mouse::MouseEvent;
use ze... |
rust_dataset_chunk_511728 | rust_dataset.txt | 511,728 | 512 | }
fn load_palette(&self) -> Palette {
Palette::default()
}
fn enable_mouse(&self) -> anyhow::Result<()> {
Ok(())
}
fn disable_mouse(&self) -> anyhow::Result<()> {
Ok(())
}
}
fn close_host_terminal(options: Options) -> (Vec<Action>, Vec<ClientInstruction>) {
let os_a... |
rust_dataset_chunk_511729 | rust_dataset.txt | 511,729 | 512 | Options {
on_force_close: Some(OnForceClose::Quit),
..Default::default()
};
let (actions, _) = close_host_terminal(options);
assert_eq!(
actions,
vec![Action::SkipConfirm {
action: Box::new(Action::Quit)
}]
);
}
fn mouse_event_from_host_terminal(byte... |
rust_dataset_chunk_511730 | rust_dataset.txt | 511,730 | 512 | message = ipc_pipe_length_error(&path_of_length(ZELLIJ_SOCK_MAX_LENGTH))
.expect("a path at the limit must be rejected");
assert!(
message.contains(&format!(
"({} {}",
ZELLIJ_SOCK_MAX_LENGTH, SOCKET_PATH_LENGTH_UNIT
)),
"the message must report the offending ... |
rust_dataset_chunk_511731 | rust_dataset.txt | 511,731 | 512 | _tests.rs ---
use crate::{
terminal_teardown_message, OuterGraphemeClusterMode, DISABLE_FOCUS_REPORTING,
ENABLE_FOCUS_REPORTING,
};
#[test]
fn the_teardown_message_cancels_focus_reporting() {
let message = terminal_teardown_message("bye", 20, false, false);
assert!(
message.contains(DISABLE_FOC... |
rust_dataset_chunk_511732 | rust_dataset.txt | 511,732 | 512 | 2027 off on exit, got: {:?}",
replies,
teardown
);
let mode_off = teardown.find("\u{1b}[?2027l").unwrap();
let exit_alternate_screen = teardown.find("\u{1b}[?1049l").unwrap();
assert!(mode_off < exit_alternate_screen);
}
}
#[test]
fn a_permanent_or_unsupporte... |
rust_dataset_chunk_511733 | rust_dataset.txt | 511,733 | 512 | SinkExt, StreamExt};
use serial_test::serial;
use std::io::{self, Write};
use std::sync::{Arc, Mutex};
use std::time::Duration;
use tokio::net::TcpStream;
use tokio::sync::mpsc;
use tokio_tungstenite::tungstenite::Message;
use zellij_utils::data::Palette;
use zellij_utils::errors::ErrorContext;
use zellij_utils::ipc::{... |
rust_dataset_chunk_511734 | rust_dataset.txt | 511,734 | 512 | .debug_struct("TestClientOsApi").finish()
}
}
impl ClientOsApi for TestClientOsApi {
fn get_terminal_size(&self) -> Size {
self.terminal_size
}
fn set_raw_mode(&mut self) {}
fn unset_raw_mode(&self) -> Result<(), std::io::Error> {
Ok(())
}
fn get_stdout_writer(&self) -> B... |
rust_dataset_chunk_511735 | rust_dataset.txt | 511,735 | 512 | self.buffer.lock().unwrap().extend_from_slice(buf);
Ok(buf.len())
}
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}
mod mock_ws_server {
use super::*;
use axum::{
extract::{
ws::{WebSocket, WebSocketUpgrade},
State,
},
rout... |
rust_dataset_chunk_511736 | rust_dataset.txt | 511,736 | 512 | _handle = tokio::spawn(async move {
axum::serve(listener, app).await.unwrap();
});
tokio::time::sleep(Duration::from_millis(100)).await;
let server = MockWsServer {
terminal_to_client_tx,
control_to_client_tx,
client_t... |
rust_dataset_chunk_511737 | rust_dataset.txt | 511,737 | 512 | ite_msg);
}
});
loop {
let msg = state.server_rx.lock().unwrap().try_recv();
match msg {
Ok(tungstenite_msg) => {
let axum_msg = match tungstenite_msg {
Message::Text(text) => {
a... |
rust_dataset_chunk_511738 | rust_dataset.txt | 511,738 | 512 | let (control_ws, _) = tokio_tungstenite::client_async_with_config(
&control_url,
MaybeTls::Plain(control_tcp),
None,
)
.await
.unwrap();
let connections = WebSocketConnections {
terminal_ws,
control_ws,
web_client_id: "test-stdin".to_string(),
};
... |
rust_dataset_chunk_511739 | rust_dataset.txt | 511,739 | 512 | )
.await
.unwrap();
let control_tcp = TcpStream::connect(format!("127.0.0.1:{}", port))
.await
.unwrap();
let (control_ws, _) = tokio_tungstenite::client_async_with_config(
&control_url,
MaybeTls::Plain(control_tcp),
None,
)
.await
.unwrap();
let... |
rust_dataset_chunk_511740 | rust_dataset.txt | 511,740 | 512 | Stream::connect(format!("127.0.0.1:{}", port))
.await
.unwrap();
let (terminal_ws, _) = tokio_tungstenite::client_async_with_config(
&terminal_url,
MaybeTls::Plain(terminal_tcp),
None,
)
.await
.unwrap();
let control_tcp = TcpStream::connect(format!("127.0.0.1... |
rust_dataset_chunk_511741 | rust_dataset.txt | 511,741 | 512 | : {:?}", received),
}
signal_tx.send(SignalEvent::Quit).unwrap();
let _ = tokio::time::timeout(Duration::from_secs(2), loop_handle)
.await
.expect("Loop didn't exit")
.unwrap();
}
#[tokio::test]
#[serial]
async fn test_quit_signal_exits_loop() {
let (port, _server, _server_hand... |
rust_dataset_chunk_511742 | rust_dataset.txt | 511,742 | 512 | tokio::test]
#[serial]
async fn test_websocket_close_exits_loop() {
let (port, server, _server_handle) = mock_ws_server::MockWsServer::start().await;
let terminal_url = format!("ws://127.0.0.1:{}/ws/terminal", port);
let control_url = format!("ws://127.0.0.1:{}/ws/control", port);
let terminal_tcp = T... |
rust_dataset_chunk_511743 | rust_dataset.txt | 511,743 | 512 | ://127.0.0.1:{}/ws/terminal", port);
let control_url = format!("ws://127.0.0.1:{}/ws/control", port);
let terminal_tcp = TcpStream::connect(format!("127.0.0.1:{}", port))
.await
.unwrap();
let (terminal_ws, _) = tokio_tungstenite::client_async_with_config(
&terminal_url,
May... |
rust_dataset_chunk_511744 | rust_dataset.txt | 511,744 | 512 | .expect("Timeout")
.expect("No message");
match received {
Message::Text(text) => {
let parsed: WebClientToWebServerControlMessage =
serde_json::from_str(&text).expect("Failed to parse");
let size = match parsed.payload {
WebClientToWebServerC... |
rust_dataset_chunk_511745 | rust_dataset.txt | 511,745 | 512 | serial]
async fn test_nested_ping_frame_is_answered_locally_and_stripped_from_forwarded_stdin() {
let (port, server, _server_handle) = mock_ws_server::MockWsServer::start().await;
let connections = connect_mock_ws(port).await;
let (stdin_tx, stdin_rx) = mpsc::unbounded_channel();
let (_signal_tx, signa... |
rust_dataset_chunk_511746 | rust_dataset.txt | 511,746 | 512 | _websocket() {
let (port, server, _server_handle) = mock_ws_server::MockWsServer::start().await;
let connections = connect_mock_ws(port).await;
let (stdin_tx, stdin_rx) = mpsc::unbounded_channel();
let (_signal_tx, signal_rx) = mpsc::unbounded_channel();
let os_input = Box::new(TestClientOsApi::new... |
rust_dataset_chunk_511747 | rust_dataset.txt | 511,747 | 512 | ::{extract::Request, http::StatusCode, middleware::Next, response::Response};
use axum_extra::extract::cookie::{Cookie, SameSite};
use zellij_utils::web_authentication_tokens::{
hash_token, is_session_token_read_only, validate_session_token,
};
#[derive(Clone)]
pub struct SessionTokenHash(pub String);
#[derive(Cl... |
rust_dataset_chunk_511748 | rust_dataset.txt | 511,748 | 512 | --- FILE: zellij/zellij-client/src/web_client/connection_manager.rs ---
use crate::os_input_output::ClientOsApi;
use crate::web_client::control_message::WebServerToWebClientControlMessage;
use crate::web_client::types::{ClientChannels, ClientConnectionBus, ConnectionTable};
use axum::extract::ws::{CloseFrame, Message};... |
rust_dataset_chunk_511749 | rust_dataset.txt | 511,749 | 512 | .map(|c| c.queue_control_message(message));
}
pub fn add_client_terminal_tx(
&mut self,
client_id: &str,
terminal_channel_tx: UnboundedSender<Message>,
) {
self.client_id_to_channels
.get_mut(client_id)
.map(|c| c.add_terminal_tx(terminal_channel_tx)... |
rust_dataset_chunk_511750 | rust_dataset.txt | 511,750 | 512 | _channel_tx.as_ref() {
Some(stdout_channel_tx) => {
let _ = stdout_channel_tx.send(message);
},
None => {
self.get_stdout_channel_tx();
if let Some(stdout_channel_tx) = self.stdout_channel_tx.as_ref() {
let _ = stdou... |
rust_dataset_chunk_511751 | rust_dataset.txt | 511,751 | 512 | (flag) = self
.connection_table
.lock()
.unwrap()
.get_should_not_reconnect_flag(&self.web_client_id)
{
flag.store(true, std::sync::atomic::Ordering::Relaxed);
}
self.close_connection();
}
fn get_control_channel_tx(&mut self) {... |
rust_dataset_chunk_511752 | rust_dataset.txt | 511,752 | 512 | ToClientMsg, ErrorContext)> {
None
}
fn handle_signals(
&self,
_sigwinch_cb: Box<dyn Fn()>,
_quit_cb: Box<dyn Fn()>,
_resize_receiver: Option<std::sync::mpsc::Receiver<()>>,
) {
}
fn connect_to_server(&self, _path: &Path... |
rust_dataset_chunk_511753 | rust_dataset.txt | 511,753 | 512 | }
#[test]
fn control_messages_are_delivered_directly_once_registered() {
let connection_table = connection_table_with_client("client");
let (control_channel_tx, mut control_channel_rx) = tokio::sync::mpsc::unbounded_channel();
connection_table
.lock()
.unwrap... |
rust_dataset_chunk_511754 | rust_dataset.txt | 511,754 | 512 | pane_id: u32,
is_plugin: bool,
},
NewPaneInTab {
tab_id: usize,
},
NewTab,
SetMobileRenderPreferences {
single_pane: bool,
fit: bool,
},
RenderFrameAck {
seq: u64,
},
ForwardedReplyFromHost {
token: u32,
reply_bytes: Vec<u8>,
... |
rust_dataset_chunk_511755 | rust_dataset.txt | 511,755 | 512 | pub font: String,
pub theme: SetConfigPayloadTheme,
pub cursor_blink: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor_inactive_style: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor_style: Option<String>,
pub mac_option_is_meta: bool,
#[se... |
rust_dataset_chunk_511756 | rust_dataset.txt | 511,756 | 512 | is_none")]
pub red: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub selection_background: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub selection_foreground: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub selection_inactive... |
rust_dataset_chunk_511757 | rust_dataset.txt | 511,757 | 512 | .cursor.clone());
theme.cursor_accent =
web_client_theme_from_config.and_then(|theme| theme.cursor_accent.clone());
theme.cyan = web_client_theme_from_config.and_then(|theme| theme.cyan.clone());
theme.green = web_client_theme_from_config.and_then(|theme| theme.green.clone());
... |
rust_dataset_chunk_511758 | rust_dataset.txt | 511,758 | 512 | :
//!
//! 1. The same `Config` that drives `SetConfigPayload`, which the
//! browser ultimately renders with. fg/bg are guaranteed to match
//! what xterm.js paints.
//! 2. The canonical xterm-256 palette formula for indices 16-255 (not
//! overridable in xterm.js's configurable theme, so the formula is
//! ... |
rust_dataset_chunk_511759 | rust_dataset.txt | 511,759 | 512 | = ResolvedTheme::default();
let palette = config.theme_config(config_options.theme.as_ref());
let web_client_theme = config.web_client.theme.as_ref();
out.foreground = web_client_theme
.and_then(|t| t.foreground.clone())
.or_else(|| palette.map(|p| p.text_unselected.base.as_rgb_str()));
... |
rust_dataset_chunk_511760 | rust_dataset.txt | 511,760 | 512 | ellij's config does
// not expose them, so the formula is the source of truth.
for index in 16u8..=255 {
let (r, g, b) = xterm_256_rgb(index);
registers.push(ColorRegister {
index: index as usize,
color: rgb_to_xparse_color(r, g, b),
});
}
registers
}
//... |
rust_dataset_chunk_511761 | rust_dataset.txt | 511,761 | 512 | => (0, 0, 0), // not used; caller restricts to 16..=255
16..=231 => {
let idx = (index - 16) as u32;
let level = |x: u32| if x == 0 { 0u8 } else { (55 + x * 40) as u8 };
(level(idx / 36), level((idx / 6) % 6), level(idx % 6))
},
232..=255 => {
let... |
rust_dataset_chunk_511762 | rust_dataset.txt | 511,762 | 512 | xterm_256_first_cube_entry_is_black() {
assert_eq!(xterm_256_rgb(16), (0, 0, 0));
}
#[test]
fn xterm_256_last_cube_entry_is_white() {
// 5,5,5 — corners at maximal level
assert_eq!(xterm_256_rgb(231), (255, 255, 255));
}
#[test]
fn xterm_256_greyscale_endpoints() {
... |
rust_dataset_chunk_511763 | rust_dataset.txt | 511,763 | 512 | }
#[test]
fn invalid_css_rgb_yields_no_conversion() {
// PaletteColor::from_rgb_str returns the default variant for
// strings it cannot parse; the bridge must reject those rather
// than emit a garbage xparse string.
assert!(css_rgb_to_xparse_color("#ff8800").is_none());
... |
rust_dataset_chunk_511764 | rust_dataset.txt | 511,764 | 512 | omits_unset_low_indices() {
// Indices 0-15 without explicit overrides should be absent from
// the ColorRegisters payload — apps will fall back to their own
// defaults rather than reading a wrong value we made up.
let mut theme = WebClientTheme::default();
theme.red = Some("rgb... |
rust_dataset_chunk_511765 | rust_dataset.txt | 511,765 | 512 | // override in 0..=15.
let mut theme = WebClientTheme::default();
theme.red = Some("rgb(255, 0, 0)".to_string());
theme.green = Some("rgb(0, 255, 0)".to_string());
theme.blue = Some("rgb(0, 0, 255)".to_string());
let config = config_with_web_theme(theme);
let opts... |
rust_dataset_chunk_511766 | rust_dataset.txt | 511,766 | 512 | Some("rgb(255, 255, 255)".to_string());
let config = config_with_web_theme(theme);
let opts = Options::default();
let msgs = build_host_query_seed_msgs(&config, &opts);
let registers = msgs
.iter()
.find_map(|m| match m {
ClientToServerMsg::Colo... |
rust_dataset_chunk_511767 | rust_dataset.txt | 511,767 | 512 | (false),
) {
Ok(session_token) => {
let is_https = state.is_https;
let cookie = if login_request.remember_me.unwrap_or(false) {
// Persistent cookie for remember_me
Cookie::build(("session_token", session_token))
.http_only(true)
... |
rust_dataset_chunk_511768 | rust_dataset.txt | 511,768 | 512 | _welcome_session(&state.pending_welcome_sessions, &generated);
}
generated
},
};
let web_client_id = String::from(Uuid::new_v4());
let os_input = state
.client_os_api_factory
.create_client_os_api()
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, Jso... |
rust_dataset_chunk_511769 | rust_dataset.txt | 511,769 | 512 | fn create_webserver_receiver(
id: &str,
) -> Result<interprocess::local_socket::tokio::Stream, Box<dyn std::error::Error + Send + Sync>> {
std::fs::create_dir_all(&WEBSERVER_SOCKET_PATH.as_path())?;
let socket_path = WEBSERVER_SOCKET_PATH.join(format!("{}", id));
if socket_path.exists() {
toki... |
rust_dataset_chunk_511770 | rust_dataset.txt | 511,770 | 512 | Ok(instruction) => match instruction {
InstructionForWebServer::ShutdownWebServer => {
server_handle.shutdown();
break;
},
InstructionForWebServer::QueryVersion => {
let response = WebSer... |
rust_dataset_chunk_511771 | rust_dataset.txt | 511,771 | 512 | (&self) -> bool {
self.pending_finalize
}
/// Clear the pending-finalize flag without draining events. Used
/// when the WebSocket loop hits an idle timeout but the client
/// connection has already been removed — there's nowhere to send
/// the drained events, and leaving the flag set woul... |
rust_dataset_chunk_511772 | rust_dataset.txt | 511,772 | 512 | ) => {
let mouse_event = from_termwiz(mouse_old_event, mouse_event);
let action = Action::MouseEvent { event: mouse_event };
os_input.send_to_server(ClientToServerMsg::Action {
action,
terminal_id: None,
client_id: None,
... |
rust_dataset_chunk_511773 | rust_dataset.txt | 511,773 | 512 | Frame {
code,
reason: "Connection closed".into(),
};
let close_message = Message::Close(Some(close_frame));
if client_channel_tx
.send(close_message)
.await
... |
rust_dataset_chunk_511774 | rust_dataset.txt | 511,774 | 512 | // For multi-event buffers (e.g. IME composition), avoid
// duplicating the full buffer for each unmodified Char event.
// Non-Char or modified keys still use the original buffer.
let raw_bytes = if single_event {
buf.to_vec()
} else {... |
rust_dataset_chunk_511775 | rust_dataset.txt | 511,775 | 512 | self) -> Box<dyn BufRead> {
Box::new(Cursor::new(Vec::<u8>::new()))
}
fn update_session_name(&mut self, _new_session_name: String) {}
fn read_from_stdin(&mut self) -> Result<Vec<u8>, &'static str> {
Ok(vec![])
}
fn box_clone(&self) -> Box<dyn ClientOsApi> ... |
rust_dataset_chunk_511776 | rust_dataset.txt | 511,776 | 512 | os_input = RecordingOsInput::default();
let mut mouse_old_event = MouseEvent::new();
let mut session = super::StdinSession::new(false);
parse_stdin(
"a".as_bytes(),
Box::new(os_input.clone()),
&mut mouse_old_event,
&mut session,
);
... |
rust_dataset_chunk_511777 | rust_dataset.txt | 511,777 | 512 | areKey::Char('a')).with_ctrl_modifier()
);
},
other => panic!("expected Key message, got {other:?}"),
}
}
#[test]
fn focus_reports_are_not_typed_into_the_session() {
let os_input = RecordingOsInput::default();
let mut mouse_old_event = MouseEv... |
rust_dataset_chunk_511778 | rust_dataset.txt | 511,778 | 512 | session = super::StdinSession::new(false);
parse_stdin(
b"ab",
Box::new(os_input.clone()),
&mut mouse_old_event,
&mut session,
);
let sent = os_input.take_sent_messages();
// Two Char events ('a', 'b'), both via the termwiz path.
... |
rust_dataset_chunk_511779 | rust_dataset.txt | 511,779 | 512 | _web_client(
config: Config,
config_options: Options,
config_file_path: Option<PathBuf>,
run_daemonized: bool,
custom_ip: Option<IpAddr>,
custom_port: Option<u16>,
custom_server_cert: Option<PathBuf>,
custom_server_key: Option<PathBuf>,
startup_timeout: Option<u64>,
) {
std::pani... |
rust_dataset_chunk_511780 | rust_dataset.txt | 511,780 | 512 | let (runtime, listener, tls_config) = if run_daemonized {
daemonize_web_server(
web_server_ip,
web_server_port,
web_server_cert,
web_server_key,
config_file_path.clone(),
startup_timeout,
)
} else {
let runtime = Run... |
rust_dataset_chunk_511781 | rust_dataset.txt | 511,781 | 512 | utex::new(ConnectionTable::default()));
let server_handle = Handle::new();
let session_manager = session_manager.unwrap_or_else(|| Arc::new(RealSessionManager));
let client_os_api_factory =
client_os_api_factory.unwrap_or_else(|| Arc::new(RealClientOsApiFactory));
// we use a short version here... |
rust_dataset_chunk_511782 | rust_dataset.txt | 511,782 | 512 | ".parse().unwrap());
headers.insert("X-Frame-Options", "DENY".parse().unwrap());
headers.insert("Referrer-Policy", "strict-origin-when-cross-origin".parse().unwrap());
headers.insert(
"Content-Security-Policy",
"default-src 'self'; ... |
rust_dataset_chunk_511783 | rust_dataset.txt | 511,783 | 512 | _umask);
let web_server_key = web_server_key.clone();
let web_server_cert = web_server_cert.clone();
let daemonization_outcome = daemonize::Daemonize::new()
.working_directory(std::env::current_dir().unwrap())
.umask(current_umask.bits() as u32)
.privileged_action(
move |... |
rust_dataset_chunk_511784 | rust_dataset.txt | 511,784 | 512 | 2);
},
}
} else {
std::process::exit(parent.first_child_exit_code);
}
},
Outcome::Child(Ok(child)) => match child.privileged_action_result {
Ok(listener_and_runtime) => {
let _ = writeln!(
... |
rust_dataset_chunk_511785 | rust_dataset.txt | 511,785 | 512 | _PROCESS_GROUP);
}
match cmd.spawn() {
Ok(_child) => {
let timeout_secs = startup_timeout.unwrap_or(DEFAULT_SERVER_STARTUP_TIMEOUT_SECS);
let deadline = Instant::now() + Duration::from_secs(timeout_secs);
let addr = format!("{}:{}", web_server_ip, web_server_port);
... |
rust_dataset_chunk_511786 | rust_dataset.txt | 511,786 | 512 | : Arc<dyn SessionManager>,
attachment_complete_tx: Option<tokio::sync::oneshot::Sender<()>>,
client_size: Option<Size>,
client_pixel_dims: Option<SizeInPixels>,
pending_welcome_sessions: PendingWelcomeSessions,
is_structured_client: bool,
) {
let _server_listener_thread = std::thread::Builder::n... |
rust_dataset_chunk_511787 | rust_dataset.txt | 511,787 | 512 | _messages = false;
let palette = config
.theme_config(config_options.theme.as_ref())
.unwrap_or_else(|| os_input.load_palette().into());
let client_attributes = zellij_utils::ipc::ClientAttributes {
size: fu... |
rust_dataset_chunk_511788 | rust_dataset.txt | 511,788 | 512 |
// via the TerminalMetrics control message once the
// browser has reported them.
if !is_structured_client {
let seeds = host_query_seed_msgs
.get_or_insert_with(|| build_host_query_seed_msgs(&config, &confi... |
rust_dataset_chunk_511789 | rust_dataset.txt | 511,789 | 512 | Size) => {
client_connection_bus.send_control(
WebServerToWebClientControlMessage::QueryTerminalSize,
);
},
Some(ServerToClientMsg::SetSoftKeyboard{on}) => {
... |
rust_dataset_chunk_511790 | rust_dataset.txt | 511,790 | 512 | }) => {},
Some(ServerToClientMsg::HostProgramStatus { .. }) => {},
Some(ServerToClientMsg::SessionAttention { .. }) => {},
Some(ServerToClientMsg::SessionPreview { .. }) => {},
Some(ServerToClientMsg::PaneMi... |
rust_dataset_chunk_511791 | rust_dataset.txt | 511,791 | 512 | = exit_reason == ExitReason::KickedByHost;
client_connection_bus.send_control(WebServerToWebClientControlMessage::Exit {
reason: exit_reason,
});
if kicked {
client_connection_bus.close_connection_kicked();
} else {
client_connection_bus.close_connect... |
rust_dataset_chunk_511792 | rust_dataset.txt | 511,792 | 512 | ) => {
log::error!("Failed to reload config: {}", e);
},
};
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn a_structured_client_is_declared_capable_of_inline_graphics_and_nothing_local() {
let declarations = structured_client_declarations();
assert_eq!(
... |
rust_dataset_chunk_511793 | rust_dataset.txt | 511,793 | 512 | }))
} else {
Ok(None)
}
}
pub fn spawn_new_session(
session_name: &str,
mut os_input: Box<dyn ClientOsApi>,
zellij_ipc_pipe: &PathBuf,
) {
let debug = false;
envs::set_session_name(session_name.to_owned());
os_input.update_session_name(session_name.to_owned());
spawn... |
rust_dataset_chunk_511794 | rust_dataset.txt | 511,794 | 512 | let cli_assets = CliAssets {
config_file_path,
config_dir: None,
should_ignore_config: false,
configuration_options: Some(config_opts),
layout: None,
terminal_window_size: client_attributes.size,
data_dir: None,
is_debug: f... |
rust_dataset_chunk_511795 | rust_dataset.txt | 511,795 | 512 | SetConfigPayload;
use crate::web_client::session_management::spawn_new_session;
use std::path::PathBuf;
use zellij_utils::{
input::{config::Config, options::Options},
ipc::ClientToServerMsg,
};
pub trait ClientOsApiFactory: Send + Sync + std::fmt::Debug {
fn create_client_os_api(&self) -> Result<Box<dyn Cl... |
rust_dataset_chunk_511796 | rust_dataset.txt | 511,796 | 512 | connected_clients: info.connected_clients,
creation_secs_ago: info.creation_time.as_secs(),
})
.collect()
}
fn get_resurrection_layout(
&self,
session_name: &str,
) -> Option<zellij_utils::input::layout::Layout> {
zellij_utils:... |
rust_dataset_chunk_511797 | rust_dataset.txt | 511,797 | 512 | .pending_control_messages.remove(0);
}
self.pending_control_messages.push(message);
}
pub fn add_terminal_tx(&mut self, terminal_channel_tx: UnboundedSender<Message>) {
self.terminal_channel_tx = Some(terminal_channel_tx);
}
pub fn add_terminal_channel_cancellation_token(
... |
rust_dataset_chunk_511798 | rust_dataset.txt | 511,798 | 512 | pending = pending.lock().unwrap();
let now = Instant::now();
pending.retain(|(_, created_at)| now.duration_since(*created_at) < PENDING_WELCOME_SESSION_TTL);
match pending.iter().position(|(name, _)| name == session_name) {
Some(index) => {
pending.remove(index);
true
... |
rust_dataset_chunk_511799 | rust_dataset.txt | 511,799 | 512 | 8; 6] = [27, 91, 50, 48, 49, 126]; // \u{1b}[201~
--- FILE: zellij/zellij-client/src/web_client/unit/web_client_tests.rs ---
use super::serve_web_client;
use super::*;
use futures_util::{SinkExt, StreamExt};
use isahc::prelude::*;
use serde_json;
use std::collections::{HashMap, HashSet, VecDeque};
use std::sync::{Arc... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.