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_517500 | rust_dataset.txt | 517,500 | 512 | /// Toggle the UI pane frames on or off
pub fn toggle_pane_frames() {
let plugin_command = PluginCommand::TogglePaneFrames;
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_comman... |
rust_dataset_chunk_517501 | rust_dataset.txt | 517,501 | 512 | obufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
}
pub fn new_pane() {
let plugin_command = PluginCommand::NewPane;
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unw... |
rust_dataset_chunk_517502 | rust_dataset.txt | 517,502 | 512 | _plugin_command() };
}
/// Change to the next [swap layout](https://zellij.dev/documentation/swap-layouts.html)
pub fn next_swap_layout() {
let plugin_command = PluginCommand::NextSwapLayout;
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf... |
rust_dataset_chunk_517503 | rust_dataset.txt | 517,503 | 512 | ).unwrap()
}
pub fn go_to_tab(tab_index: u32) {
let plugin_command = PluginCommand::GoToTab(tab_index);
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
}
pub fn st... |
rust_dataset_chunk_517504 | rust_dataset.txt | 517,504 | 512 | _be_in_place_if_hidden: bool,
) {
let plugin_command = PluginCommand::FocusPluginPane(
plugin_pane_id,
should_float_if_hidden,
should_be_in_place_if_hidden,
);
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plug... |
rust_dataset_chunk_517505 | rust_dataset.txt | 517,505 | 512 | plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
}
/// Switch to a session with the given name, create one if no name is given
pub fn switch_session(name: Option<&str>) {
let plugin_command = PluginCommand::SwitchSession(... |
rust_dataset_chunk_517506 | rust_dataset.txt | 517,506 | 512 | Command::SwitchSession(ConnectToSession {
name: Some(name.to_owned()),
tab_position,
pane_id,
..Default::default()
});
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsa... |
rust_dataset_chunk_517507 | rust_dataset.txt | 517,507 | 512 | let plugin_command = PluginCommand::RenameSession(name.to_owned());
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
}
/// Unblock the input side of a pipe, requesti... |
rust_dataset_chunk_517508 | rust_dataset.txt | 517,508 | 512 | from the current session
pub fn disconnect_other_clients() {
let plugin_command = PluginCommand::DisconnectOtherClients;
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command(... |
rust_dataset_chunk_517509 | rust_dataset.txt | 517,509 | 512 | _path_buf());
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
}
pub fn set_soft_keyboard(on: bool) {
let plugin_command = PluginCommand::SetSoftKeyboard(on);
le... |
rust_dataset_chunk_517510 | rust_dataset.txt | 517,510 | 512 | Ok((content, metadata))
},
Some(dump_session_layout_response::Result::Error(error)) => Err(error),
None => Err("Server returned empty response".to_string()),
}
}
/// Parses a KDL layout string and returns LayoutMetadata
pub fn parse_layout(layout_string: &str) -> Result<LayoutMetadata, Lay... |
rust_dataset_chunk_517511 | rust_dataset.txt | 517,511 | 512 | bytes| ProtobufReadConfigResponse::decode(bytes.as_slice()).ok())
.map(ConfigSnapshot::from)
.unwrap_or_default()
}
pub fn revert_config(key: Option<SettingKey>) {
let plugin_command = PluginCommand::RevertConfig(key);
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into... |
rust_dataset_chunk_517512 | rust_dataset.txt | 517,512 | 512 | _run_plugin_command() };
}
pub fn reset_keys(keys: Vec<(InputMode, KeyWithModifier)>, write_config_to_disk: bool) {
let plugin_command = PluginCommand::ResetKeys {
keys,
write_config_to_disk,
};
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
obj... |
rust_dataset_chunk_517513 | rust_dataset.txt | 517,513 | 512 | ());
unsafe { host_run_plugin_command() };
let response = bytes_from_stdin()
.ok()
.and_then(|bytes| ProtobufWriteThemeFileResponse::decode(bytes.as_slice()).ok());
match response.and_then(|response| response.result) {
Some(WriteResult::Path(path)) => Ok(path),
Some(WriteResu... |
rust_dataset_chunk_517514 | rust_dataset.txt | 517,514 | 512 | : u32) {
let plugin_command = PluginCommand::RerunCommandPane(terminal_pane_id);
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
}
/// Sugar for close_terminal_pane... |
rust_dataset_chunk_517515 | rust_dataset.txt | 517,515 | 512 | works
/// for terminal panes)
pub fn edit_scrollback_for_pane_with_id(pane_id: PaneId) {
let plugin_command = PluginCommand::EditScrollbackForPaneWithId(pane_id);
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec... |
rust_dataset_chunk_517516 | rust_dataset.txt | 517,516 | 512 | = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
}
/// Write characters to the `STDIN` of the specified pane
pub fn write_chars_to_pane_id(chars: &str, pane_id: PaneId) {
let plugin_command = PluginCommand::WriteCharsTo... |
rust_dataset_chunk_517517 | rust_dataset.txt | 517,517 | 512 | protobuf response: {}", e))?;
// Convert Result enum to actual Result type
match response {
GetPanePidResponse::Ok(pid) => Ok(pid),
GetPanePidResponse::Err(error_msg) => Err(error_msg),
}
}
/// Gets the current running command for a specific pane by its ID.
///
/// This queries the operat... |
rust_dataset_chunk_517518 | rust_dataset.txt | 517,518 | 512 | Snapshot, String> {
let plugin_command = PluginCommand::GetSessionList;
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
let protobuf_response =
Protobuf... |
rust_dataset_chunk_517519 | rust_dataset.txt | 517,519 | 512 | ) -> Result<PathBuf, String> {
let plugin_command = PluginCommand::GetPaneCwd { pane_id };
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
let protobuf_response... |
rust_dataset_chunk_517520 | rust_dataset.txt | 517,520 | 512 | response {
SaveLayoutResponse::Ok(_) => Ok(()),
SaveLayoutResponse::Err(error_msg) => Err(error_msg),
}
}
/// Delete a layout from the user's layout directory.
///
/// # Arguments
///
/// * `layout_name` - The name of the layout file to delete (without the `.kdl` extension).
/// ... |
rust_dataset_chunk_517521 | rust_dataset.txt | 517,521 | 512 | the layout (without .kdl extension)
///
/// # Returns
/// * `Ok(())` - Layout was successfully renamed
/// * `Err(String)` - Error message describing what went wrong
///
/// # Error Cases
/// * Old layout name is invalid (empty, contains path separators, etc.)
/// * New layout name is invalid
/// * Source layout file ... |
rust_dataset_chunk_517522 | rust_dataset.txt | 517,522 | 512 | layout_name.as_ref().to_owned();
let plugin_command = PluginCommand::EditLayout {
layout_name,
context,
};
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_co... |
rust_dataset_chunk_517523 | rust_dataset.txt | 517,523 | 512 | _plugin_command() };
}
/// Scroll the specified pane up 1 line
pub fn scroll_up_in_pane_id(pane_id: PaneId) {
let plugin_command = PluginCommand::ScrollUpInPaneId(pane_id);
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.enc... |
rust_dataset_chunk_517524 | rust_dataset.txt | 517,524 | 512 | unsafe { host_run_plugin_command() };
}
/// Toggle the specified pane to be fullscreen or normal sized
pub fn toggle_pane_id_fullscreen(pane_id: PaneId) {
let plugin_command = PluginCommand::TogglePaneIdFullscreen(pane_id);
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap(... |
rust_dataset_chunk_517525 | rust_dataset.txt | 517,525 | 512 | _pane_id) => {
PluginCommand::RenameTerminalPane(terminal_pane_id, new_name.to_string())
},
PaneId::Plugin(plugin_pane_id) => {
PluginCommand::RenamePluginPane(plugin_pane_id, new_name.to_string())
},
};
let protobuf_plugin_command: ProtobufPluginCommand = plugin_... |
rust_dataset_chunk_517526 | rust_dataset.txt | 517,526 | 512 | TabWithId(
pane_ids.to_vec(),
tab_id as u64,
should_change_focus_to_target_tab,
);
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
let r... |
rust_dataset_chunk_517527 | rust_dataset.txt | 517,527 | 512 | _to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
}
pub fn set_floating_pane_pinned(pane_id: PaneId, should_be_pinned: bool) {
let plugin_command = PluginCommand::SetFloatingPanePinned(pane_id, should_be_pinned);
let protobuf_plugin_command: ProtobufPluginCommand =... |
rust_dataset_chunk_517528 | rust_dataset.txt | 517,528 | 512 | fn set_pane_border_style(pane_id: PaneId, border_style: BorderStyleOverride) {
let plugin_command = PluginCommand::SetPaneBorderStyle(pane_id, border_style);
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
... |
rust_dataset_chunk_517529 | rust_dataset.txt | 517,529 | 512 | let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
}
pub fn group_and_ungroup_panes(
pane_ids_to_group: Vec<PaneId>,
pane_ids_to_ungroup: Vec<PaneId>,
for_all_... |
rust_dataset_chunk_517530 | rust_dataset.txt | 517,530 | 512 | ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
}
/// Give this plugin's pane back to its neighbors while it has nothing to draw, or take it
/// again when it does.
///
/// Intended for a plugin mount... |
rust_dataset_chunk_517531 | rust_dataset.txt | 517,531 | 512 | } else {
Ok(())
}
}
pub fn list_web_login_tokens() -> Result<Vec<(String, String, bool)>, String> {
// (name, created_at, read_only)
let plugin_command = PluginCommand::ListWebLoginTokens;
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_st... |
rust_dataset_chunk_517532 | rust_dataset.txt | 517,532 | 512 | ().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
}
pub fn clear_key_presses_intercepts() {
let plugin_command = PluginCommand::ClearKeyPressesIntercepts;
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap()... |
rust_dataset_chunk_517533 | rust_dataset.txt | 517,533 | 512 | _stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
}
// Internal Functions
#[doc(hidden)]
pub fn object_from_stdin<T: DeserializeOwned>() -> Result<T> {
let err_context = || "failed to deserialize object from stdin".to_string();
let mut json = String::new();
io::... |
rust_dataset_chunk_517534 | rust_dataset.txt | 517,534 | 512 | {
self.position = JsonBytesPosition::AfterArray;
}
},
byte if byte.is_ascii_whitespace() && self.current.is_none() => {},
_ => return Err("unexpected character in byte array"),
},
JsonBytesPosition::Afte... |
rust_dataset_chunk_517535 | rust_dataset.txt | 517,535 | 512 | ToPlugin(plugin_message);
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
}
pub fn run_action(action: Action, context: BTreeMap<String, String>) {
// TODO: also acc... |
rust_dataset_chunk_517536 | rust_dataset.txt | 517,536 | 512 | _command = PluginCommand::HideFloatingPanes { tab_id };
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
let response_bytes =
bytes_from_stdin().map_err(|e| f... |
rust_dataset_chunk_517537 | rust_dataset.txt | 517,537 | 512 | ClearPaneHighlights(pane_id);
let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap();
object_to_stdout(&protobuf_plugin_command.encode_to_vec());
unsafe { host_run_plugin_command() };
}
thread_local! {
static NEXT_PROMPT_REQUEST_ID: std::cell::Cell<u64> = std::cell::Cel... |
rust_dataset_chunk_517538 | rust_dataset.txt | 517,538 | 512 | , capacity: usize) -> Vec<Result<Vec<u8>, String>> {
let mut reader = BufReader::with_capacity(capacity, Cursor::new(input.as_bytes().to_vec()));
let mut results = vec![];
while !reader.fill_buf().unwrap().is_empty() {
results.push(read_json_byte_array_line(&mut reader).map_err(|e| e... |
rust_dataset_chunk_517539 | rust_dataset.txt | 517,539 | 512 | }
impl Button {
pub fn new(label: impl Into<Text>) -> Self {
Button {
label: label.into(),
width: None,
focused: false,
disabled: false,
pressed: false,
hovered: false,
accent_brackets: false,
left_aligned: fals... |
rust_dataset_chunk_517540 | rust_dataset.txt | 517,540 | 512 | state, "ab", self.accent_brackets);
state_flag(&mut state, "la", self.left_aligned);
widget_dcs("button", x, y, Some(width), Some(1), &state, &self.fields())
}
fn fields(&self) -> Vec<String> {
vec![self.label.serialize()]
}
pub fn render(&mut self, x: usize, y: usize) {
... |
rust_dataset_chunk_517541 | rust_dataset.txt | 517,541 | 512 | }
}
--- FILE: zellij/zellij-tile/src/ui_components/confirm_dialog.rs ---
use super::text::Text;
use super::widget_common::{
encode_text, is_plain, is_shift_tab, state_value, text_width, widget_dcs, Rect, UiResponse,
UiValue, Widget,
};
use zellij_utils::data::{BareKey, KeyWithModifier, Mouse};
const DEFAULT... |
rust_dataset_chunk_517542 | rust_dataset.txt | 517,542 | 512 | self
}
pub fn footer_area(&self) -> Option<Rect> {
let area = self.area?;
if self.footer_rows == 0 || area.width < 4 {
return None;
}
Some(Rect::new(
area.x + 2,
area.y + area.height - 1 - self.footer_rows,
area.width - 4,
... |
rust_dataset_chunk_517543 | rust_dataset.txt | 517,543 | 512 | width: usize, max_height: usize) -> String {
let width = width.max(MIN_WIDTH);
let mut lines = self.lines_for(width);
let max_lines = max_height.saturating_sub(5 + self.footer_rows);
lines.truncate(max_lines);
let height = lines.len() + 5 + self.footer_rows;
let widths =... |
rust_dataset_chunk_517544 | rust_dataset.txt | 517,544 | 512 | _sub(width) / 2;
let y = rows.saturating_sub(height) / 2;
self.serialize(x, y, width, rows)
}
pub fn render_centered(&mut self, rows: usize, cols: usize) {
print!("{}", self.serialize_centered(rows, cols));
}
fn choose(&mut self, index: usize) -> UiResponse {
self.selecte... |
rust_dataset_chunk_517545 | rust_dataset.txt | 517,545 | 512 | _focused(&self) -> bool {
self.open
}
fn is_disabled(&self) -> bool {
false
}
fn last_area(&self) -> Option<Rect> {
self.area
}
fn clear_area(&mut self) {
self.area = None;
self.button_areas.clear();
}
fn captures_input(&self) -> bool {
sel... |
rust_dataset_chunk_517546 | rust_dataset.txt | 517,546 | 512 | }
pub fn accent_brackets(mut self) -> Self {
self.accent_brackets = true;
self
}
pub fn arrow(mut self, arrow: impl Into<String>) -> Self {
self.arrow = Some(arrow.into());
self
}
pub fn styled_value(mut self, value: impl Into<Text>) -> Self {
self.styled_... |
rust_dataset_chunk_517547 | rust_dataset.txt | 517,547 | 512 | {
self.open
}
pub fn highlighted_index(&self) -> Option<usize> {
if self.open {
self.menu.highlighted_index()
} else {
None
}
}
pub fn set_highlighted_index(&mut self, index: usize) {
if self.open && index < self.options.len() {
... |
rust_dataset_chunk_517548 | rust_dataset.txt | 517,548 | 512 | _width = self.effective_label_width();
let width = width.max(label_width + MIN_FIELD_WIDTH);
self.area = Some(Rect::new(x, y, width, 1));
let mut state = vec![];
state_flag(&mut state, "f", self.focused);
state_flag(&mut state, "d", self.disabled);
state_flag(&mut state, ... |
rust_dataset_chunk_517549 | rust_dataset.txt | 517,549 | 512 | wanted, wanted)
} else if above > below {
(0, above)
} else {
(area.bottom(), below)
};
if height < 3 {
return String::new();
}
self.opens_upward = list_y < area.y;
let serialized = self.menu.serialize(field_x, list_y, list_wid... |
rust_dataset_chunk_517550 | rust_dataset.txt | 517,550 | 512 | ::RightClick(..) => {
self.close();
UiResponse::Cancelled
},
Mouse::Hover(line, column) | Mouse::Hold(line, column) => {
let on_field = self.area.map(|a| a.contains(line, column)).unwrap_or(false);
update_hov... |
rust_dataset_chunk_517551 | rust_dataset.txt | 517,551 | 512 | Toggle(Toggle),
Dropdown(Dropdown),
TextInput(TextInput),
NumberStepper(NumberStepper),
MenuList(MenuList),
SideMenu(SideMenu),
}
macro_rules! element_conversions {
($($variant:ident, $as_ref:ident, $as_mut:ident);* $(;)?) => {
$(
impl From<$variant> for Element {
... |
rust_dataset_chunk_517552 | rust_dataset.txt | 517,552 | 512 | ($($variant:ident, $get:ident, $get_mut:ident, $as_ref:ident, $as_mut:ident);* $(;)?) => {
$(
pub fn $get(&self, key: &K) -> Option<&$variant> {
self.get(key).and_then(|element| element.$as_ref())
}
pub fn $get_mut(&mut self, key: &K) -> Option<&mut $variant>... |
rust_dataset_chunk_517553 | rust_dataset.txt | 517,553 | 512 | , as_toggle_mut;
Dropdown, dropdown, dropdown_mut, as_dropdown, as_dropdown_mut;
TextInput, text_input, text_input_mut, as_text_input, as_text_input_mut;
NumberStepper, number_stepper, number_stepper_mut, as_number_stepper, as_number_stepper_mut;
MenuList, menu_list, menu_list_mut, as_me... |
rust_dataset_chunk_517554 | rust_dataset.txt | 517,554 | 512 | None => {
return if forward {
(0..count).find(|i| !self.entries[*i].1.widget().is_disabled())
} else {
(0..count)
.rev()
.find(|i| !self.entries[*i].1.widget().is_disabled())
};
... |
rust_dataset_chunk_517555 | rust_dataset.txt | 517,555 | 512 | fn element_at(&self, line: isize, column: usize) -> Option<&K> {
self.index_at(line, column).map(|i| &self.entries[i].0)
}
fn index_at(&self, line: isize, column: usize) -> Option<usize> {
self.entries
.iter()
.position(|(_, element)| element.widget().hit_test(line, colu... |
rust_dataset_chunk_517556 | rust_dataset.txt | 517,556 | 512 | FocusEvent::FocusChanged(self.entries[index].0.clone())
}
},
Mouse::Hover(..)
| Mouse::Release(..)
| Mouse::Hold(..)
| Mouse::ScrollUp(_)
| Mouse::ScrollDown(_) => {
let stop_at_first = matches!(mouse, Mouse::Scroll... |
rust_dataset_chunk_517557 | rust_dataset.txt | 517,557 | 512 | : vec![],
}
}
pub fn shortcut(mut self, shortcut: impl Into<String>) -> Self {
self.shortcut = Some(shortcut.into());
self
}
pub fn disabled(mut self) -> Self {
self.disabled = true;
self
}
pub fn marked(mut self) -> Self {
self.marked = true;
... |
rust_dataset_chunk_517558 | rust_dataset.txt | 517,558 | 512 | serialized.push('/');
serialized.push_str(&join(&self.emphasized));
}
serialized
}
fn natural_width(&self, mark_column: bool) -> usize {
text_width(&self.label)
+ if mark_column { 4 } else { 2 }
+ self
.shortcut
.as_ref... |
rust_dataset_chunk_517559 | rust_dataset.txt | 517,559 | 512 | .offset = self
.offset
.min(self.items.len().saturating_sub(self.visible_rows));
}
pub fn highlighted_index(&self) -> Option<usize> {
self.highlighted
}
pub fn highlighted_item(&self) -> Option<&MenuItem> {
self.highlighted.and_then(|i| self.items.get(i))
}
... |
rust_dataset_chunk_517560 | rust_dataset.txt | 517,560 | 512 | .reveal(SCROLL_MARGIN);
}
self.offset = self
.offset
.min(self.items.len().saturating_sub(self.visible_rows));
let height = self.height_for(max_height);
self.area = Some(Rect::new(x, y, width, height));
let mut state = vec![];
state_flag(&mut state... |
rust_dataset_chunk_517561 | rust_dataset.txt | 517,561 | 512 | let row = (line as usize).checked_sub(self.first_item_line()?)?;
if row >= self.visible_rows {
return None;
}
Some(self.offset + row)
}
fn indicator_at(&self, line: isize, column: usize) -> Option<IndicatorHover> {
let area = self.area?;
if !(self.border || s... |
rust_dataset_chunk_517562 | rust_dataset.txt | 517,562 | 512 | .iter()
.enumerate()
.filter(|(_, item)| item.is_selectable())
.map(|(index, _)| index)
.collect();
if selectable.is_empty() {
self.highlighted = None;
return;
}
let position = self
.highlighted
.and... |
rust_dataset_chunk_517563 | rust_dataset.txt | 517,563 | 512 | } else if is_plain(key, BareKey::PageDown) {
self.step(true, page);
UiResponse::Consumed
} else if is_plain(key, BareKey::Home) {
self.highlighted = None;
self.step(true, 1);
UiResponse::Consumed
} else if is_plain(key, BareKey::End) {
... |
rust_dataset_chunk_517564 | rust_dataset.txt | 517,564 | 512 | ) => UiResponse::Consumed,
_ => UiResponse::NotHandled,
}
},
Mouse::ScrollUp(count) if self.hovered => {
self.scroll_by(-(count.max(1) as isize));
UiResponse::Consumed
},
Mouse::ScrollDown(count) if self.... |
rust_dataset_chunk_517565 | rust_dataset.txt | 517,565 | 512 | self
}
pub fn serialize(&self) -> String {
let mut serialized = String::new();
for _ in 0..self.indentation_level {
serialized.push('|');
}
format!("{}{}", serialized, self.content.serialize())
}
}
/// render a nested list with arbitrary data
pub fn print... |
rust_dataset_chunk_517566 | rust_dataset.txt | 517,566 | 512 | 1b}Pznested_list;{}/{}/{}/{};{}\u{1b}\\",
x, y, width, height, items
)
}
--- FILE: zellij/zellij-tile/src/ui_components/number_stepper.rs ---
use super::text::Text;
use super::text_input::TextInput;
use super::widget_common::{
default_label_width, encode_text, is_plain, state_flag, state_value, typed_... |
rust_dataset_chunk_517567 | rust_dataset.txt | 517,567 | 512 | <i64>,
label_width: Option<usize>,
field_width: Option<usize>,
input: TextInput,
editing: bool,
focused: bool,
disabled: bool,
hovered: bool,
hovered_arrow: Option<bool>,
area: Option<Rect>,
field_x: usize,
field_width_drawn: usize,
}
impl NumberStepper {
pub fn new(labe... |
rust_dataset_chunk_517568 | rust_dataset.txt | 517,568 | 512 | pub fn label(&self) -> &str {
self.label.content()
}
pub fn value(&self) -> i64 {
self.value
}
pub fn set_value(&mut self, value: i64) {
self.value = self.clamp(value);
self.editing = false;
}
pub fn display_value(&self) -> String {
format_scaled(self.... |
rust_dataset_chunk_517569 | rust_dataset.txt | 517,569 | 512 | ;
}
fn commit(&mut self) -> bool {
if !self.editing {
return false;
}
self.editing = false;
let previous = self.value;
if let Some(parsed) = parse_scaled(self.input.get_text(), self.decimals) {
self.value = self.clamp(parsed);
}
sel... |
rust_dataset_chunk_517570 | rust_dataset.txt | 517,570 | 512 | (&mut self, x: usize, y: usize) {
print!("{}", self.serialize(x, y));
}
fn arrow_at(&self, column: usize) -> Option<bool> {
if column == self.field_x {
Some(false)
} else if column + 1 == self.field_x + self.field_width_drawn {
Some(true)
} else {
... |
rust_dataset_chunk_517571 | rust_dataset.txt | 517,571 | 512 | ) {
Some(false) => self.step_by(-1),
Some(true) => self.step_by(1),
None => UiResponse::Consumed,
}
},
Mouse::Hover(line, column) => {
let hit = self.hit_test(line, column);
let previous_a... |
rust_dataset_chunk_517572 | rust_dataset.txt | 517,572 | 512 | _string()).unwrap_or_default();
let height = height.map(|h| h.to_string()).unwrap_or_default();
format!(
"\u{1b}Pzribbon;{}/{}/{}/{};{}\u{1b}\\",
x,
y,
width,
height,
text.serialize()
)
}
pub fn serialize_ribbon_line<I>(ribbons: I) -> String
where
I: Int... |
rust_dataset_chunk_517573 | rust_dataset.txt | 517,573 | 512 | _rows;
self.clamp();
}
pub fn offset(&self) -> usize {
self.offset
}
pub fn set_offset(&mut self, offset: usize) {
self.offset = offset;
self.clamp();
}
pub fn is_hovered(&self) -> bool {
self.hovered
}
pub fn is_dragging(&self) -> bool {
s... |
rust_dataset_chunk_517574 | rust_dataset.txt | 517,574 | 512 | self.visible_range().start
}
pub fn rows_below(&self) -> usize {
self.total_rows.saturating_sub(self.visible_range().end)
}
pub fn screen_row(&self, row: usize) -> Option<usize> {
if self.area.is_some() && self.visible_range().contains(&row) {
Some(self.content_y() + row - s... |
rust_dataset_chunk_517575 | rust_dataset.txt | 517,575 | 512 | Value::Index(self.offset))
} else {
UiResponse::Consumed
}
}
fn indicator_at(&self, line: isize, column: usize) -> Option<IndicatorHover> {
let area = self.area?;
if !self.needs_indicators() || !area.contains(line, column) {
return None;
}
... |
rust_dataset_chunk_517576 | rust_dataset.txt | 517,576 | 512 |
}
}
fn handle_mouse(&mut self, mouse: Mouse) -> UiResponse {
match mouse {
Mouse::Hover(line, column) => {
let hit = self.hit_test(line, column);
let previous = self.indicator_hover;
self.indicator_hover = self.indicator_at(line, colum... |
rust_dataset_chunk_517577 | rust_dataset.txt | 517,577 | 512 | }
fn is_disabled(&self) -> bool {
false
}
fn last_area(&self) -> Option<Rect> {
self.area
}
fn clear_area(&mut self) {
self.area = None;
self.dragging = false;
}
}
--- FILE: zellij/zellij-tile/src/ui_components/side_menu.rs ---
use super::widget_common::{
... |
rust_dataset_chunk_517578 | rust_dataset.txt | 517,578 | 512 | }
pub fn selected_label(&self) -> Option<&str> {
self.items.get(self.selected).map(|i| i.as_str())
}
pub fn set_selected(&mut self, index: usize) {
if index < self.items.len() {
self.selected = index;
self.reveal();
}
}
pub fn scroll_offset(&self) ... |
rust_dataset_chunk_517579 | rust_dataset.txt | 517,579 | 512 | .offset + self.visible_rows;
let mut state = vec![];
state_flag(&mut state, "f", self.focused);
state_flag(&mut state, "ind", self.indicator_rows);
if visible.contains(&self.selected) {
state_value(&mut state, "sel", self.selected - self.offset);
}
if let Some... |
rust_dataset_chunk_517580 | rust_dataset.txt | 517,580 | 512 | + row < self.items.len() {
Some(self.offset + row)
} else {
None
}
}
}
impl Widget for SideMenu {
fn handle_key(&mut self, key: &KeyWithModifier) -> UiResponse {
if self.items.is_empty() {
return UiResponse::NotHandled;
}
let last = s... |
rust_dataset_chunk_517581 | rust_dataset.txt | 517,581 | 512 | (count) if self.hovered => {
self.scroll_by(-(count.max(1) as isize));
UiResponse::Consumed
},
Mouse::ScrollDown(count) if self.hovered => {
self.scroll_by(count.max(1) as isize);
UiResponse::Consumed
},
_ =>... |
rust_dataset_chunk_517582 | rust_dataset.txt | 517,582 | 512 | height = height.map(|h| h.to_string()).unwrap_or_default();
print!(
"\u{1b}Pztable;{}/{}/{}/{};{}",
x,
y,
width,
height,
table.serialize()
)
}
pub fn serialize_table(table: &Table) -> String {
format!("\u{1b}Pztable;{}", table.serialize())
}
pub fn serializ... |
rust_dataset_chunk_517583 | rust_dataset.txt | 517,583 | 512 | cs, Rect, UiResponse, UiValue, Widget,
};
use std::fmt;
use std::rc::Rc;
use zellij_utils::data::{BareKey, KeyModifier, KeyWithModifier, Mouse};
use zellij_utils::graphemes;
#[derive(Debug, Clone, Copy)]
struct ClusterSpan {
start: usize,
end: usize,
width: usize,
whitespace: bool,
}
fn cluster_spans(... |
rust_dataset_chunk_517584 | rust_dataset.txt | 517,584 | 512 | .disabled)
.field("scroll_offset", &self.scroll_offset)
.field("area", &self.area)
.finish()
}
}
impl TextInput {
pub fn new(initial_text: impl Into<String>) -> Self {
let initial_text = initial_text.into();
let cursor_position = initial_text.chars().count();... |
rust_dataset_chunk_517585 | rust_dataset.txt | 517,585 | 512 | {
self.disabled = disabled;
}
pub fn set_show_cursor(&mut self, show_cursor: bool) {
self.show_cursor = show_cursor;
}
pub fn set_match_count(&mut self, match_count: Option<usize>) {
self.match_count = match_count;
}
pub fn is_search_mode(&self) -> bool {
self... |
rust_dataset_chunk_517586 | rust_dataset.txt | 517,586 | 512 | next_boundary(&self, position: usize) -> usize {
let spans = cluster_spans(&self.buffer);
spans
.iter()
.map(|span| span.end)
.find(|end| *end > position)
.unwrap_or_else(|| spans.last().map(|span| span.end).unwrap_or(0))
}
fn remove_char_range(&... |
rust_dataset_chunk_517587 | rust_dataset.txt | 517,587 | 512 | _range(start_position, end_position);
}
pub fn move_left(&mut self) {
if self.cursor_position > 0 {
self.break_coalescing();
self.cursor_position = self.previous_boundary(self.cursor_position);
}
}
pub fn move_right(&mut self) {
let len = self.buffer.cha... |
rust_dataset_chunk_517588 | rust_dataset.txt | 517,588 | 512 | fn char_index_to_byte_index(&self, char_index: usize) -> usize {
self.buffer
.char_indices()
.nth(char_index)
.map(|(byte_idx, _)| byte_idx)
.unwrap_or(self.buffer.len())
}
fn save_undo_state(&mut self) {
if self.undo_stack.len() >= MAX_UNDO_S... |
rust_dataset_chunk_517589 | rust_dataset.txt | 517,589 | 512 | let spans = cluster_spans(&self.buffer);
let total = spans.last().map(|span| span.end).unwrap_or(0);
let cursor = self.cursor_position.min(total);
let cursor_index = spans
.iter()
.position(|span| span.start >= cursor)
.unwrap_or(spans.len());
... |
rust_dataset_chunk_517590 | rust_dataset.txt | 517,590 | 512 | + field_width, height));
self.text_start_x = x + label_width + 2;
self.text_area_width = text_area_width;
let show_placeholder = self.buffer.is_empty() && self.placeholder.is_some();
let error = self.validation_error();
let mut state = vec![];
state_flag(&mut state, "f",... |
rust_dataset_chunk_517591 | rust_dataset.txt | 517,591 | 512 | o();
},
BareKey::Char('a') if ctrl => self.move_to_start(),
BareKey::Char('e') if ctrl => self.move_to_end(),
BareKey::Char('z') if ctrl => {
self.undo();
},
BareKey::Char('y') if ctrl => {
self.redo();
}... |
rust_dataset_chunk_517592 | rust_dataset.txt | 517,592 | 512 | ) -> UiResponse {
match mouse {
Mouse::LeftClick(line, column) if self.hit_test(line, column) => {
if self.disabled {
return UiResponse::Consumed;
}
let area = self.area.unwrap_or_default();
if line as usize == area.... |
rust_dataset_chunk_517593 | rust_dataset.txt | 517,593 | 512 | to_string());
input.backspace();
assert_eq!(input.get_text(), "hell");
assert_eq!(input.get_cursor_position(), 4);
input.cursor_position = 0;
input.backspace();
assert_eq!(input.get_text(), "hell");
assert_eq!(input.get_cursor_position(), 0);
}
#[test]
... |
rust_dataset_chunk_517594 | rust_dataset.txt | 517,594 | 512 | 16);
input.move_word_left();
assert_eq!(input.get_cursor_position(), 12);
input.move_word_left();
assert_eq!(input.get_cursor_position(), 6);
input.move_word_left();
assert_eq!(input.get_cursor_position(), 0);
}
#[test]
fn test_word_jump_with_multiple_spac... |
rust_dataset_chunk_517595 | rust_dataset.txt | 517,595 | 512 | !(input.get_text(), "hello rld foo");
assert_eq!(input.get_cursor_position(), 6);
}
#[test]
fn test_delete_word_forward() {
let mut input = TextInput::new("hello world foo".to_string());
input.cursor_position = 0;
input.delete_word_forward();
assert_eq!(input.get_te... |
rust_dataset_chunk_517596 | rust_dataset.txt | 517,596 | 512 | input.insert_char('l');
input.insert_char('o');
assert_eq!(input.get_text(), "llohe");
input.undo();
assert_eq!(input.get_text(), "he");
input.undo();
assert_eq!(input.get_text(), "");
}
#[test]
fn test_undo_backspace() {
let mut input = TextInput... |
rust_dataset_chunk_517597 | rust_dataset.txt | 517,597 | 512 | {
let mut input = TextInput::empty();
for c in "hello".chars() {
input.insert_char(c);
}
input.move_left();
for c in "world".chars() {
input.insert_char(c);
}
assert_eq!(input.get_text(), "hellworldo");
input.undo();
a... |
rust_dataset_chunk_517598 | rust_dataset.txt | 517,598 | 512 | input.get_text(), "a");
input.insert_char('c');
assert_eq!(input.get_text(), "ac");
input.undo();
assert_eq!(input.get_text(), "a");
input.undo();
assert_eq!(input.get_text(), "ab");
input.undo();
assert_eq!(input.get_text(), "");
}
const FAMI... |
rust_dataset_chunk_517599 | rust_dataset.txt | 517,599 | 512 | input.move_to_start();
input.delete();
assert_eq!(input.get_text(), "b");
}
#[test]
fn word_movement_steps_over_clusters() {
let mut input = TextInput::new(format!("{} e\u{301}e\u{301}", FAMILY));
assert_eq!(input.get_cursor_position(), 10);
input.move_word_l... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.