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_510900 | rust_dataset.txt | 510,900 | 512 | _start(
display_name,
max_width
.saturating_sub(9 + zellij_tile::graphemes::display_width(text_suffix)),
);
text = format!("Save as: {}{}", truncated_display_name, text_suffix);
let truncated_len = zellij_til... |
rust_dataset_chunk_510901 | rust_dataset.txt | 510,901 | 512 | );
// Calculate layout detail dimensions
let available_cols_for_details = actual_ui_width.saturating_sub(2);
let desired_details_height =
layout_detail.calculate_required_height(available_cols_for_details);
let desired_ui_height = 6 + desired_details_hei... |
rust_dataset_chunk_510902 | rust_dataset.txt | 510,902 | 512 | ;
self.render_esc_cancel_help(base_x, help_y);
}
}
fn render_esc_cancel_help(&self, x: usize, y: usize) {
let help_text = "<Esc> - Cancel";
let help_text = Text::from(help_text).color_substring(3, "<Esc>");
print_text_with_coordinates(help_text, x, y, None, None);
... |
rust_dataset_chunk_510903 | rust_dataset.txt | 510,903 | 512 | _tab: false,
show_more_override_options: false,
search_state: SearchState::new_in_search_mode(),
last_rows: 0,
last_cols: 0,
}
}
pub fn handle_key(
&mut self,
key: KeyWithModifier,
display_layouts: &[DisplayLayout],
) -> KeyRes... |
rust_dataset_chunk_510904 | rust_dataset.txt | 510,904 | 512 | {
self.apply_selected_layout(display_layouts);
KeyResponse::none()
},
BareKey::Char('t') if key.has_no_modifiers() => {
self.toggle_retain_options();
KeyResponse::render()
},
... |
rust_dataset_chunk_510905 | rust_dataset.txt | 510,905 | 512 | }
return KeyResponse::render();
},
BareKey::Up if key.has_no_modifiers() => {
// Navigate filtered results while typing
self.navigate_up(display_layouts);
return KeyResponse::render();
},
BareKey::Down if ke... |
rust_dataset_chunk_510906 | rust_dataset.txt | 510,906 | 512 | new(Screen::LayoutList(self.clone())),
}),
}
}
fn start_import_layout(&self) -> Screen {
Screen::ImportLayout(super::ImportLayoutScreen::new())
}
fn start_rename_layout(&self, display_layouts: &[DisplayLayout]) -> Option<Screen> {
if let Some(layout_file_name) = sel... |
rust_dataset_chunk_510907 | rust_dataset.txt | 510,907 | 512 | _results()
.get(self.search_state.get_selected_search_index())
.map(|r| r.original_index)
.unwrap_or(0);
} else {
// Normal navigation
if self.selected_layout_index + 1 >= display_layouts.len() {
self.selected_layout_index =... |
rust_dataset_chunk_510908 | rust_dataset.txt | 510,908 | 512 | Box::new(Screen::LayoutList(self.clone())),
)))
} else {
None
}
}
fn should_default_to_current_tab(&self, display_layouts: &[DisplayLayout]) -> bool {
match display_layouts.get(self.selected_layout_index) {
Some(DisplayLayout::Valid(LayoutInfo::Built... |
rust_dataset_chunk_510909 | rust_dataset.txt | 510,909 | 512 | ) =
self.calculate_horizontal_split(cols, display_layouts, controls_width);
let table_y = if self.search_state.is_active() || self.search_state.is_typing() {
1 + base_y
} else {
base_y
};
if self.search_state.is_active() || self.search_state.is_typin... |
rust_dataset_chunk_510910 | rust_dataset.txt | 510,910 | 512 | max(rows_in_table, 5);
if content_height + controls_height + padding + filter_row_height + search_mode_offset
>= rows
{
content_height = rows
.saturating_sub(controls_height)
.saturating_sub(padding)
.saturating_sub(filter_row_heigh... |
rust_dataset_chunk_510911 | rust_dataset.txt | 510,911 | 512 | self.apply_only_to_active_tab,
self.show_more_override_options,
self.search_state.is_typing(),
self.search_state.is_active(),
);
let controls_width = controls.calculate_width(cols);
let (table_width, detail_x) =
self.calculate_horizontal_split(co... |
rust_dataset_chunk_510912 | rust_dataset.txt | 510,912 | 512 | let (total_width, total_height) =
self.calculate_content_dimensions(self.last_rows, self.last_cols, display_layouts);
let (base_x, base_y) = self.calculate_base_coordinates(
self.last_rows,
self.last_cols,
total_width,
total_height,
);
... |
rust_dataset_chunk_510913 | rust_dataset.txt | 510,913 | 512 | if let Some(layout) = layouts.get(before) {
visible.insert(0, layout.clone());
}
} else if after + 1 < layouts.len() {
after += 1;
if let Some(layout) = layouts.get(after) {
visible.push(layout.clone());
}
} else {
... |
rust_dataset_chunk_510914 | rust_dataset.txt | 510,914 | 512 | mut TextInput {
&mut self.filter_input
}
pub fn get_search_results(&self) -> &[SearchResult] {
&self.search_results
}
pub fn get_selected_search_index(&self) -> usize {
self.selected_search_index
}
pub fn set_selected_search_index(&mut self, index: usize) {
sel... |
rust_dataset_chunk_510915 | rust_dataset.txt | 510,915 | 512 | = 0;
show_cursor(None);
}
pub fn get_current_selected_original_index(&self) -> Option<usize> {
self.search_results
.get(self.selected_search_index)
.map(|result| result.original_index)
}
pub fn render_filter_line(&self, base_x: usize, base_y: usize) {
l... |
rust_dataset_chunk_510916 | rust_dataset.txt | 510,916 | 512 | }
/// Optimistic state updates to apply before Zellij confirms
#[derive(Clone, Debug)]
pub enum OptimisticUpdate {
Delete(String), // file_name
Rename {
old_name: String,
new_name: String,
},
Add {
name: String,
metadata: LayoutMetadata,
},
}
/// Response from scree... |
rust_dataset_chunk_510917 | rust_dataset.txt | 510,917 | 512 | _mode_key(&mut self, key: KeyWithModifier) -> KeyResponse {
match self.name_input.handle_key(&key) {
UiResponse::Changed(_) | UiResponse::Consumed => KeyResponse::render(),
UiResponse::Submitted(_) | UiResponse::Cancelled => self.exit_editing_mode(),
_ => KeyResponse::none(),... |
rust_dataset_chunk_510918 | rust_dataset.txt | 510,918 | 512 | ".to_string(),
return_to_screen: Box::new(Screen::LayoutList(Default::default())),
})),
Err(error_msg) => Some(Screen::Error(super::ErrorScreen {
message: format!("Failed to dump session layout: {}", error_msg),
return_to_screen... |
rust_dataset_chunk_510919 | rust_dataset.txt | 510,919 | 512 | _name.to_owned(), self.session_layout.clone(), false)
.map_err(|err| format!("Failed to save layout '{}': {}", layout_name, err))?;
eprintln!(
"Successfully saved current session as layout: {}",
layout_name
);
Ok(())
}
pub fn render(&self, rows: usiz... |
rust_dataset_chunk_510920 | rust_dataset.txt | 510,920 | 512 | 2);
print_text_with_coordinates(title, x, y, Some(width), None);
}
fn description_text_full(&self) -> (&str, &str) {
(
"This layout was created from the current session.",
"Save it to recreate the session later or share it with others.",
)
}
fn descriptio... |
rust_dataset_chunk_510921 | rust_dataset.txt | 510,921 | 512 | {
let (text, _) = self.save_as_line_text(width);
let colored = Text::from(text).color_substring(3, "<r>");
print_text_with_coordinates(colored, x, y, None, None);
}
fn render_tab_toggle(&self, x: usize, y: usize, width: usize) {
let text = if self.save_current_tab_only {
... |
rust_dataset_chunk_510922 | rust_dataset.txt | 510,922 | 512 | usize, max_width: usize) {
if self.editing_name {
let (_, cursor_position_in_line) = self.save_as_line_text(max_width);
show_cursor(Some((base_x + cursor_position_in_line, cursor_y)))
} else {
show_cursor(None)
}
}
}
--- FILE: zellij/default-plugins/lay... |
rust_dataset_chunk_510923 | rust_dataset.txt | 510,923 | 512 | (None);
Screen::Error(ErrorScreen {
message: message.to_string(),
return_to_screen: Box::new(Screen::RenameLayout(self.clone())),
})
}
fn rename_line_text(&self, max_width: Option<usize>) -> (String, usize) {
// Returns (text, cursor_position_in_line)
let... |
rust_dataset_chunk_510924 | rust_dataset.txt | 510,924 | 512 | usize, cursor_y: usize, max_width: usize) {
// Always show cursor since rename is always in editing mode
let (_, cursor_position_in_line) = self.rename_line_text(Some(max_width));
show_cursor(Some((base_x + cursor_position_in_line, cursor_y)))
}
pub fn render(&self, rows: usize, cols: ... |
rust_dataset_chunk_510925 | rust_dataset.txt | 510,925 | 512 | ) {
match self.layout {
DisplayLayout::Valid(_) => {
self.render_valid_layout(self.layout, x, y, max_rows, max_cols)
},
DisplayLayout::Error {
name: _,
error: _,
error_message,
} => self.render_error(... |
rust_dataset_chunk_510926 | rust_dataset.txt | 510,926 | 512 | fn render_built_in_indication(
&self,
name: &str,
x: usize,
y: usize,
max_rows: usize,
max_cols: usize,
) {
if max_rows == 0 {
return;
}
let full_text = format!("{} is a built-in layout. Create your own layouts to automate or shar... |
rust_dataset_chunk_510927 | rust_dataset.txt | 510,927 | 512 | , right_width, padding) = self.calculate_column_layout(max_cols);
let right_x = x + left_width + padding;
let tabs_lines = self.prepare_tabs_content(metadata, left_width);
let panes_lines = self.prepare_panes_content(metadata, right_width);
let (tabs_truncated, panes_truncated) =
... |
rust_dataset_chunk_510928 | rust_dataset.txt | 510,928 | 512 | _label = if let Some(name) = &tab.name {
name.clone()
} else {
format!("Tab {}", i + 1)
};
// Account for " - " prefix (4 characters)
let available_width = max_width.saturating_sub(4);
let truncated_label = truncate_with_ellip... |
rust_dataset_chunk_510929 | rust_dataset.txt | 510,929 | 512 | render_truncation_ellipsis(&self, x: usize, y: usize) {
let ellipsis = Text::from(" [...]").color_all(1);
print_text_with_coordinates(ellipsis, x, y, None, None);
}
fn render_panes_only(
&self,
metadata: &LayoutMetadata,
x: usize,
y: usize,
max_rows: us... |
rust_dataset_chunk_510930 | rust_dataset.txt | 510,930 | 512 | _ellipsis(name, max_width)
} else {
name.to_string()
};
let name_text = if let Some(indices) = matched_indices {
// Create text with highlighted matched characters
let mut text = Text::from(display_name);
// Apply base color to entire text
text = if is_error {
... |
rust_dataset_chunk_510931 | rust_dataset.txt | 510,931 | 512 | the "last modified" column
let max_last_modified_width = self
.display_layouts
.iter()
.map(|layout| {
let (_, metadata_opt) = get_layout_display_info(layout);
get_last_modified_string(metadata_opt, layout.is_builtin()).len()
})
... |
rust_dataset_chunk_510932 | rust_dataset.txt | 510,932 | 512 | ,
filter_active: bool,
) -> Self {
Self {
retain_terminal_panes,
retain_plugin_panes,
apply_only_to_active_tab,
show_more_options,
typing_filter,
filter_active,
}
}
fn get_typing_filter_controls(&self, max_cols:... |
rust_dataset_chunk_510933 | rust_dataset.txt | 510,933 | 512 | = if max_cols >= long_text.chars().count() {
long_text
} else if max_cols >= short_text.chars().count() {
short_text
} else {
minimum_text
};
(text, &["<Enter>", "<↓↑>", "</>", "<e>", "<r>", "<Del>"])
}
fn get_basic_controls_text_and_keys(&se... |
rust_dataset_chunk_510934 | rust_dataset.txt | 510,934 | 512 | toggle
let (override_text, _) = self.get_override_text_and_keys(max_cols);
width = width.max(override_text.chars().count());
// Line 3 (or 5 if show_more_options): New layout controls
let (new_layout_text, _) = self.get_new_layout_text_and_keys(max_cols);
width = width.max(new_... |
rust_dataset_chunk_510935 | rust_dataset.txt | 510,935 | 512 | , "New Layout:");
print_text_with_coordinates(new_layout_line, x, y, None, None);
}
fn render_typing_filter_controls(&self, x: usize, y: usize, max_cols: usize) {
let (text, keys) = self.get_typing_filter_controls(max_cols);
let controls_line = color_control_text(text, keys);
pr... |
rust_dataset_chunk_510936 | rust_dataset.txt | 510,936 | 512 | _text.chars().count() {
match (self.retain_terminal_panes, self.retain_plugin_panes) {
(true, false) => (" <t> Retain: [Term]| Pl | Both | None", "[Term]"),
(false, true) => (" <t> Retain: Term |[Pl]| Both | None", "[Pl]"),
(true, true) => (" <t> Retain: ... |
rust_dataset_chunk_510937 | rust_dataset.txt | 510,937 | 512 | <a> Target: [All]| Current ";
if max_cols >= long_text.chars().count() {
(long_text, "[All Tabs]")
} else {
(short_text, "[All]")
}
}
}
}
pub struct Title<'a> {
text: &'a str,
}
impl<'a> Title<'a> {
pub fn new(text: &'a str) -> S... |
rust_dataset_chunk_510938 | rust_dataset.txt | 510,938 | 512 | ).cloned() {
let text = Text::from(line).error_color_all();
print_text_with_coordinates(text, x, current_y, None, None);
current_y += 1;
}
let help = Text::from("Press any key to continue");
print_text_with_coordinates(help, x, current_y + 2, None, None);
... |
rust_dataset_chunk_510939 | rust_dataset.txt | 510,939 | 512 | !("{}\u{1b}[0m", content)
}
}
pub fn truncate_line_with_ansi(line: &str, max_width: usize) -> String {
let ansi_line = AnsiString::new(line);
let truncated = ansi_line.truncate_to_width(max_width);
AnsiString::with_reset_code(truncated)
}
pub fn wrap_text_to_width(text: &str, max_width: usize) -> Vec<... |
rust_dataset_chunk_510940 | rust_dataset.txt | 510,940 | 512 | .parse::<i64>() else {
return " ".to_string();
};
use std::time::{SystemTime, UNIX_EPOCH};
let now = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs() as i64;
let diff = now - timestamp;
if diff < 60 {
"now".to_string()
} else if diff <... |
rust_dataset_chunk_510941 | rust_dataset.txt | 510,941 | 512 | intercept_key_presses();
set_selectable(false);
}
fn update(&mut self, event: Event) -> bool {
if self.closing {
return false;
}
intercept_key_presses(); // we do this here so that all clients (even those connected after
// lo... |
rust_dataset_chunk_510942 | rust_dataset.txt | 510,942 | 512 | _panes_message(&self, rows: usize, cols: usize) {
let message = "PANES SELECTED FOR OTHER CLIENT";
let message_component = Text::from(message).color_all(2);
let base_x = cols.saturating_sub(message.len()) / 2;
let base_y = rows / 2;
print_text_with_coordinates(message_component, ... |
rust_dataset_chunk_510943 | rust_dataset.txt | 510,943 | 512 | , component)
}
fn shortcuts_line2_text() -> (&'static str, Text) {
let text = "<l> - break left, <r> - break right";
let component = Text::from(text)
.color_substring(3, "<l>")
.color_substring(3, "<r>");
(text, component)
}
fn shortcuts_line3_text() -> ... |
rust_dataset_chunk_510944 | rust_dataset.txt | 510,944 | 512 | client_id)
.or_insert_with(Vec::new)
.push(pane_id);
}
}
}
}
fn update_own_grouped_panes(&mut self, pane_manifest: &PaneManifest, own_client_id: ClientId) {
self.grouped_panes.clear();
let mut count = 0;
... |
rust_dataset_chunk_510945 | rust_dataset.txt | 510,945 | 512 | _index, pane_infos) in &pane_manifest.panes {
for pane_info in pane_infos {
if pane_info.is_plugin && Some(pane_info.id) == self.own_plugin_id {
self.own_tab_index = Some(*tab_index);
return;
}
}
}
}
fn hand... |
rust_dataset_chunk_510946 | rust_dataset.txt | 510,946 | 512 | None,
);
running_y += 1;
print_text_with_coordinates(
Self::shortcuts_line3_text().1,
base_x,
running_y,
None,
None,
);
}
fn render_controls(&self, base_x: usize, base_y: usize) {
render_group_controls(&self.m... |
rust_dataset_chunk_510947 | rust_dataset.txt | 510,947 | 512 | break_panes_to_tab_with_index(&pane_ids, own_tab_index.saturating_sub(1), true);
} else {
break_panes_to_new_tab(&pane_ids, None, true);
}
self.close_self();
}
pub fn close_grouped_panes(&mut self) {
self.execute_action_and_close(|pane_ids| {
... |
rust_dataset_chunk_510948 | rust_dataset.txt | 510,948 | 512 | !("{}", height)),
Some(true),
Some(false),
) else {
return;
};
change_floating_panes_coordinates(vec![(
PaneId::Plugin(own_plugin_id),
next_coordinates,
)])... |
rust_dataset_chunk_510949 | rust_dataset.txt | 510,949 | 512 | length
}
fn extract_key_bindings(
keymap: &[(KeyWithModifier, Vec<Action>)],
) -> (Vec<KeyModifier>, String, String) {
let pane_group_keys = get_key_for_action(keymap, &[Action::TogglePaneInGroup]);
let group_mark_keys = get_key_for_action(keymap, &[Action::ToggleGroupMarking]);
let key_refs: Vec<&Ke... |
rust_dataset_chunk_510950 | rust_dataset.txt | 510,950 | 512 | WithModifier>) -> Vec<KeyModifier> {
if keys.is_empty() {
return vec![];
}
let mut common = keys[0].key_modifiers.clone();
for key in keys.iter().skip(1) {
common = common.intersection(&key.key_modifiers).cloned().collect();
}
common.into_iter().collect()
}
fn render_follow_f... |
rust_dataset_chunk_510951 | rust_dataset.txt | 510,951 | 512 | in-place manipulation
new_config_key: String,
new_config_val: String,
entering_plugin_url: bool,
entering_config_key: bool,
entering_config_val: bool,
selected_config_index: Option<usize>,
request_ids: Vec<String>,
load_in_background: bool,
colors: Styling,
}
impl Default for NewPl... |
rust_dataset_chunk_510952 | rust_dataset.txt | 510,952 | 512 | _plugin_url, cols.saturating_sub(18)); // 17 the length of the prompt + 1 for padding
let text = format!("Enter Plugin URL: {}", truncated_url);
Text::from(text).color_range(2, ..=16).color_range(0, 18..)
};
print_text_with_coordinates(url_field, 0, 2, None, None);
let ur... |
rust_dataset_chunk_510953 | rust_dataset.txt | 510,953 | 512 | ing_config_line() {
items.push(self.render_editing_config_line(config_key, config_val, cols));
} else {
items.push(self.render_config_line(config_key, config_val, is_selected, cols));
}
}
if self.editing_new_config_line() {
items.push(s... |
rust_dataset_chunk_510954 | rust_dataset.txt | 510,954 | 512 | EMPTY>".to_owned()
} else {
config_val
};
NestedListItem::new(
Text::from(format!("{}_: {}", config_key, val))
.color_range(3, ..=config_key.chars().count())
.color_range(1, config_key.chars().count() + 3..),
... |
rust_dataset_chunk_510955 | rust_dataset.txt | 510,955 | 512 | Ctrl l");
let key_shortcuts_text_len = key_shortcuts_text.len();
print_text_with_coordinates(
Text::from(key_shortcuts_text).color_range(3, ..).opaque(),
0,
y_coordinates,
None,
None,
);
let background = self.colors.text_unsele... |
rust_dataset_chunk_510956 | rust_dataset.txt | 510,956 | 512 | .entering_plugin_url {
Some(&mut self.new_plugin_url)
} else {
match self.selected_config_index {
Some(selected_config_index) => {
if self.entering_config_key {
self.new_plugin_config
.get_mut(selecte... |
rust_dataset_chunk_510957 | rust_dataset.txt | 510,957 | 512 | ).into_iter().collect();
let load_in_background = self.load_in_background;
let skip_plugin_cache = true;
load_new_plugin(plugin_url, config, load_in_background, skip_plugin_cache);
should_render = true;
should_close = tr... |
rust_dataset_chunk_510958 | rust_dataset.txt | 510,958 | 512 | {
let max_len = self.new_plugin_config.len().saturating_sub(1);
let has_config_values = !self.new_plugin_config.is_empty();
if self.selected_config_index.is_none() && has_config_values {
self.selected_config_index = Some(max_len);
... |
rust_dataset_chunk_510959 | rust_dataset.txt | 510,959 | 512 | ,
}
register_plugin!(State);
impl ZellijPlugin for State {
fn load(&mut self, configuration: BTreeMap<String, String>) {
self.userspace_configuration = configuration;
subscribe(&[
EventType::ModeUpdate,
EventType::PaneUpdate,
EventType::TabUpdate,
Ev... |
rust_dataset_chunk_510960 | rust_dataset.txt | 510,960 | 512 | .insert(pane_info.id, tab_position);
}
}
}
},
Event::Key(key) => match self.new_plugin_screen.as_mut() {
Some(new_plugin_screen) => {
let (should_render_new_plugin_scre... |
rust_dataset_chunk_510961 | rust_dataset.txt | 510,961 | 512 | }
fn render_plugin_list(&self, cols: usize) -> (Option<usize>, Vec<NestedListItem>) {
let mut selected_index_in_list = None;
let mut plugin_list = vec![];
for (i, (plugin_id, plugin_info)) in self.plugins.iter().enumerate() {
let is_selected = Some(i) == self.selected_index;
... |
rust_dataset_chunk_510962 | rust_dataset.txt | 510,962 | 512 | , 0, 0, None, None);
}
}
pub fn render_plugin(
&self,
plugin_id: u32,
plugin_info: &PluginInfo,
is_selected: bool,
is_expanded: bool,
cols: usize,
) -> Vec<NestedListItem> {
let mut items = vec![];
let plugin_location_len = graphemes::d... |
rust_dataset_chunk_510963 | rust_dataset.txt | 510,963 | 512 | Text::from(format!("{}: {}", config_key, config_val))
.color_range(0, ..config_key.chars().count())
.color_range(1, config_key.chars().count() + 2..),
)
.indent(2)
}
pub fn render_search_result(
&self,
search_result: &SearchResult,
is_sele... |
rust_dataset_chunk_510964 | rust_dataset.txt | 510,964 | 512 | {
let mut item = Text::from(format!("{} [+{}]", location_string, plus_indication))
.color_range(0, ..)
.color_range(1, location_string.chars().count() + 1..);
if let Some(indices) = indices {
item = item.color_indices(3, indices);
}
NestedListItem::ne... |
rust_dataset_chunk_510965 | rust_dataset.txt | 510,965 | 512 | full_text.chars().count() {
let text = Text::from(full_text)
.color_range(3, 5..=11)
.color_range(3, 32..=38)
.color_range(3, 49..=53)
.color_range(3, 65..=69)
.color_range(3, 80..=87)
.color_range(3, 96..=100);... |
rust_dataset_chunk_510966 | rust_dataset.txt | 510,966 | 512 | self) {
self.selected_index = None;
self.expanded_indices.clear();
}
pub fn expand_selected(&mut self) {
if let Some(selected_index) = &self.selected_index {
self.expanded_indices.push(*selected_index);
}
}
pub fn collapse_selected(&mut self) {
if let... |
rust_dataset_chunk_510967 | rust_dataset.txt | 510,967 | 512 | self.is_searching() {
self.search_results.len().saturating_sub(1)
} else {
self.plugins.keys().len().saturating_sub(1)
};
if self.selected_index.is_none() {
self.selected_index = Some(0);
} else ... |
rust_dataset_chunk_510968 | rust_dataset.txt | 510,968 | 512 | mut plugin_list: Vec<NestedListItem>,
max_list_items: usize,
) -> (usize, usize, Vec<NestedListItem>) {
let mut more_above = 0;
let mut more_below = 0;
if plugin_list.len() > max_list_items {
let anchor_line = selected_index_in_list.unwrap_or(0);
let l... |
rust_dataset_chunk_510969 | rust_dataset.txt | 510,969 | 512 | {
let truncated = truncate_string_start("/home/ünïcödé/plügîn.wasm", 12);
assert_eq!(truncated, "[...]în.wasm");
assert_eq!(graphemes::display_width(&truncated), 12);
}
#[test]
fn truncate_string_start_never_splits_a_cluster() {
let family = "\u{1f468}\u{200d}\u{1f469}\u{20... |
rust_dataset_chunk_510970 | rust_dataset.txt | 510,970 | 512 | {
BlockPipe(String),
SetExitCode(String, i32),
Output(String, String),
UnblockPipe(String),
ReplyToPrompt(u64, PromptResult),
SetPopupSize(usize, usize),
SetTimeout(f64),
ShowSelf,
CloseSelf,
FocusPane(PaneId),
WatchNames,
}
#[derive(Default)]
pub struct App {
source: O... |
rust_dataset_chunk_510971 | rust_dataset.txt | 510,971 | 512 | pipe_prompt| {
let destination = destination.clone().for_request(&pipe_prompt);
request_from_pipe_prompt(pipe_prompt).map(|request| (destination, request))
});
let (destination, request) = match parsed {
Ok(parsed) => parsed,
Err(error) => {
... |
rust_dataset_chunk_510972 | rust_dataset.txt | 510,972 | 512 | self
.screen
.as_mut()
.map(|screen| screen.update_tabs(tabs))
.unwrap_or(false);
if changed {
self.request_popup_size();
}
changed
}
fn close_notice(&mut self) {
self.finished = true;
self.push(... |
rust_dataset_chunk_510973 | rust_dataset.txt | 510,973 | 512 | .map(|screen| screen.handle_timer())
.unwrap_or(false);
if let Some(deadline) = self.deadline {
if now >= deadline && self.released {
self.close_notice();
return false;
}
if now >= deadline {
let answer =... |
rust_dataset_chunk_510974 | rust_dataset.txt | 510,974 | 512 | }
fn has_confirm_footer(&self) -> bool {
self.screen
.as_ref()
.map(|screen| screen.has_own_frame())
.unwrap_or(false)
}
fn has_own_footer(&self) -> bool {
self.screen
.as_ref()
.map(|screen| screen.has_own_footer())
... |
rust_dataset_chunk_510975 | rust_dataset.txt | 510,975 | 512 | as_ref()
.map(|screen| screen.is_notice())
.unwrap_or(false)
}
pub fn desired_size(&self) -> Option<(usize, usize)> {
let screen = self.screen.as_ref()?;
if screen.is_notice() {
return Some(screen.desired_size());
}
let (body_width, body_height... |
rust_dataset_chunk_510976 | rust_dataset.txt | 510,976 | 512 | �{}╮", "─".repeat(inner))),
};
print_text_with_coordinates(top, 0, 0, Some(cols), None);
for row in 1..rows - 1 {
print_text_with_coordinates(Text::from("│"), 0, row, Some(1), None);
print_text_with_coordinates(Text::from("│"), cols - 1, row, Some(1), None);
}
... |
rust_dataset_chunk_510977 | rust_dataset.txt | 510,977 | 512 | );
}
} else if self.has_own_footer() {
let body_height = height.saturating_sub(header_rows).max(1);
if let Some(screen) = self.screen.as_mut() {
screen.render(x, y + header_rows, width, body_height);
}
} else {
l... |
rust_dataset_chunk_510978 | rust_dataset.txt | 510,978 | 512 | ![
Effect::BlockPipe("p".to_owned()),
Effect::SetExitCode("p".to_owned(), 1),
]
);
app.handle_key(KeyWithModifier::new(BareKey::Enter));
assert_eq!(
pipe_effects(&app.take_effects()),
vec![
Effect::SetExitCode("p... |
rust_dataset_chunk_510979 | rust_dataset.txt | 510,979 | 512 | app.take_effects();
let (cols, rows) = app.desired_size().unwrap();
app.render(rows, cols, now);
app.handle_mouse(Mouse::LeftClick(1, 2));
assert_eq!(
pipe_effects(&app.take_effects()),
vec![Effect::FocusPane(PaneId::Terminal(7)), Effect::CloseSelf]
);
... |
rust_dataset_chunk_510980 | rust_dataset.txt | 510,980 | 512 | &[
("message", "x"),
("_caller_pane_id", "terminal_7"),
("no_pane_name", "true"),
("no_tab_name", "true"),
],
None,
),
now,
);
... |
rust_dataset_chunk_510981 | rust_dataset.txt | 510,981 | 512 | );
app.handle_pipe(message("p", "choose", &[], Some("c\nd\ne\n")), now);
app.handle_pipe(message("p", "choose", &[], None), now);
app.take_effects();
for _ in 0..4 {
app.handle_key(KeyWithModifier::new(BareKey::Down));
}
app.handle_key(KeyWithModifier::new(Bar... |
rust_dataset_chunk_510982 | rust_dataset.txt | 510,982 | 512 | 2));
}
#[test]
fn a_second_request_to_a_busy_prompt_is_refused() {
let mut app = App::default();
app.handle_pipe(message("p", "toggle", &[], None), Instant::now());
app.take_effects();
app.handle_pipe(message("q", "toggle", &[], None), Instant::now());
let effects =... |
rust_dataset_chunk_510983 | rust_dataset.txt | 510,983 | 512 | true,
};
app.handle_pipe(pipe_message, Instant::now());
assert!(app.take_effects().contains(&Effect::ShowSelf));
}
#[test]
fn only_popups_without_their_own_frame_get_a_frame() {
let mut app = App::default();
app.handle_pipe(
message("p", "choose", &[("it... |
rust_dataset_chunk_510984 | rust_dataset.txt | 510,984 | 512 | "b"]),
&[BareKey::Down, BareKey::Enter]
),
vec![
Effect::ReplyToPrompt(
5,
PromptResult::Answered(PromptValue::Choice("b".to_owned()))
),
Effect::CloseSelf
]
);
as... |
rust_dataset_chunk_510985 | rust_dataset.txt | 510,985 | 512 | default();
app.handle_pipe(
plugin_message(5, PromptRequest::toggle("t")),
Instant::now(),
);
app.take_effects();
app.handle_pipe(
plugin_message(6, PromptRequest::toggle("t")),
Instant::now(),
);
let effects = pipe_effects(... |
rust_dataset_chunk_510986 | rust_dataset.txt | 510,986 | 512 | CloseSelf]);
let (mut app, _) = start();
app.handle_timer(now + Duration::from_secs(6));
assert_eq!(pipe_effects(&app.take_effects()), vec![Effect::CloseSelf]);
}
#[test]
fn a_dialog_form_answers_the_plugin_with_its_fields() {
let request = || {
PromptRequest::fo... |
rust_dataset_chunk_510987 | rust_dataset.txt | 510,987 | 512 | , defaults: &Option<Map<String, Value>>) -> Option<Value> {
defaults
.as_ref()
.and_then(|defaults| defaults.get(&field.id).cloned())
.or_else(|| field.default.clone())
}
fn choose_items(field: &FormField, marked: &[bool]) -> Vec<MenuItem> {
field
.options
.iter()
... |
rust_dataset_chunk_510988 | rust_dataset.txt | 510,988 | 512 | index,
Toggle::new(field.label.clone(), on).label_width(label_width),
);
},
FormFieldKind::Number => {
let mut value = default
.as_ref()
.and_then(|d| d.as_i64())
... |
rust_dataset_chunk_510989 | rust_dataset.txt | 510,989 | 512 | FieldKind::Choose))
}
fn message_lines(&self, width: usize) -> Vec<Text> {
match &self.spec.message {
Some(message) => Text::from(message.clone()).wrap(width.min(DIALOG_TEXT_WIDTH).max(1)),
None => vec![],
}
}
fn header_rows(&self, width: usize) -> usize {
... |
rust_dataset_chunk_510990 | rust_dataset.txt | 510,990 | 512 | .highlighted_index()) else {
return Step::Nothing;
};
let mut marked: Vec<bool> = list.items().iter().map(|item| item.is_marked()).collect();
let was_marked = marked.get(position).copied().unwrap_or(false);
if !field.multi {
marked.iter_mut().for_each(|m| *m = fal... |
rust_dataset_chunk_510991 | rust_dataset.txt | 510,991 | 512 | text_input(&index)
.map(|input| input.get_text().to_owned())
.unwrap_or_default(),
),
FormFieldKind::Select => self
.group
.dropdown(&index)
.and_then(|... |
rust_dataset_chunk_510992 | rust_dataset.txt | 510,992 | 512 | iValue::Choice { index, .. }) = response {
return self.toggle_choice(key, Some(index));
}
}
if !from_mouse {
if let UiResponse::Submitted(_) = response {
self.group.focus_next();
... |
rust_dataset_chunk_510993 | rust_dataset.txt | 510,993 | 512 | Step::Redraw;
}
}
if key.is_key_without_modifier(BareKey::Down) && !self.focused_uses_up_down() {
self.group.focus_next();
self.follow_focus = true;
return Step::Redraw;
}
if key.is_key_without_modifier(BareKey::Up) && !self.focused_uses_u... |
rust_dataset_chunk_510994 | rust_dataset.txt | 510,994 | 512 | (width) + fields + bottom_padding
}
pub fn render(&mut self, x: usize, y: usize, width: usize, height: usize) {
self.group.clear_areas();
let total = self.content_height(width.saturating_sub(DIALOG_PADDING * 2));
self.scroll.set_total_rows(total);
self.scroll.layout(x, y, width, ... |
rust_dataset_chunk_510995 | rust_dataset.txt | 510,995 | 512 | field = self.spec.fields[index].clone();
let mut body_rows = 1;
match field.kind {
FormFieldKind::Input => {
if let Some(input) = self.group.text_input_mut(&index) {
input.render(x, screen_y, content_width);
}
... |
rust_dataset_chunk_510996 | rust_dataset.txt | 510,996 | 512 | _width = self
.group
.button(&submit_key)
.map(|b| b.natural_width())
.unwrap_or(8);
let buttons_x = if self.is_dialog() {
centered_x(self.buttons_width())
} else {
x
... |
rust_dataset_chunk_510997 | rust_dataset.txt | 510,997 | 512 | p| Pattern(regex::Regex::new(p).unwrap()))
})
.collect();
FormScreen::new(spec, patterns, None)
}
const EXAMPLE: &str = r#"{ "title": "New project",
"fields": [
{ "id": "name", "type": "input", "label": "Name", "validate": "^[a-z-]+$", "required": true },
... |
rust_dataset_chunk_510998 | rust_dataset.txt | 510,998 | 512 | }
assert_eq!(screen.handle_key(&key(BareKey::Char(' '))), Step::Redraw);
match screen.try_submit() {
Step::Done(Outcome::Answered(Answer::Form(values))) => {
assert_eq!(
crate::outcome::ordered_object(&values),
r#"{"name":"demo"... |
rust_dataset_chunk_510999 | rust_dataset.txt | 510,999 | 512 | areKey::Enter)), Step::Redraw);
}
#[test]
fn required_choose_needs_a_ticked_option_and_esc_cancels() {
let mut screen =
form(r#"{"fields":[{"id":"f","type":"choose","options":["a","b"],"required":true}]}"#);
assert_eq!(screen.try_submit(), Step::Redraw);
assert!(screen.e... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.